forked from brainflow-dev/brainflow
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
executable file
·317 lines (286 loc) · 14.3 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
cmake_minimum_required (VERSION 3.10)
project (brainflow)
set (CMAKE_CXX_STANDARD 11)
set (CMAKE_VERBOSE_MAKEFILE ON)
set (BRAINFLOW_VERSION 2.1.0)
macro (configure_msvc_runtime)
if (MSVC)
# Default to statically-linked runtime.
if ("${MSVC_RUNTIME}" STREQUAL "")
set (MSVC_RUNTIME "static")
endif ()
# Set compiler options.
set (variables
CMAKE_C_FLAGS_DEBUG
CMAKE_C_FLAGS_MINSIZEREL
CMAKE_C_FLAGS_RELEASE
CMAKE_C_FLAGS_RELWITHDEBINFO
CMAKE_CXX_FLAGS_DEBUG
CMAKE_CXX_FLAGS_MINSIZEREL
CMAKE_CXX_FLAGS_RELEASE
CMAKE_CXX_FLAGS_RELWITHDEBINFO
)
if (${MSVC_RUNTIME} STREQUAL "static")
message(STATUS
"MSVC -> forcing use of statically-linked runtime."
)
foreach (variable ${variables})
if (${variable} MATCHES "/MD")
string (REGEX REPLACE "/MD" "/MT" ${variable} "${${variable}}")
endif ()
endforeach ()
else ()
message (STATUS
"MSVC -> forcing use of dynamically-linked runtime."
)
foreach (variable ${variables})
if (${variable} MATCHES "/MT")
string (REGEX REPLACE "/MT" "/MD" ${variable} "${${variable}}")
endif ()
endforeach ()
endif ()
endif ()
endmacro ()
# link msvc runtime statically
configure_msvc_runtime ()
# add_subfolder doesnt work on linux if you need to istall packages, add it in top level file
SET (DSPFILTERS "DSPFilters")
aux_source_directory (${CMAKE_HOME_DIRECTORY}/third_party/DSPFilters/source DSPFILTERS_SOURCE_LIB)
add_library (${DSPFILTERS} STATIC ${DSPFILTERS_SOURCE_LIB})
target_include_directories (${DSPFILTERS} PUBLIC $<BUILD_INTERFACE:${CMAKE_HOME_DIRECTORY}/third_party/DSPFilters/include>)
set_property (TARGET ${DSPFILTERS} PROPERTY POSITION_INDEPENDENT_CODE ON)
# there are asserts, I wanna disable them even for debug builds
target_compile_definitions(${DSPFILTERS} PRIVATE -DNDEBUG)
SET (WAVELIB "WaveLib")
aux_source_directory (${CMAKE_HOME_DIRECTORY}/third_party/wavelib/src WAVELIB_SRC)
add_library (${WAVELIB} STATIC ${WAVELIB_SRC})
target_include_directories (${WAVELIB} PUBLIC $<BUILD_INTERFACE:${CMAKE_HOME_DIRECTORY}/third_party/wavelib/header>)
set_property (TARGET ${WAVELIB} PROPERTY POSITION_INDEPENDENT_CODE ON)
SET (GANGLION_LIB "GanglionLib")
set (GANGLION_SOURCE_LIB
${CMAKE_HOME_DIRECTORY}/src/board_controller/openbci/ganglion_bglib/callbacks.cpp
${CMAKE_HOME_DIRECTORY}/src/board_controller/openbci/ganglion_bglib/cmd_def.cpp
${CMAKE_HOME_DIRECTORY}/src/board_controller/openbci/ganglion_bglib/helpers.cpp
${CMAKE_HOME_DIRECTORY}/src/board_controller/openbci/ganglion_bglib/main.cpp
${CMAKE_HOME_DIRECTORY}/src/board_controller/openbci/ganglion_bglib/stubs.cpp
${CMAKE_HOME_DIRECTORY}/src/board_controller/openbci/ganglion_bglib/uart.cpp
)
add_library (${GANGLION_LIB} STATIC ${GANGLION_SOURCE_LIB})
target_include_directories (${GANGLION_LIB} PUBLIC
$<BUILD_INTERFACE:${CMAKE_HOME_DIRECTORY}/src/utils/inc>
$<BUILD_INTERFACE:${CMAKE_HOME_DIRECTORY}/src/board_controller/openbci/ganglion_bglib/inc>
)
set_property (TARGET ${GANGLION_LIB} PROPERTY POSITION_INDEPENDENT_CODE ON)
SET (BOARDS_JSON "brainflow_boards.json")
if (CMAKE_SIZEOF_VOID_P EQUAL 8)
MESSAGE ("64 bits compiler detected")
SET (PLATFORM_ACH "X64")
SET (BOARD_CONTROLLER_NAME "BoardController")
SET (DATA_HANDLER_NAME "DataHandler")
SET (BRAINFLOW_CPP_BINDING_NAME "Brainflow")
if(APPLE)
SET (BOARD_CONTROLLER_COMPILED_NAME "libBoardController.dylib")
SET (DATA_HANDLER_COMPILED_NAME "libDataHandler.dylib")
elseif (UNIX)
SET (BOARD_CONTROLLER_COMPILED_NAME "libBoardController.so")
SET (DATA_HANDLER_COMPILED_NAME "libDataHandler.so")
else ()
SET (BOARD_CONTROLLER_COMPILED_NAME "BoardController.dll")
SET (DATA_HANDLER_COMPILED_NAME "DataHandler.dll")
endif (APPLE)
else (CMAKE_SIZEOF_VOID_P EQUAL 8)
MESSAGE ("32 bits compiler detected")
SET (PLATFORM_ACH "X86")
SET (BOARD_CONTROLLER_NAME "BoardController32")
SET (DATA_HANDLER_NAME "DataHandler32")
SET (BRAINFLOW_CPP_BINDING_NAME "Brainflow32")
if (APPLE)
SET (BOARD_CONTROLLER_COMPILED_NAME "libBoardController32.dylib")
SET (DATA_HANDLER_COMPILED_NAME "libDataHandler32.dylib")
elseif (UNIX)
SET (BOARD_CONTROLLER_COMPILED_NAME "libBoardController32.so")
SET (DATA_HANDLER_COMPILED_NAME "libDataHandler32.so")
else ()
SET (BOARD_CONTROLLER_COMPILED_NAME "BoardController32.dll")
SET (DATA_HANDLER_COMPILED_NAME "DataHandler32.dll")
endif (APPLE)
endif (CMAKE_SIZEOF_VOID_P EQUAL 8)
set (BOARD_CONTROLLER_SRC
${CMAKE_HOME_DIRECTORY}/src/utils/timestamp.cpp
${CMAKE_HOME_DIRECTORY}/src/utils/data_buffer.cpp
${CMAKE_HOME_DIRECTORY}/src/utils/serial.cpp
${CMAKE_HOME_DIRECTORY}/src/utils/socket_client.cpp
${CMAKE_HOME_DIRECTORY}/src/utils/socket_server.cpp
${CMAKE_HOME_DIRECTORY}/src/utils/multicast_client.cpp
${CMAKE_HOME_DIRECTORY}/src/utils/multicast_server.cpp
${CMAKE_HOME_DIRECTORY}/src/board_controller/openbci/openbci_serial_board.cpp
${CMAKE_HOME_DIRECTORY}/src/board_controller/openbci/openbci_wifi_shield_board.cpp
${CMAKE_HOME_DIRECTORY}/src/board_controller/openbci/ganglion_wifi.cpp
${CMAKE_HOME_DIRECTORY}/src/board_controller/openbci/cyton_wifi.cpp
${CMAKE_HOME_DIRECTORY}/src/board_controller/openbci/cyton_daisy_wifi.cpp
${CMAKE_HOME_DIRECTORY}/src/board_controller/openbci/ganglion.cpp
${CMAKE_HOME_DIRECTORY}/src/board_controller/openbci/cyton.cpp
${CMAKE_HOME_DIRECTORY}/src/board_controller/openbci/cyton_daisy.cpp
${CMAKE_HOME_DIRECTORY}/src/board_controller/board_controller.cpp
${CMAKE_HOME_DIRECTORY}/src/board_controller/board_info_getter.cpp
${CMAKE_HOME_DIRECTORY}/src/board_controller/board.cpp
${CMAKE_HOME_DIRECTORY}/src/board_controller/streaming_board.cpp
${CMAKE_HOME_DIRECTORY}/src/board_controller/synthetic_board.cpp
${CMAKE_HOME_DIRECTORY}/src/board_controller/openbci/novaxr.cpp
${CMAKE_HOME_DIRECTORY}/src/board_controller/file_streamer.cpp
${CMAKE_HOME_DIRECTORY}/src/board_controller/multicast_streamer.cpp
)
set (DATA_HANDLER_SRC
${CMAKE_HOME_DIRECTORY}/src/data_handler/data_handler.cpp
)
add_library (
${BOARD_CONTROLLER_NAME} SHARED
${BOARD_CONTROLLER_SRC}
)
add_library (
${DATA_HANDLER_NAME} SHARED
${DATA_HANDLER_SRC}
)
target_include_directories (
${BOARD_CONTROLLER_NAME} PRIVATE
${CMAKE_HOME_DIRECTORY}/third_party/
${CMAKE_HOME_DIRECTORY}/third_party/json
${CMAKE_HOME_DIRECTORY}/third_party/http
${CMAKE_HOME_DIRECTORY}/src/utils/inc
${CMAKE_HOME_DIRECTORY}/src/board_controller/inc
${CMAKE_HOME_DIRECTORY}/src/board_controller/openbci/inc
${CMAKE_HOME_DIRECTORY}/src/board_controller/openbci/ganglion_bglib/inc
)
target_include_directories (
${DATA_HANDLER_NAME} PRIVATE
${CMAKE_HOME_DIRECTORY}/third_party/
${CMAKE_HOME_DIRECTORY}/src/utils/inc
${CMAKE_HOME_DIRECTORY}/src/board_controller/inc
${CMAKE_HOME_DIRECTORY}/src/data_handler/inc
${CMAKE_HOME_DIRECTORY}/third_party/DSPFilters/include
${CMAKE_HOME_DIRECTORY}/third_party/wavelib/header
${CMAKE_HOME_DIRECTORY}/third_party/fft/src
)
set_target_properties (${BOARD_CONTROLLER_NAME}
PROPERTIES
ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_HOME_DIRECTORY}/compiled
LIBRARY_OUTPUT_DIRECTORY ${CMAKE_HOME_DIRECTORY}/compiled
RUNTIME_OUTPUT_DIRECTORY ${CMAKE_HOME_DIRECTORY}/compiled
)
set_target_properties (${DATA_HANDLER_NAME}
PROPERTIES
ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_HOME_DIRECTORY}/compiled
LIBRARY_OUTPUT_DIRECTORY ${CMAKE_HOME_DIRECTORY}/compiled
RUNTIME_OUTPUT_DIRECTORY ${CMAKE_HOME_DIRECTORY}/compiled
)
if (UNIX)
target_link_libraries (${BOARD_CONTROLLER_NAME} ${GANGLION_LIB} pthread dl)
target_link_libraries (${DATA_HANDLER_NAME} ${DSPFILTERS} ${WAVELIB} pthread dl)
else (UNIX)
target_link_libraries (${BOARD_CONTROLLER_NAME} ${GANGLION_LIB})
target_link_libraries (${DATA_HANDLER_NAME} ${DSPFILTERS} ${WAVELIB})
endif (UNIX)
add_library (
${BRAINFLOW_CPP_BINDING_NAME} STATIC
${CMAKE_HOME_DIRECTORY}/cpp-package/src/board_shim.cpp
${CMAKE_HOME_DIRECTORY}/cpp-package/src/data_filter.cpp
)
target_include_directories (
${BRAINFLOW_CPP_BINDING_NAME} PRIVATE
${CMAKE_HOME_DIRECTORY}/src/board_controller/inc
${CMAKE_HOME_DIRECTORY}/src/data_handler/inc
${CMAKE_HOME_DIRECTORY}/cpp-package/src/inc
${CMAKE_HOME_DIRECTORY}/third_party/json
)
if (UNIX)
target_link_libraries (${BRAINFLOW_CPP_BINDING_NAME} pthread ${BOARD_CONTROLLER_NAME} ${DATA_HANDLER_NAME})
else (UNIX)
target_link_libraries (${BRAINFLOW_CPP_BINDING_NAME} ${BOARD_CONTROLLER_NAME} ${DATA_HANDLER_NAME})
endif (UNIX)
# copy
if (MSVC)
add_custom_command (TARGET ${BOARD_CONTROLLER_NAME} POST_BUILD
# copy board controller libs
COMMAND "${CMAKE_COMMAND}" -E copy_if_different "${CMAKE_HOME_DIRECTORY}/compiled/$<CONFIG>/${BOARD_CONTROLLER_COMPILED_NAME}" "${CMAKE_HOME_DIRECTORY}/python-package/brainflow/lib/${BOARD_CONTROLLER_COMPILED_NAME}"
COMMAND "${CMAKE_COMMAND}" -E copy_if_different "${CMAKE_HOME_DIRECTORY}/compiled/$<CONFIG>/${BOARD_CONTROLLER_COMPILED_NAME}" "${CMAKE_HOME_DIRECTORY}/java-package/brainflow/src/main/resources/${BOARD_CONTROLLER_COMPILED_NAME}"
COMMAND "${CMAKE_COMMAND}" -E copy_if_different "${CMAKE_HOME_DIRECTORY}/compiled/$<CONFIG>/${BOARD_CONTROLLER_COMPILED_NAME}" "${CMAKE_HOME_DIRECTORY}/csharp-package/brainflow/brainflow/lib/${BOARD_CONTROLLER_COMPILED_NAME}"
)
add_custom_command (TARGET ${DATA_HANDLER_NAME} POST_BUILD
# copy data handler libs
COMMAND "${CMAKE_COMMAND}" -E copy_if_different "${CMAKE_HOME_DIRECTORY}/compiled/$<CONFIG>/${DATA_HANDLER_COMPILED_NAME}" "${CMAKE_HOME_DIRECTORY}/python-package/brainflow/lib/${DATA_HANDLER_COMPILED_NAME}"
COMMAND "${CMAKE_COMMAND}" -E copy_if_different "${CMAKE_HOME_DIRECTORY}/compiled/$<CONFIG>/${DATA_HANDLER_COMPILED_NAME}" "${CMAKE_HOME_DIRECTORY}/java-package/brainflow/src/main/resources/${DATA_HANDLER_COMPILED_NAME}"
COMMAND "${CMAKE_COMMAND}" -E copy_if_different "${CMAKE_HOME_DIRECTORY}/compiled/$<CONFIG>/${DATA_HANDLER_COMPILED_NAME}" "${CMAKE_HOME_DIRECTORY}/csharp-package/brainflow/brainflow/lib/${DATA_HANDLER_COMPILED_NAME}"
)
endif (MSVC)
if (UNIX)
add_custom_command (TARGET ${BOARD_CONTROLLER_NAME} POST_BUILD
# copy board controller libs
COMMAND "${CMAKE_COMMAND}" -E copy_if_different "${CMAKE_HOME_DIRECTORY}/compiled/${BOARD_CONTROLLER_COMPILED_NAME}" "${CMAKE_HOME_DIRECTORY}/python-package/brainflow/lib/${BOARD_CONTROLLER_COMPILED_NAME}"
COMMAND "${CMAKE_COMMAND}" -E copy_if_different "${CMAKE_HOME_DIRECTORY}/compiled/${BOARD_CONTROLLER_COMPILED_NAME}" "${CMAKE_HOME_DIRECTORY}/java-package/brainflow/src/main/resources/${BOARD_CONTROLLER_COMPILED_NAME}"
COMMAND "${CMAKE_COMMAND}" -E copy_if_different "${CMAKE_HOME_DIRECTORY}/compiled/${BOARD_CONTROLLER_COMPILED_NAME}" "${CMAKE_HOME_DIRECTORY}/csharp-package/brainflow/brainflow/${BOARD_CONTROLLER_COMPILED_NAME}"
)
add_custom_command (TARGET ${DATA_HANDLER_NAME} POST_BUILD
# copy data handler libs
COMMAND "${CMAKE_COMMAND}" -E copy_if_different "${CMAKE_HOME_DIRECTORY}/compiled/${DATA_HANDLER_COMPILED_NAME}" "${CMAKE_HOME_DIRECTORY}/python-package/brainflow/lib/${DATA_HANDLER_COMPILED_NAME}"
COMMAND "${CMAKE_COMMAND}" -E copy_if_different "${CMAKE_HOME_DIRECTORY}/compiled/${DATA_HANDLER_COMPILED_NAME}" "${CMAKE_HOME_DIRECTORY}/java-package/brainflow/src/main/resources/${DATA_HANDLER_COMPILED_NAME}"
COMMAND "${CMAKE_COMMAND}" -E copy_if_different "${CMAKE_HOME_DIRECTORY}/compiled/${DATA_HANDLER_COMPILED_NAME}" "${CMAKE_HOME_DIRECTORY}/csharp-package/brainflow/brainflow/${DATA_HANDLER_COMPILED_NAME}"
)
endif (UNIX)
# need to copy json file to bindings
add_custom_command (TARGET ${BOARD_CONTROLLER_NAME} POST_BUILD
COMMAND "${CMAKE_COMMAND}" -E copy_if_different "${CMAKE_HOME_DIRECTORY}/${BOARDS_JSON}" "${CMAKE_HOME_DIRECTORY}/python-package/brainflow/lib/${BOARDS_JSON}"
COMMAND "${CMAKE_COMMAND}" -E copy_if_different "${CMAKE_HOME_DIRECTORY}/${BOARDS_JSON}" "${CMAKE_HOME_DIRECTORY}/java-package/brainflow/src/main/resources/${BOARDS_JSON}"
COMMAND "${CMAKE_COMMAND}" -E copy_if_different "${CMAKE_HOME_DIRECTORY}/${BOARDS_JSON}" "${CMAKE_HOME_DIRECTORY}/csharp-package/brainflow/brainflow/lib/${BOARDS_JSON}"
)
# install
set (VERSION_CONFIG ${CMAKE_HOME_DIRECTORY}/compiled/brainflowConfigVersion.cmake)
set (CONFIG_INSTALL_DIR lib/cmake/brainflow)
set (PROJECT_CONFIG ${CMAKE_HOME_DIRECTORY}/compiled/brainflowConfig.cmake)
set (TARGETS_EXPORT_NAME brainflowTargets)
set (PACKAGE_LIB_INSTALL_DIR ${CMAKE_INSTALL_PREFIX}/lib)
set (PACKAGE_INC_INSTALL_DIR ${CMAKE_INSTALL_PREFIX}/inc)
include (CMakePackageConfigHelpers)
write_basic_package_version_file (
${VERSION_CONFIG}
VERSION ${BRAINFLOW_VERSION}
COMPATIBILITY AnyNewerVersion
)
configure_package_config_file (
cmake/Config.cmake.in
${PROJECT_CONFIG}
INSTALL_DESTINATION ${CONFIG_INSTALL_DIR}
)
install (
FILES
${CMAKE_HOME_DIRECTORY}/src/board_controller/inc/board_controller.h
${CMAKE_HOME_DIRECTORY}/src/board_controller/inc/brainflow_constants.h
${CMAKE_HOME_DIRECTORY}/src/board_controller/inc/board_info_getter.h
${CMAKE_HOME_DIRECTORY}/src/data_handler/inc/data_handler.h
${CMAKE_HOME_DIRECTORY}/cpp-package/src/inc/data_filter.h
${CMAKE_HOME_DIRECTORY}/cpp-package/src/inc/board_shim.h
${CMAKE_HOME_DIRECTORY}/cpp-package/src/inc/brainflow_exception.h
DESTINATION inc
)
# need to put this file with libraries
install (
FILES
${BOARDS_JSON}
DESTINATION lib
)
install (
TARGETS ${BOARD_CONTROLLER_NAME} ${DATA_HANDLER_NAME} ${DSPFILTERS} ${WAVELIB} ${GANGLION_LIB} ${BRAINFLOW_CPP_BINDING_NAME}
EXPORT ${TARGETS_EXPORT_NAME}
RUNTIME DESTINATION lib
LIBRARY DESTINATION lib
INCLUDES DESTINATION inc
ARCHIVE DESTINATION lib
)
install (
FILES ${PROJECT_CONFIG} ${VERSION_CONFIG}
DESTINATION ${CONFIG_INSTALL_DIR}
)
install (
EXPORT ${TARGETS_EXPORT_NAME}
NAMESPACE brainflow::
DESTINATION ${CONFIG_INSTALL_DIR}
)