-
Notifications
You must be signed in to change notification settings - Fork 13
/
CMakeLists.txt
263 lines (231 loc) · 7.67 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
################################################################################
# THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY #
# Please refer to the README for information about making permanent changes. #
################################################################################
########################################################################
# Project setup
########################################################################
cmake_minimum_required(VERSION 2.8)
project(glar150)
enable_language(C)
enable_testing()
set(SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}")
########################################################################
# options
########################################################################
OPTION (ENABLE_DRAFTS "Build and install draft classes and methods" ON)
IF (ENABLE_DRAFTS)
ADD_DEFINITIONS (-DGLAR_BUILD_DRAFT_API)
ENDIF (ENABLE_DRAFTS)
########################################################################
# platform.h
########################################################################
include(CheckIncludeFile)
CHECK_INCLUDE_FILE("linux/wireless.h" HAVE_LINUX_WIRELESS_H)
CHECK_INCLUDE_FILE("net/if_media.h" HAVE_NET_IF_MEDIA_H)
include(CheckFunctionExists)
CHECK_FUNCTION_EXISTS("getifaddrs" HAVE_GETIFADDRS)
CHECK_FUNCTION_EXISTS("freeifaddrs" HAVE_FREEIFADDRS)
include(CheckIncludeFiles)
check_include_files("sys/socket.h;net/if.h" HAVE_NET_IF_H)
if (NOT HAVE_NET_IF_H)
CHECK_INCLUDE_FILE("net/if.h" HAVE_NET_IF_H)
endif()
file(WRITE "${SOURCE_DIR}/src/platform.h.in" "
#cmakedefine HAVE_LINUX_WIRELESS_H
#cmakedefine HAVE_NET_IF_H
#cmakedefine HAVE_NET_IF_MEDIA_H
#cmakedefine HAVE_GETIFADDRS
#cmakedefine HAVE_FREEIFADDRS
")
configure_file("${SOURCE_DIR}/src/platform.h.in" "${SOURCE_DIR}/src/platform.h")
#The MSVC C compiler is too out of date,
#so the sources have to be compiled as c++
if (MSVC)
enable_language(CXX)
file(GLOB sources "${SOURCE_DIR}/src/*.c")
set_source_files_properties(
${sources}
PROPERTIES LANGUAGE CXX
)
set(MORE_LIBRARIES ws2_32 Rpcrt4 Iphlpapi)
endif()
# required libraries for mingw
if (MINGW)
set(MORE_LIBRARIES -lws2_32 -lrpcrt4 -liphlpapi)
endif()
# required libraries for cygwin
if (CYGWIN)
set(MORE_LIBRARIES)
endif()
list(APPEND CMAKE_MODULE_PATH "${SOURCE_DIR}")
set(OPTIONAL_LIBRARIES)
########################################################################
# LIBZMQ dependency
########################################################################
find_package(libzmq REQUIRED)
IF (LIBZMQ_FOUND)
include_directories(${LIBZMQ_INCLUDE_DIRS})
list(APPEND MORE_LIBRARIES ${LIBZMQ_LIBRARIES})
ELSE (LIBZMQ_FOUND)
message( FATAL_ERROR "libzmq not found." )
ENDIF (LIBZMQ_FOUND)
########################################################################
# CZMQ dependency
########################################################################
find_package(czmq REQUIRED)
IF (CZMQ_FOUND)
include_directories(${CZMQ_INCLUDE_DIRS})
list(APPEND MORE_LIBRARIES ${CZMQ_LIBRARIES})
ELSE (CZMQ_FOUND)
message( FATAL_ERROR "czmq not found." )
ENDIF (CZMQ_FOUND)
########################################################################
# ZYRE dependency
########################################################################
find_package(zyre REQUIRED)
IF (ZYRE_FOUND)
include_directories(${ZYRE_INCLUDE_DIRS})
list(APPEND MORE_LIBRARIES ${ZYRE_LIBRARIES})
ELSE (ZYRE_FOUND)
message( FATAL_ERROR "zyre not found." )
ENDIF (ZYRE_FOUND)
########################################################################
# includes
########################################################################
set (glar_headers
include/glar_library.h
include/glar150.h
src/glard_init.sh
src/rc.local
)
IF (ENABLE_DRAFTS)
list(APPEND glar_headers
include/glar_node.h
include/glar_panel.h
include/glar_morse.h
)
ENDIF (ENABLE_DRAFTS)
source_group ("Header Files" FILES ${glar_headers})
install(FILES ${glar_headers} DESTINATION include)
########################################################################
# library
########################################################################
include_directories("${SOURCE_DIR}/src" "${SOURCE_DIR}/include")
set (glar_sources
)
IF (ENABLE_DRAFTS)
list (APPEND glar_sources
src/glar_node.c
src/glar_panel.c
src/glar_morse.c
)
ENDIF (ENABLE_DRAFTS)
source_group("Source Files" FILES ${glar_sources})
if (NOT DEFINED BUILD_SHARED_LIBS)
SET(BUILD_SHARED_LIBS ON)
endif()
add_library(glar ${glar_sources})
set_target_properties(glar
PROPERTIES DEFINE_SYMBOL "LIBGLAR_EXPORTS"
)
set_target_properties(glar
PROPERTIES LIBRARY_OUTPUT_DIRECTORY "${SOURCE_DIR}/src"
)
target_link_libraries(glar
${ZEROMQ_LIBRARIES} ${MORE_LIBRARIES}
)
install(TARGETS glar
LIBRARY DESTINATION "lib${LIB_SUFFIX}" # .so file
ARCHIVE DESTINATION "lib${LIB_SUFFIX}" # .lib file
RUNTIME DESTINATION bin # .dll file
)
########################################################################
# pkgconfig
########################################################################
set (VERSION "0.0.0")
set (prefix "${CMAKE_INSTALL_PREFIX}")
set (exec_prefix "\${prefix}")
set (libdir "\${prefix}/lib${LIB_SUFFIX}")
set (includedir "\${prefix}/include")
IF (ENABLE_DRAFTS)
set (pkg_config_defines "-DGLAR_BUILD_DRAFT_API=1")
ELSE (ENABLE_DRAFTS)
set (pkg_config_defines "")
ENDIF (ENABLE_DRAFTS)
configure_file(
"${SOURCE_DIR}/src/libglar.pc.in"
"${SOURCE_DIR}/src/libglar.pc"
@ONLY)
install(
FILES "${SOURCE_DIR}/src/libglar.pc"
DESTINATION "lib${LIB_SUFFIX}/pkgconfig"
)
########################################################################
# executables
########################################################################
add_executable(
glard
"${SOURCE_DIR}/src/glard.c"
)
target_link_libraries(
glard
glar
${LIBZMQ_LIBRARIES}
${CZMQ_LIBRARIES}
${ZYRE_LIBRARIES}
${OPTIONAL_LIBRARIES}
)
set_target_properties(
glard
PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${SOURCE_DIR}/src"
)
add_executable(
glar_selftest
"${SOURCE_DIR}/src/glar_selftest.c"
)
target_link_libraries(
glar_selftest
glar
${LIBZMQ_LIBRARIES}
${CZMQ_LIBRARIES}
${ZYRE_LIBRARIES}
${OPTIONAL_LIBRARIES}
)
set_target_properties(
glar_selftest
PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${SOURCE_DIR}/src"
)
########################################################################
# tests
########################################################################
set(CLASSTEST_TIMEOUT 5 CACHE STRING "Timeout of the selftest of a class")
set(TOTAL_TIMEOUT 20 CACHE STRING "Timout of the total testsuite")
set(TEST_CLASSES
)
IF (ENABLE_DRAFTS)
list (APPEND TEST_CLASSES
glar_node
glar_panel
glar_morse
)
ENDIF (ENABLE_DRAFTS)
foreach(TEST_CLASS ${TEST_CLASSES})
add_test(
NAME ${TEST_CLASS}
COMMAND glar_selftest --continue --verbose --test ${TEST_CLASS}
)
set_tests_properties(
${TEST_CLASS}
PROPERTIES TIMEOUT ${CLASSTEST_TIMEOUT}
)
endforeach(TEST_CLASS)
########################################################################
# summary
########################################################################
message (STATUS "*** Version number: ${VERSION}")
message (STATUS "*** Install target: ${CMAKE_INSTALL_PREFIX}")
################################################################################
# THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY #
# Please refer to the README for information about making permanent changes. #
################################################################################