-
Notifications
You must be signed in to change notification settings - Fork 47
/
CMakeLists.txt
190 lines (163 loc) · 5.52 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
cmake_minimum_required(VERSION 3.12)
#set(CMAKE_OSX_DEPLOYMENT_TARGET "10.15" CACHE STRING "Minimum MacOS deployment version")
project(LabRecorder
DESCRIPTION "Record and write LabStreamingLayer streams to an XDF file"
HOMEPAGE_URL "https://github.com/labstreaminglayer/App-LabRecorder/"
LANGUAGES C CXX
VERSION 1.16.4)
# Needed for customized MacOSXBundleInfo.plist.in
SET(CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/cmake" ${CMAKE_MODULE_PATH})
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED On)
option(BUILD_GUI "Build the GUI, set to off for CLI only build" ON)
set(CMAKE_XCODE_ATTRIBUTE_CODE_SIGNING_REQUIRED "NO")
set(CMAKE_XCODE_ATTRIBUTE_CODE_SIGN_IDENTITY "")
# Dependencies
## LSL
if(ANDROID)
set(LIBLSL_SOURCE_PATH "../../LSL/liblsl" CACHE STRING "Path to liblsl sources")
# force include liblsl as target to build with the android toolchain
# as path of the normal build process
add_subdirectory(${LIBLSL_SOURCE_PATH} liblsl_bin)
add_library(LSL::lsl ALIAS lsl)
else()
find_package(LSL REQUIRED
HINTS ${LSL_INSTALL_ROOT}
"${CMAKE_CURRENT_LIST_DIR}/../../LSL/liblsl/build/"
"${CMAKE_CURRENT_LIST_DIR}/../../LSL/liblsl/build/install"
"${CMAKE_CURRENT_LIST_DIR}/../../LSL/liblsl/out/build/x64-Release"
"${CMAKE_CURRENT_LIST_DIR}/../../LSL/liblsl/out/install/x64-Release"
PATH_SUFFIXES share/LSL
)
endif()
if (BUILD_GUI)
## Qt
set(CMAKE_AUTOMOC ON) # The later version of this in LSLCMake is somehow not enough.
set(CMAKE_AUTORCC ON)
set(CMAKE_AUTOUIC ON)
find_package(QT NAMES Qt6 Qt5 REQUIRED COMPONENTS Core)
find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Core Widgets Network DBus)
endif(BUILD_GUI)
## Threads
find_package(Threads REQUIRED)
# Targets
## xdfwriter - stand alone library
add_subdirectory(xdfwriter)
if (BUILD_GUI)
add_executable(${PROJECT_NAME} MACOSX_BUNDLE)
target_sources(${PROJECT_NAME} PRIVATE
src/main.cpp
src/mainwindow.cpp
src/mainwindow.h
src/mainwindow.ui
src/recording.h
src/recording.cpp
src/tcpinterface.h
src/tcpinterface.cpp
)
target_link_libraries(${PROJECT_NAME}
PRIVATE
xdfwriter
Qt${QT_VERSION_MAJOR}::Core
Qt${QT_VERSION_MAJOR}::Widgets
Qt${QT_VERSION_MAJOR}::Network
Qt${QT_VERSION_MAJOR}::DBus
Threads::Threads
LSL::lsl
)
endif(BUILD_GUI)
add_executable(LabRecorderCLI MACOSX_BUNDLE
src/clirecorder.cpp
src/recording.h
src/recording.cpp
)
target_link_libraries(LabRecorderCLI
PRIVATE
xdfwriter
Threads::Threads
LSL::lsl
)
installLSLApp(xdfwriter)
installLSLApp(testxdfwriter)
installLSLApp(LabRecorderCLI)
if (BUILD_GUI)
installLSLApp(${PROJECT_NAME})
installLSLAuxFiles(${PROJECT_NAME}
${PROJECT_NAME}.cfg
LICENSE
README.md
)
else()
installLSLAuxFiles(LabRecorderCLI
${PROJECT_NAME}.cfg
LICENSE
README.md
)
endif(BUILD_GUI)
if (WIN32)
if(BUILD_GUI)
get_target_property(QT_QMAKE_EXECUTABLE Qt::qmake IMPORTED_LOCATION)
get_filename_component(QT_WINDEPLOYQT_EXECUTABLE ${QT_QMAKE_EXECUTABLE} PATH)
set(QT_WINDEPLOYQT_EXECUTABLE "${QT_WINDEPLOYQT_EXECUTABLE}/windeployqt.exe")
add_custom_command(
TARGET ${PROJECT_NAME} POST_BUILD
COMMAND ${QT_WINDEPLOYQT_EXECUTABLE}
--no-translations --no-system-d3d-compiler
--qmldir ${CMAKE_CURRENT_SOURCE_DIR}
$<TARGET_FILE_DIR:${PROJECT_NAME}>)
add_custom_command(TARGET ${PROJECT_NAME} POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_if_different
$<TARGET_FILE:LSL::lsl>
$<TARGET_FILE:xdfwriter>
$<TARGET_FILE_DIR:${PROJECT_NAME}>)
else()
add_custom_command(TARGET LabRecorderCLI POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_if_different
$<TARGET_FILE:LSL::lsl>
$<TARGET_FILE:xdfwriter>
$<TARGET_FILE_DIR:LabRecorderCLI>)
endif(BUILD_GUI)
endif()
if (BUILD_GUI)
add_custom_command(
TARGET ${PROJECT_NAME} POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy
${CMAKE_CURRENT_SOURCE_DIR}//${PROJECT_NAME}.cfg
$<TARGET_FILE_DIR:${PROJECT_NAME}>)
else()
add_custom_command(
TARGET LabRecorderCLI POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy
${CMAKE_CURRENT_SOURCE_DIR}//${PROJECT_NAME}.cfg
$<TARGET_FILE_DIR:LabRecorderCLI>)
endif(BUILD_GUI)
if(Qt6_FOUND AND BUILD_GUI)
set_target_properties(${PROJECT_NAME} PROPERTIES
QT_ANDROID_EXTRA_LIBS "${CMAKE_CURRENT_BINARY_DIR}/liblsl_bin/liblsl.so")
qt_finalize_executable(${PROJECT_NAME})
endif(Qt6_FOUND AND BUILD_GUI)
set(CPACK_DEBIAN_LABRECORDER_PACKAGE_SECTION "science" CACHE INTERNAL "")
LSLGenerateCPackConfig()
if(APPLE AND NOT DEFINED ENV{GITHUB_ACTIONS})
# Qt6 QtNetwork depends on libbrotidec which depends on libbroticommon but whose search path uses @loader_path.
# Unfortunately, macdeployqt does not seem to traverse @loader_path dependencies.
# So we are forced to call `fixup_bundle`. For now, we only do this if homebrew is present
# because that seems to be where the bad dependency is coming from.
# Note that fixup_bundle also destroys the codesigning so we have to redo that.
# TODO: Checkout supercollider apple-specific stuff, e.g.: https://github.com/supercollider/supercollider/blob/develop/CMakeLists.txt#L260-L262
execute_process(
COMMAND brew --prefix
RESULT_VARIABLE BREW_LIB
OUTPUT_VARIABLE BREW_PREFIX
OUTPUT_STRIP_TRAILING_WHITESPACE
)
if (BREW_LIB EQUAL 0 AND EXISTS "${BREW_PREFIX}")
install(CODE
"
include(BundleUtilities)
fixup_bundle(\"${CMAKE_INSTALL_PREFIX}/${PROJECT_NAME}/${PROJECT_NAME}.app\" \"\" \"${BREW_PREFIX}/lib\")
execute_process(COMMAND codesign --force --deep --sign - ${CMAKE_INSTALL_PREFIX}/${PROJECT_NAME}/${PROJECT_NAME}.app)
"
)
endif()
endif(APPLE AND NOT DEFINED ENV{GITHUB_ACTIONS})