forked from cminyard/gensio
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
238 lines (206 loc) · 6.84 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
cmake_minimum_required(VERSION 3.10)
cmake_policy(SET CMP0078 NEW) # For swig
project(gensio VERSION 2.4.0)
set (gensio_VERSION_STRING "${gensio_VERSION_MAJOR}.${gensio_VERSION_MINOR}.${gensio_VERSION_PATCH}")
include_directories("${PROJECT_BINARY_DIR}" "${PROJECT_SOURCE_DIR}/include"
"${PROJECT_BINARY_DIR}/include" )
include(CheckLibraryExists)
include(CheckIncludeFile)
include(CheckSymbolExists)
include(CheckCSourceCompiles)
include(GNUInstallDirs)
include(FindPkgConfig)
include(FindTCL)
if (WIN32)
# Suppress packing error warnings, as they are ubiquitous and don't matter.
set (CMAKE_C_FLAGS "/wd4820")
set (CMAKE_RUNTIME_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}/output")
else()
set (CMAKE_C_FLAGS "-Wall")
endif()
option(BUILD_SHARED_LIBS "Build using shared libraries" ON)
option(ALSOSTATIC "When buiding a shared library, build a static one, too")
option(ENABLE_TCP_WRAPPERS "Enable tcpwrappers support" ON)
if(ENABLE_TCP_WRAPPERS)
CHECK_INCLUDE_FILE(tcpd.h HAVE_TCPD_H)
if(HAVE_TCPD_H)
list(APPEND EXTRA_LIBS wrap)
endif()
endif()
option(ENABLE_PTHREADS "Enable pthreads" ON)
set(USE_PTHREADS 0)
if(ENABLE_PTHREADS)
CHECK_LIBRARY_EXISTS(pthread "pthread_create" "" PTHREAD_LIB_FOUND)
CHECK_INCLUDE_FILE(pthread.h PTHREAD_INC_FOUND)
if(PTHREAD_LIB_FOUND AND PTHREAD_INC_FOUND)
set(USE_PTHREADS 1)
list(APPEND EXTRA_LIBS pthread)
endif()
endif()
option(ENABLE_EPOLL "Enable epoll support" ON)
if(ENABLE_EPOLL)
CHECK_INCLUDE_FILE(sys/epoll.h HAVE_EPOLL_PWAIT)
endif()
# Currently only support glib on Unix
option(ENABLE_GLIB "Enable GLIB support" ${UNIX})
if(ENABLE_GLIB)
pkg_check_modules(GLIB glib-2.0)
if(GLIB_FOUND)
set(HAVE_GLIB ON)
set(GLIB_LIB gensioglib)
set(GLIB_LIBS -lglib-2.0)
endif()
endif()
set(TCL_LIBS )
option(ENABLE_TCL "Enable TCL support" ON)
if(ENABLE_TCL)
if(TCL_FOUND)
set(HAVE_TCL ON)
set(TCL_LIB gensiotcl)
set(TCL_LIBS ${TCL_LIBRARY})
endif()
endif()
option(ENABLE_OPENIPMI "Enable OpenIPMI serial over LAN support" ON)
if(ENABLE_OPENIPMI)
CHECK_LIBRARY_EXISTS(OpenIPMI "ipmi_alloc_os_handler" "" OPENIPMI_LIB_FOUND)
CHECK_INCLUDE_FILE(OpenIPMI/ipmiif.h OPENIPMI_INC_FOUND)
if(OPENIPMI_LIB_FOUND AND OPENIPMI_INC_FOUND)
set(HAVE_OPENIPMI 1)
if(USE_PTHREADS)
list(APPEND EXTRA_LIBS OpenIPMI OpenIPMIpthread OpenIPMIutils)
else()
list(APPEND EXTRA_LIBS OpenIPMI OpenIPMIposix OpenIPMIutils)
endif()
endif()
endif()
option(ENABLE_OPENSSL "Enable openssl" ON)
set(HAVE_OPENSSL 0)
if(ENABLE_OPENSSL)
CHECK_LIBRARY_EXISTS(ssl "SSL_connect" "" SSL_LIB_FOUND)
CHECK_LIBRARY_EXISTS(crypto "X509_verify_cert" "" CRYPTO_LIB_FOUND)
CHECK_INCLUDE_FILE(openssl/ssl.h SSL_INC_FOUND)
CHECK_INCLUDE_FILE(openssl/x509.h CRYPTO_INC_FOUND)
if(SSL_LIB_FOUND AND SSL_INC_FOUND AND CRYPTO_LIB_FOUND AND CRYPTO_INC_FOUND)
set(HAVE_OPENSSL 1)
list(APPEND EXTRA_LIBS ssl crypto)
endif()
endif()
option(ENABLE_MDNS "Enable MDNS" ON)
set(HAVE_AVAHI 0)
if(ENABLE_MDNS)
CHECK_LIBRARY_EXISTS(avahi-client "avahi_client_new" "" AVAHI_CLI_LIB_FOUND)
CHECK_LIBRARY_EXISTS(avahi-common "avahi_malloc" "" AVAHI_COM_LIB_FOUND)
CHECK_INCLUDE_FILE(avahi-client/client.h AVAHI_CLI_INC_FOUND)
CHECK_INCLUDE_FILE(avahi-common/malloc.h AVAHI_COM_INC_FOUND)
if(AVAHI_CLI_LIB_FOUND AND AVAHI_CLI_INC_FOUND AND AVAHI_COM_LIB_FOUND AND AVAHI_COM_INC_FOUND)
set(HAVE_AVAHI 1)
list(APPEND EXTRA_LIBS avahi-client avahi-common)
endif()
endif()
option(ENABLE_SWIG "Enable swig support" ON)
if(ENABLE_SWIG)
find_package(SWIG)
endif()
option(ENABLE_PYTHON "Enable python support" ON)
if(ENABLE_PYTHON)
set (Python_ADDITIONAL_VERSIONS 3 2)
find_package(PythonInterp)
find_package(PythonLibs)
# FIXME - we are assuming this for now.
option(PYTHON_HAS_THREADS "Support threading in python" ON)
endif()
option(ENABLE_SCTP "Enable SCTP support" ON)
if(ENABLE_SCTP)
CHECK_LIBRARY_EXISTS(sctp "sctp_bindx" "" HAVE_LIBSCTP)
if (HAVE_LIBSCTP)
list(APPEND EXTRA_LIBS sctp)
endif()
endif()
if(HAVE_LIBSCTP)
CHECK_LIBRARY_EXISTS(sctp "sctp_sendv" "" HAVE_SCTP_SENDV)
endif()
string(COMPARE EQUAL "${CMAKE_HOST_SYSTEM_NAME}" "Linux" HAVE_WORKING_PORT0)
CHECK_LIBRARY_EXISTS(pam "pam_start" "" HAVE_PAM)
check_symbol_exists(TIOCSRS485 sys/ioctl.h HAVE_DECL_TIOCSRS485)
check_symbol_exists(SIGWINCH signal.h HAVE_DECL_SIGWINCH)
CHECK_INCLUDE_FILE(sys/un.h HAVE_UNIX)
option(USE_FILE_STDIO "Use stdio instead of unix files for the file gensio"
${MSVC})
option(ENABLE_INTERNAL_TRACE
"Enable internal trace tools, required for oomtest"
OFF)
set (prefix "${CMAKE_INSTALL_PREFIX}")
set (exec_prefix "${CMAKE_INSTALL_PREFIX}")
set (libdir "${CMAKE_INSTALL_FULL_LIBDIR}")
set (includedir "${CMAKE_INSTALL_FULL_INCLUDEDIR}")
set (VERSION "${PROJECT_VERSION}")
check_c_source_compiles("int main()
{
static int counter = 0;
int val;
__atomic_load(&counter, &val, __ATOMIC_SEQ_CST);
return val;
}" HAVE_GCC_ATOMICS)
check_symbol_exists(sendmsg sys/socket.h HAVE_SENDMSG)
check_symbol_exists(recvmsg sys/socket.h HAVE_RECVMSG)
check_symbol_exists(isatty unistd.h HAVE_ISATTY)
check_symbol_exists(strcasecmp string.h HAVE_STRCASECMP)
check_symbol_exists(strncasecmp string.h HAVE_STRNCASECMP)
check_symbol_exists(prctl sys/prctl.h HAVE_PRCTL)
check_symbol_exists(getrandom sys/random.h HAVE_GETRANDOM_FUNC)
set (CMAKE_REQUIRED_DEFINITIONS "-D_GNU_SOURCE")
check_symbol_exists(ptsname_r "stdlib.h" HAVE_PTSNAME_R)
check_symbol_exists(cfmakeraw "termios.h" HAVE_CFMAKERAW)
check_symbol_exists(signalfd "signalfd.h" HAVE_SIGNALFD)
check_symbol_exists(regexec "regex.h" HAVE_REGEXEC)
check_symbol_exists(fnmatch "fnmatch.h" HAVE_FNMATCH)
if (${CMAKE_HOST_SYSTEM_NAME} STREQUAL "Darwin")
set(APPLE ON)
else()
set(APPLE OFF)
endif()
if (${UNIX})
if (${APPLE})
set(DEF_UUCP_LOCKING OFF)
else()
set(DEF_UUCP_LOCKING ON)
endif()
else()
set(DEF_UUCP_LOCKING OFF)
endif()
if (${CMAKE_HOST_SYSTEM_NAME} STREQUAL "Linux")
set(UUCP_LOCK_DIR "/var/lock")
else()
set(UUCP_LOCK_DIR "/var/spool/lock")
endif()
option(USE_UUCP_LOCKING "Enable UUCP lock file handling for devices"
${DEF_UUCP_LOCKING})
if(UNIX)
set(HAVE_PTY 1)
else()
set(HAVE_PTY 0)
list(APPEND EXTRA_LIBS ws2_32 bcrypt Iphlpapi)
endif()
configure_file(config.h.cmake config.h)
add_subdirectory(lib)
add_subdirectory(c++)
if(HAVE_GLIB)
add_subdirectory(glib)
endif()
if(HAVE_TCL)
add_subdirectory(tcl)
endif()
add_subdirectory(include)
add_subdirectory(tools)
add_subdirectory(examples)
if(SWIG_FOUND)
add_subdirectory(swig)
endif()
add_subdirectory(man)
add_subdirectory(tests)
set(CPACK_SOURCE_GENERATOR "TGZ")
set(CPACK_SOURCE_PACKAGE_FILE_NAME
"${CMAKE_PROJECT_NAME}-${gensio_VERSION_MAJOR}.${gensio_VERSION_MINOR}.${gensio_VERSION_PATCH}")
set(CPACK_SOURCE_IGNORE_FILES "/.git/;/Z.*/;~$;${CPACK_SOURCE_IGNORE_FILES}")
include(CPack)
add_custom_target(dist COMMAND ${CMAKE_MAKE_PROGRAM} package_source)