-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathCMakeLists.txt
379 lines (294 loc) · 11.7 KB
/
CMakeLists.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
cmake_minimum_required(VERSION 3.10)
project (linm)
set(PACKAGE "linm")
set(VERSION "0.9.1")
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wp,-w")
# where to look first for cmake modules, before ${CMAKE_ROOT}/Modules/ is checked
set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake/Modules)
message( STATUS "CMAKE_BINARY_DIR: ${CMAKE_BINARY_DIR}")
message( STATUS "CMAKE_SOURCE_DIR: ${CMAKE_SOURCE_DIR}")
# disallow in-source build
include(MacroEnsureOutOfSourceBuild)
macro_ensure_out_of_source_build("${PROJECT_NAME} requires an out of source build. Please create a separate build directory and run 'cmake /path/to/${PROJECT_NAME} [options]' there.")
#set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
#set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
#set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
# header or library check.
include(CheckIncludeFiles)
include(CheckFunctionExists)
include(CheckLibraryExists)
include(CheckTypeSize)
include(CheckStructHasMember)
include(CheckIncludeFileCXX)
find_package( Threads )
# Boost library find
# set(Boost_USE_STATIC_LIBS ON) # only find static libs
# set(Boost_USE_MULTITHREADED ON)
# find_package(Boost 1.50.0 COMPONENTS program_options signals system)
# if (NOT Boost_FOUND)
# message(FATAL_ERROR "'boost' library is not found. please install 'boost' library.(http://www.boost.org/)")
#else()
# include_directories(${Boost_INCLUDE_DIRS})
# message( STATUS "BOOST INCLUDE : ${Boost_INCLUDE_DIRS}")
# message( STATUS "BOOST LIBS : ${Boost_LIBRARIES}")
#endif()
CHECK_INCLUDE_FILES(errno.h HAVE_ERRNO_H)
CHECK_INCLUDE_FILES(fcntl.h HAVE_FCNTL_H)
check_function_exists (alloca HAVE_ALLOCA)
check_function_exists (asprintf HAVE_ASPRINTF)
CHECK_INCLUDE_FILES(alloca.h HAVE_ALLOCA_H)
CHECK_INCLUDE_FILES(argz.h HAVE_ARGZ_H)
check_function_exists (CFLocaleCopyCurrent HAVE_CFLOCALECOPYCURRENT)
check_function_exists (CFPreferencesCopyAppValue HAVE_CFPREFERENCESCOPYAPPVALUE)
CHECK_INCLUDE_FILES (curses.h HAVE_CURSES_H)
check_function_exists (getopt getopt_long HAVE_DECL_GETOPT)
check_function_exists (_snprintf HAVE_DECL__SNPRINTF)
check_function_exists (_snwprintf HAVE_DECL__SNWPRINTF)
CHECK_INCLUDE_FILES(argz.h HAVE_ARGZ_H)
check_function_exists (vprintf HAVE_DOPRNT)
check_function_exists (fwprintf HAVE_FWPRINTF)
check_function_exists (getegid HAVE_GETEGID)
check_function_exists (geteuid HAVE_GETEUID)
check_function_exists (getgid HAVE_GETGID)
check_function_exists (getopt HAVE_GETOPT)
check_function_exists (getopt_long HAVE_GETOPT_LONG)
check_function_exists (getpt HAVE_GETPT)
check_function_exists (gettimeofday HAVE_GETTIMEOFDAY)
check_function_exists (getuid HAVE_GETUID)
check_function_exists (grantpt HAVE_GRANTPT)
check_function_exists (intmax_t HAVE_INTMAX_T)
CHECK_INCLUDE_FILES (inttypes.h HAVE_INTTYPES_H)
CHECK_INCLUDE_FILES (inttypes.h HAVE_INTTYPES_H_WITH_UINTMAX)
CHECK_INCLUDE_FILES (langinfo.h HAVE_LANGINFO_CODESET)
CHECK_LIBRARY_EXISTS (pt "" "" "HAVE_LIBPT")
CHECK_INCLUDE_FILES (pthread.h PTHREAD_ENABLE)
CHECK_INCLUDE_FILES (limits.h HAVE_LIMITS_H)
CHECK_INCLUDE_FILES ("locale.h;libintl.h" HAVE_LC_MESSAGES)
CHECK_INCLUDE_FILES ("locale.h" HAVE_LOCALE_H)
CHECK_TYPE_SIZE("long double" HAVE_LONG_DOUBLE)
CHECK_TYPE_SIZE("long long" HAVE_LONG_LONG)
CHECK_TYPE_SIZE("lstat" HAVE_LSTAT_EMPTY_STRING_BUG)
check_function_exists (malloc HAVE_MALLOC)
CHECK_INCLUDE_FILES (malloc.h HAVE_MALLOC_H)
CHECK_INCLUDE_FILES (memory.h HAVE_MEMORY_H)
check_function_exists (mempcpy HAVE_MEMPCPY)
check_function_exists (memset HAVE_MEMSET)
check_function_exists (mkdir HAVE_MKDIR)
check_function_exists (mmap HAVE_MMAP)
check_function_exists (munmap HAVE_MUNMAP)
CHECK_INCLUDE_FILES (ncurses.h HAVE_NCURSES_H)
CHECK_INCLUDE_FILES (ndir.h HAVE_NDIR_H)
CHECK_INCLUDE_FILES (nl_types.h HAVE_NL_TYPES_H)
check_function_exists (poll HAVE_POLL)
check_function_exists (posix_openpt HAVE_POSIX_OPENPT)
check_function_exists (printf HAVE_POSIX_PRINTF)
check_function_exists (putenv HAVE_PUTENV)
check_function_exists (select HAVE_SELECT)
check_function_exists (setenv HAVE_SETENV)
check_function_exists (setlocale HAVE_SETLOCALE)
check_function_exists (snprintf HAVE_SNPRINTF)
check_function_exists (stat HAVE_STAT_EMPTY_STRING_BUG)
CHECK_INCLUDE_FILES (stdbool.h HAVE_STDBOOL_H)
CHECK_INCLUDE_FILES (stddef.h HAVE_STDDEF_H)
CHECK_INCLUDE_FILES (stdint.h HAVE_STDINT_H)
CHECK_INCLUDE_FILES ("stdint.h;sys/types.h" HAVE_STDINT_H_WITH_UINTMAX)
CHECK_INCLUDE_FILES (stdio.h HAVE_STDIO_H)
CHECK_INCLUDE_FILES (stdlib.h HAVE_STDLIB_H)
check_function_exists (stpcpy HAVE_STPCPY)
check_function_exists (strcasecmp HAVE_STRCASECMP)
check_function_exists (strdup HAVE_STRDUP)
CHECK_INCLUDE_FILES (string.h HAVE_STRING_H)
CHECK_INCLUDE_FILES (strings.h HAVE_STRINGS_H)
check_function_exists (strtol HAVE_STRTOL)
check_function_exists (strtoul HAVE_STRTOUL)
CHECK_INCLUDE_FILES (sys/dir.h HAVE_SYS_DIR_H)
CHECK_INCLUDE_FILES (sys/param.h HAVE_SYS_PARAM_H)
CHECK_INCLUDE_FILES (sys/select.h HAVE_SYS_SELECT_H)
CHECK_INCLUDE_FILES (sys/socket.h HAVE_SYS_SOCKET_H)
CHECK_INCLUDE_FILES (sys/stat.h HAVE_SYS_STAT_H)
CHECK_INCLUDE_FILES (sys/types.h HAVE_SYS_TYPES_H)
CHECK_INCLUDE_FILES (sys/uio.h HAVE_SYS_UIO_H)
CHECK_INCLUDE_FILES (sys/wait.h HAVE_SYS_WAIT_H)
CHECK_TYPE_SIZE ("uintmax_t" HAVE_UINTMAX_T)
CHECK_INCLUDE_FILES (unistd.h HAVE_UNISTD_H)
CHECK_TYPE_SIZE("unsigned long long" HAVE_UNSIGNED_LONG_LONG)
check_function_exists (vprintf HAVE_VPRINTF)
CHECK_TYPE_SIZE("wchar_t" HAVE_WCHAR_T)
check_function_exists (wcslen HAVE_WCSLEN)
set(_FILE_OFFSET_BITS 64)
set(_LARGEFILE_SOURCE TRUE)
include(GNUInstallDirs)
add_definitions("-DHAVE_CONFIG_H")
include_directories(${CMAKE_SOURCE_DIR} ${CMAKE_SOURCE_DIR}/intl ${CMAKE_SOURCE_DIR} ${CMAKE_BINARY_DIR} )
########### find iconv library
find_library(LIBICONV NAMES iconv HINTS "/usr/lib")
find_file(ICONV_H iconv.h HINTS "/usr/local/opt/libiconv/include" )
if (NOT ICONV_H)
message("Please install 'iconv' library. (https://ftp.gnu.org/pub/gnu/libiconv/)")
message(FATAL_ERROR "'iconv' library is not found.")
else()
set(HAVE_ICONV "TRUE")
set(ICONV_CONST "TRUE")
message( STATUS "iconv: ${LIBICONV}")
endif()
########### find intl(gettext) library
find_library(LIBINTL intl)
find_path(PATH_LIBINTL_H libintl.h HINTS "/usr/local/include" )
if (NOT PATH_LIBINTL_H)
message(FATAL_ERROR "'libintl.h' is not found. please install 'gettext' library or libc6.(https://www.gnu.org/software/gettext)")
else()
include_directories( ${PATH_LIBINTL_H} )
set(HAVE_GETTEXT "TRUE")
add_definitions( -DLOCALEDIR=\"${CMAKE_INSTALL_LOCALEDIR}\" )
message( STATUS "intl: ${LIBINTL} ${PATH_LIBINTL_H}")
endif()
########### set configure file
option(LINM_CFGPATH "set configure file install path. (default: '${CMAKE_INSTALL_PREFIX}/etc/linm')")
if(LINM_CFGPATH)
set(__LINM_CFGPATH__ "${LINM_CFGPATH}")
else()
set(__LINM_CFGPATH__ "${CMAKE_INSTALL_PREFIX}/etc/linm")
endif(LINM_CFGPATH)
message( STATUS "Option - configure path : '${__LINM_CFGPATH__}'" )
########### set bin path
option(LINM_BINPATH "set binary file install path. (default: '${CMAKE_INSTALL_PREFIX}/bin/linm')")
if(LINM_BINPATH)
set(__LINM_BINPATH__ "${LINM_BINPATH}")
else()
set(__LINM_BINPATH__ "${CMAKE_INSTALL_PREFIX}/bin/linm")
endif(LINM_BINPATH)
message( STATUS "Option - configure path : '${__LINM_CFGPATH__}'" )
########### set debug mode
option(DEBUG_MODE "Build debugging mode")
if( DEBUG_MODE )
set(__DEBUGMODE__ "ON" )
endif(DEBUG_MODE)
message( STATUS "Option - debug mode : ${DEBUG_MODE}" )
########### setting tar name
option(TAR_FILE_NAME "set 'tar' filename. (default: 'tar')")
if (TAR_FILE_NAME)
set(TARNAME ${TAR_FILE_NAME})
else()
find_program(GTAR gtar)
find_program(TAR tar)
if (GTAR)
set(TARGNAME "gtar")
else()
set(TARGNAME "tar")
endif(GTAR)
endif(TAR_FILE_NAME)
message( STATUS "Option - tar or gtar program name : '${TARGNAME}'" )
########### find ncurses library
find_library(CURSES_LIB curses)
find_library(NCURSES_LIB ncurses)
find_library(NCURSESW_LIB ncursesw)
if(NOT NCURSESW_LIB AND NOT NCURSES_LIB AND NOT NCURSESW_LIB)
message("")
message("Need to the ncurces library.")
message("")
message(" debian or ubuntu : ")
message(" apt-get install libncursesw5-dev libncurses5-dev")
message(" redhat or fedora : ")
message(" yum install ncurses-devel")
message(" other : ")
message(" Please refer to http://www.gnu.org/software/ncurses")
message("")
message(FATAL_ERROR "'curses' or 'ncurses' library is not found.")
else()
message(STATUS "find CURSES_LIB: ${CURSES_LIB}")
message(STATUS "find NCURSES_LIB: ${NCURSES_LIB}")
message(STATUS "find NCURSESW_LIB: ${NCURSESW_LIB}")
endif()
########### find openssl library
option(ENABLE_SFTP "Enable support for SFTP protocol. (default: ON)" ON)
if( ENABLE_SFTP )
if (EXISTS "/usr/local/opt/openssl")
set(OPENSSL_ROOT_DIR /usr/local/opt/openssl)
endif()
if (EXISTS "/usr/local/openssl")
set(OPENSSL_ROOT_DIR /usr/local/openssl)
endif()
include(FindOpenSSL)
find_library(SOCKET socket)
find_library(MLIB ceil)
include(FindPkgConfig)
if ( PKG_CONFIG_EXECUTABLE )
pkg_check_modules(LIBSSH2 REQUIRED libssh2>=1.8)
find_library(LIBSSH2 ssh2 PATHS ${LIBSSH2_LIBRARY_DIRS})
else ( PKG_CONFIG_EXECUTABLE )
find_library(LIBSSH2_LIBRARIES ssh2)
endif( PKG_CONFIG_EXECUTABLE )
message(STATUS "Option - SFTP protocol : ON")
if ( OPENSSL_FOUND AND LIBSSH2_LIBRARIES )
set(__LINM_SFTP_USE__ ON)
else()
if ( NOT OPENSSL_FOUND )
message("Unable to find openssl library.")
endif()
if ( NOT LIBSSH2_LIBRARIES )
message("Unable to find libssh2 library")
endif()
message(WARNING "Not support sftp protocol.")
endif()
else()
message(STATUS "Option - SFTP protocol : OFF")
endif()
option(ENABLE_SAMBA "Enable support for Microsoft SMB protocol. (default: OFF)")
if( ENABLE_SAMBA )
message(STATUS "Option - SMB protocol : ON")
find_library(SMBCLIENT_FOUND smbclient)
if ( SMBCLIENT_FOUND )
set(__LINM_SAMBA_USE__ ON)
endif( SMBCLIENT_FOUND )
else()
message(STATUS "Option - SMB protocol : OFF")
endif()
option(ENABLE_SOURCE_HIGHLIGHT "Enable support for source highlight. (default: ON)" ON)
if( ENABLE_SOURCE_HIGHLIGHT )
find_library(SOURCEHIGHLIGHT source-highlight)
find_path(PATH_HIGHLIGHT_H srchilite/highlightstate.h PATHS /usr/include )
if ( SOURCEHIGHLIGHT AND PATH_HIGHLIGHT_H )
include_directories( ${PATH_HIGHLIGHT_H} )
message(STATUS "Option - SOURCE HIGHLIGHT : ON")
set(__LINM_SOURCE_HIGHLIGHT_USE__ ON)
else()
set(ENABLE_SOURCE_HIGHLIGHT OFF)
message(STATUS "Option - SOURCE HIGHLIGHT : OFF")
endif()
else()
message(STATUS "Option - SOURCE HIGHLIGHT : OFF")
endif()
# subdirectory
#add_subdirectory(po)
add_subdirectory(libfswatch)
add_subdirectory(lib)
add_subdirectory(panel)
add_subdirectory(editor)
add_subdirectory(src)
add_subdirectory(sh)
if ( DEBUG_MODE )
add_subdirectory(test)
endif( DEBUG_MODE )
# make config.h
configure_file(
${CMAKE_CURRENT_SOURCE_DIR}/config.h.cmake
${CMAKE_CURRENT_BINARY_DIR}/config.h)
message("============================================")
message(" Build Status")
message("")
if ( DEBUG_MODE )
message("- Debug mode : ${DEBUG_MODE}" )
endif()
if ( NOT OPENSSL_FOUND OR NOT LIBSSH2_LIBRARIES )
message("- Unsupport sftp protocol.")
endif()
if( NOT ENABLE_SAMBA )
message("- Unsupport samba protocol.")
endif()
if( NOT ENABLE_SOURCE_HIGHLIGHT )
message("- Unsupport source highlight.")
endif()
message("============================================")
########### install files ###############
# install(FILES README.md README.ko DESTINATION share )