-
-
Notifications
You must be signed in to change notification settings - Fork 42
Expand file tree
/
Copy pathCMakeLists.txt
More file actions
407 lines (372 loc) · 16.2 KB
/
Copy pathCMakeLists.txt
File metadata and controls
407 lines (372 loc) · 16.2 KB
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
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
cmake_minimum_required(VERSION 3.21)
project(sigviewer
VERSION 0.7.2
LANGUAGES CXX C
)
# -- Pinned/minimum versions of external dependencies ------------------------
# The ONLY accepted versions for the static build below (change here, then
# rebuild). Also the documented minimum for system packages via
# SIGVIEWER_SYSTEM_DEPS, which cannot enforce it automatically (see below).
set(LIBXDF_VERSION "1.0.3")
set(LIBBIOSIG_VERSION "3.9.5")
# -- Language standards ------------------------------------------------------
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_C_STANDARD 11)
set(CMAKE_C_STANDARD_REQUIRED ON)
# -- Qt ----------------------------------------------------------------------
find_package(Qt6 REQUIRED COMPONENTS Core Gui Widgets Xml Svg LinguistTools Test)
qt_standard_project_setup()
# -- zlib (gzip decompression for .xdf.gz / .xdfz) ----------------------------
find_package(ZLIB REQUIRED)
# -- libxdf / libbiosig: system packages, or pre-built from source -----------
# SIGVIEWER_SYSTEM_DEPS (default OFF) statically links the pinned versions.
# ON requires system packages instead, which fails configure if either is missing.
#
# find_package(libxdf ${LIBXDF_VERSION} CONFIG) enforces a real minimum
# version. libbiosig has no reliable version check (see cmake/FindLibBiosig.cmake);
# a system libbiosig is accepted as-is; ensure it is >= ${LIBBIOSIG_VERSION}.
option(SIGVIEWER_SYSTEM_DEPS
"Link libxdf/libbiosig dynamically against system packages instead of building pinned static libraries from source"
OFF)
list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake")
if(SIGVIEWER_SYSTEM_DEPS)
find_package(libxdf ${LIBXDF_VERSION} CONFIG REQUIRED)
find_package(LibBiosig REQUIRED)
message(STATUS "Using system libxdf and libbiosig (dynamically linked)")
add_library(dep_libxdf ALIAS XDF::xdf)
add_library(dep_libbiosig ALIAS LibBiosig::LibBiosig)
else()
# -- External pre-built dependencies -----------------------------------
# Override with -DDEPS_DIR=<path> if the libraries were built elsewhere.
set(DEPS_DIR "${CMAKE_SOURCE_DIR}/external"
CACHE PATH "Directory containing built libxdf and libbiosig")
# The versions.cmake file is written by external/build_deps.cmake and
# records the versions of the libraries that are actually present in
# DEPS_DIR.
set(_DEPS_VERSIONS_FILE "${DEPS_DIR}/versions.cmake")
if(NOT EXISTS "${_DEPS_VERSIONS_FILE}")
message(FATAL_ERROR
"Dependency version file not found:\n"
" ${_DEPS_VERSIONS_FILE}\n\n"
"Run the following command to build the required libraries:\n"
" cmake -P external/build_deps.cmake\n"
"Or manually place the libraries in\n"
"${DEPS_DIR}\n"
"and create external/versions.cmake with:\n"
" set(LIBXDF_VERSION_INSTALLED \"${LIBXDF_VERSION}\")\n"
" set(LIBBIOSIG_VERSION_INSTALLED \"${LIBBIOSIG_VERSION}\")\n\n"
"Or install libxdf/libbiosig as system packages so that "
"find_package can locate them (see SIGVIEWER_SYSTEM_DEPS above)."
)
endif()
include("${_DEPS_VERSIONS_FILE}")
foreach(_lib IN ITEMS LIBXDF LIBBIOSIG)
set(_required "${${_lib}_VERSION}")
set(_found "${${_lib}_VERSION_INSTALLED}")
if(NOT _found STREQUAL _required)
message(FATAL_ERROR
"${_lib} version mismatch.\n"
" Required : ${_required}\n"
" Installed: ${_found}\n\n"
"Run cmake -P external/build_deps.cmake to install the correct version."
)
endif()
endforeach()
unset(_lib)
unset(_required)
unset(_found)
# Create IMPORTED targets so consumers get include dirs for free via
# target_link_libraries.
add_library(dep_libxdf STATIC IMPORTED)
set_target_properties(dep_libxdf PROPERTIES
IMPORTED_LOCATION "${DEPS_DIR}/lib/libxdf.a"
INTERFACE_INCLUDE_DIRECTORIES "${DEPS_DIR}/include"
)
add_library(dep_libbiosig STATIC IMPORTED)
set_target_properties(dep_libbiosig PROPERTIES
IMPORTED_LOCATION "${DEPS_DIR}/lib/libbiosig.a"
INTERFACE_INCLUDE_DIRECTORIES "${DEPS_DIR}/include"
)
endif()
# -- Sources -----------------------------------------------------------------
qt_add_library(sigviewer_objects OBJECT
src/application_context.cpp
src/application_context.h
src/command_executer.h
src/file_context.cpp
src/file_context.h
src/tab_context.cpp
src/tab_context.h
# base
src/base/data_block.cpp
src/base/data_block.h
src/base/exception.cpp
src/base/exception.h
src/base/fixed_data_block.cpp
src/base/fixed_data_block.h
src/base/math_utils.cpp
src/base/math_utils.h
src/base/signal_channel.cpp
src/base/signal_channel.h
src/base/signal_event.cpp
src/base/signal_event.h
src/base/application_states.h
src/base/file_states.h
src/base/sigviewer_user_types.h
src/base/tab_states.h
# commands
src/commands/convert_file_command.cpp
src/commands/convert_file_command.h
src/commands/open_file_command.cpp
src/commands/open_file_command.h
# editing_commands
src/editing_commands/change_channel_undo_command.cpp
src/editing_commands/change_channel_undo_command.h
src/editing_commands/change_type_undo_command.cpp
src/editing_commands/change_type_undo_command.h
src/editing_commands/delete_event_undo_command.cpp
src/editing_commands/delete_event_undo_command.h
src/editing_commands/macro_undo_command.cpp
src/editing_commands/macro_undo_command.h
src/editing_commands/new_event_undo_command.cpp
src/editing_commands/new_event_undo_command.h
src/editing_commands/resize_event_undo_command.cpp
src/editing_commands/resize_event_undo_command.h
# file_handling
src/file_handling/basic_header.cpp
src/file_handling/basic_header.h
src/file_handling/channel_manager.cpp
src/file_handling/channel_manager.h
src/file_handling/event_manager.h
src/file_handling/file_handler_factory.h
src/file_handling/gzip_decompressor.cpp
src/file_handling/gzip_decompressor.h
src/file_handling/file_signal_reader.cpp
src/file_handling/file_signal_reader.h
src/file_handling/file_signal_reader_factory.cpp
src/file_handling/file_signal_reader_factory.h
src/file_handling/file_signal_writer.h
src/file_handling/file_signal_writer_factory.cpp
src/file_handling/file_signal_writer_factory.h
# file_handling (impl)
src/file_handling/biosig_basic_header.cpp
src/file_handling/biosig_basic_header.h
src/file_handling/biosig_reader.cpp
src/file_handling/biosig_reader.h
src/file_handling/biosig_writer.cpp
src/file_handling/biosig_writer.h
src/file_handling/channel_manager_proxy.cpp
src/file_handling/channel_manager_proxy.h
src/file_handling/detrend_channel_manager.cpp
src/file_handling/detrend_channel_manager.h
src/file_handling/file_channel_manager.cpp
src/file_handling/file_channel_manager.h
src/file_handling/event_manager.cpp
src/file_handling/event_manager.h
src/file_handling/event_table_file_reader.cpp
src/file_handling/event_table_file_reader.h
src/file_handling/evt_writer.cpp
src/file_handling/evt_writer.h
src/file_handling/file_handler_factory_registrator.h
src/file_handling/downsampling_thread.cpp
src/file_handling/downsampling_thread.h
src/file_handling/xdf_reader.cpp
src/file_handling/xdf_reader.h
# gui
src/gui/background_processes.cpp
src/gui/background_processes.h
src/gui/color_manager.cpp
src/gui/color_manager.h
src/gui/event_view.h
src/gui/gui_action_command.cpp
src/gui/gui_action_command.h
src/gui/gui_action_factory.cpp
src/gui/gui_action_factory.h
src/gui/gui_action_factory_registrator.h
src/gui/gui_helper_functions.cpp
src/gui/gui_helper_functions.h
src/gui/main_window.cpp
src/gui/main_window.h
src/gui/main_window_model.cpp
src/gui/main_window_model.h
src/gui/processed_signal_channel_manager.cpp
src/gui/processed_signal_channel_manager.h
src/gui/progress_bar.h
src/gui/select_shown_channels_dialog.cpp
src/gui/select_shown_channels_dialog.h
src/gui/signal_browser_mouse_handling.cpp
src/gui/signal_browser_mouse_handling.h
src/gui/signal_view_settings.cpp
src/gui/signal_view_settings.h
src/gui/signal_visualisation_model.cpp
src/gui/signal_visualisation_model.h
src/gui/signal_visualisation_modes.h
src/gui/signal_visualisation_view.h
src/gui/info_widgets/power_spectrum_info_widget.ui
# gui/commands
src/gui/commands/adapt_channel_view_gui_command.cpp
src/gui/commands/adapt_channel_view_gui_command.h
src/gui/commands/adapt_event_view_gui_command.cpp
src/gui/commands/adapt_event_view_gui_command.h
src/gui/commands/close_file_gui_command.cpp
src/gui/commands/close_file_gui_command.h
src/gui/commands/detrend_gui_command.cpp
src/gui/commands/detrend_gui_command.h
src/gui/commands/event_editing_gui_command.cpp
src/gui/commands/event_editing_gui_command.h
src/gui/commands/help_gui_command.cpp
src/gui/commands/help_gui_command.h
src/gui/commands/mouse_mode_gui_command.cpp
src/gui/commands/mouse_mode_gui_command.h
src/gui/commands/open_file_gui_command.cpp
src/gui/commands/open_file_gui_command.h
src/gui/commands/save_gui_command.cpp
src/gui/commands/save_gui_command.h
src/gui/commands/signal_processing_gui_command.cpp
src/gui/commands/signal_processing_gui_command.h
src/gui/commands/undo_redo_gui_command.cpp
src/gui/commands/undo_redo_gui_command.h
src/gui/commands/zoom_gui_command.cpp
src/gui/commands/zoom_gui_command.h
# gui/dialogs
src/gui/dialogs/about_dialog.ui
src/gui/dialogs/basic_header_info_dialog.cpp
src/gui/dialogs/basic_header_info_dialog.h
src/gui/dialogs/channel_dialog.ui
src/gui/dialogs/channel_selection_dialog.cpp
src/gui/dialogs/channel_selection_dialog.h
src/gui/dialogs/event_time_selection_dialog.cpp
src/gui/dialogs/event_time_selection_dialog.h
src/gui/dialogs/event_time_selection_dialog.ui
src/gui/dialogs/event_type_selection_dialog.ui
src/gui/dialogs/event_types_selection_dialog.cpp
src/gui/dialogs/event_types_selection_dialog.h
src/gui/dialogs/resampling_dialog.cpp
src/gui/dialogs/resampling_dialog.h
src/gui/dialogs/resampling_dialog.ui
src/gui/dialogs/scale_channel_dialog.cpp
src/gui/dialogs/scale_channel_dialog.h
src/gui/dialogs/scale_channel_dialog.ui
# gui/event_table
src/gui/event_table/event_table_view_model.cpp
src/gui/event_table/event_table_view_model.h
src/gui/event_table/event_table_widget.cpp
src/gui/event_table/event_table_widget.h
src/gui/event_table/event_table_widget.ui
# gui/signal_browser
src/gui/signal_browser/adapt_browser_view_widget.cpp
src/gui/signal_browser/adapt_browser_view_widget.h
src/gui/signal_browser/adapt_browser_view_widget.ui
src/gui/signal_browser/event_context_menu.cpp
src/gui/signal_browser/event_context_menu.h
src/gui/signal_browser/event_creation_widget.cpp
src/gui/signal_browser/event_creation_widget.h
src/gui/signal_browser/event_creation_widget.ui
src/gui/signal_browser/event_editing_widget.cpp
src/gui/signal_browser/event_editing_widget.h
src/gui/signal_browser/event_editing_widget.ui
src/gui/signal_browser/event_graphics_item.cpp
src/gui/signal_browser/event_graphics_item.h
src/gui/signal_browser/label_widget.cpp
src/gui/signal_browser/label_widget.h
src/gui/signal_browser/overview_widget.cpp
src/gui/signal_browser/overview_widget.h
src/gui/signal_browser/signal_browser_graphics_view.h
src/gui/signal_browser/signal_browser_model_4.cpp
src/gui/signal_browser/signal_browser_model_4.h
src/gui/signal_browser/signal_browser_view.cpp
src/gui/signal_browser/signal_browser_view.h
src/gui/signal_browser/signal_graphics_item.cpp
src/gui/signal_browser/signal_graphics_item.h
src/gui/signal_browser/signal_grid_graphics_item.cpp
src/gui/signal_browser/signal_grid_graphics_item.h
src/gui/signal_browser/x_axis_widget_4.cpp
src/gui/signal_browser/x_axis_widget_4.h
src/gui/signal_browser/y_axis_widget_4.cpp
src/gui/signal_browser/y_axis_widget_4.h
# signal_processing
src/signal_processing/FFTReal.cpp
src/signal_processing/FFTReal.h
)
qt_add_resources(SIGVIEWER_RESOURCES src/src.qrc)
target_sources(sigviewer_objects PRIVATE ${SIGVIEWER_RESOURCES})
# AUTOUIC needs to know every directory that contains a .ui file.
set_target_properties(sigviewer_objects PROPERTIES
AUTOUIC_SEARCH_PATHS
"${CMAKE_SOURCE_DIR}/src/gui/dialogs;${CMAKE_SOURCE_DIR}/src/gui/event_table;${CMAKE_SOURCE_DIR}/src/gui/signal_browser;${CMAKE_SOURCE_DIR}/src/gui/info_widgets"
)
# -- Compile definitions -----------------------------------------------------
target_compile_definitions(sigviewer_objects PUBLIC
VERSION_MAJOR=${PROJECT_VERSION_MAJOR}
VERSION_MINOR=${PROJECT_VERSION_MINOR}
VERSION_BUILD=${PROJECT_VERSION_PATCH}
$<$<NOT:$<CONFIG:Debug>>:QT_NO_DEBUG_OUTPUT>
)
# -- Include paths and link libraries ----------------------------------------
# The autogen include dir (for generated ui_*.h headers) must be propagated
# explicitly so that test targets that consume sigviewer_objects can find them.
target_include_directories(sigviewer_objects PUBLIC
src
"${CMAKE_CURRENT_BINARY_DIR}/sigviewer_objects_autogen/include"
)
# libbiosig uses libiconv on macOS/Windows and Winsock on Windows
# (ntohl/htonl/getaddrinfo); on Linux these are part of glibc, so no separate
# library is needed there. Linked unconditionally, not just for the static
# build above, since a "system" libbiosig can be static too (see
# cmake/FindLibBiosig.cmake) — linking these when unneeded is harmless.
target_link_libraries(sigviewer_objects PUBLIC
Qt6::Core
Qt6::Gui
Qt6::Widgets
Qt6::Xml
Qt6::Svg
dep_libxdf
dep_libbiosig
ZLIB::ZLIB
$<$<OR:$<PLATFORM_ID:Darwin>,$<PLATFORM_ID:Windows>>:iconv>
$<$<PLATFORM_ID:Windows>:ws2_32>
)
# -- Main application --------------------------------------------------------
qt_add_executable(sigviewer src/main.cpp)
target_link_libraries(sigviewer PRIVATE sigviewer_objects)
# -- Platform-specific sources -----------------------------------------------
if(APPLE)
target_sources(sigviewer PRIVATE src/sigviewer.icns)
set_source_files_properties(src/sigviewer.icns PROPERTIES
MACOSX_PACKAGE_LOCATION "Resources")
set_target_properties(sigviewer PROPERTIES
MACOSX_BUNDLE TRUE
MACOSX_BUNDLE_BUNDLE_NAME "SigViewer"
MACOSX_BUNDLE_BUNDLE_VERSION "${PROJECT_VERSION}"
MACOSX_BUNDLE_SHORT_VERSION_STRING "${PROJECT_VERSION}"
MACOSX_DEPLOYMENT_TARGET "11"
MACOSX_BUNDLE_ICON_FILE "sigviewer.icns"
OUTPUT_NAME "SigViewer"
)
elseif(WIN32)
target_sources(sigviewer PRIVATE src/src.rc)
set_target_properties(sigviewer PROPERTIES WIN32_EXECUTABLE TRUE)
endif()
# -- Translations ------------------------------------------------------------
qt_add_translations(sigviewer
TS_FILES
src/translations/sigviewer_de.ts
src/translations/sigviewer_en.ts
src/translations/sigviewer_ru.ts
)
# -- Tests -------------------------------------------------------------------
enable_testing()
function(add_sigviewer_test name source)
qt_add_executable(${name} ${source})
target_link_libraries(${name} PRIVATE sigviewer_objects Qt6::Test)
add_test(NAME ${name} COMMAND ${name})
set_tests_properties(${name} PROPERTIES ENVIRONMENT "QT_QPA_PLATFORM=offscreen")
endfunction()
add_sigviewer_test(test_data_block src/tests/test_data_block.cpp)
add_sigviewer_test(test_color_manager src/tests/test_color_manager.cpp)
add_sigviewer_test(test_event_manager src/tests/test_event_manager.cpp)
add_sigviewer_test(test_editing_commands src/tests/test_editing_commands.cpp)
add_sigviewer_test(test_event_table_widget src/tests/test_event_table_widget.cpp)
add_sigviewer_test(test_file_handling src/tests/test_file_handling.cpp)
add_sigviewer_test(test_gui src/tests/test_gui.cpp)