-
-
Notifications
You must be signed in to change notification settings - Fork 129
Expand file tree
/
Copy pathCMakeLists.txt
More file actions
432 lines (371 loc) · 15 KB
/
Copy pathCMakeLists.txt
File metadata and controls
432 lines (371 loc) · 15 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
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
cmake_minimum_required(VERSION 3.25...4.2 FATAL_ERROR)
if(POLICY CMP0177)
cmake_policy(SET CMP0177 NEW)
endif()
if(POLICY CMP0167)
cmake_policy(SET CMP0167 OLD)
endif()
set(CMAKE_MODULE_PATH
"${CMAKE_MODULE_PATH}"
"${CMAKE_CURRENT_SOURCE_DIR}/cmake"
"${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules"
"${CMAKE_CURRENT_SOURCE_DIR}/cmake/Configurations"
"${CMAKE_CURRENT_SOURCE_DIR}/3rdparty/libossia/cmake"
"${CMAKE_CURRENT_SOURCE_DIR}/3rdparty/libossia/cmake/cmake-modules")
list(APPEND CMAKE_PREFIX_PATH "${CMAKE_MODULE_PATH}")
if(OSSIA_SDK)
if(UNIX AND NOT APPLE)
set_property(GLOBAL PROPERTY FIND_LIBRARY_USE_LIB64_PATHS TRUE)
endif()
set(CMAKE_PREFIX_PATH
"${OSSIA_SDK}"
"${OSSIA_SDK}/SDL2"
"${OSSIA_SDK}/qt6-static-debug"
"${OSSIA_SDK}/qt6-static"
"${OSSIA_SDK}/llvm"
"${OSSIA_SDK}/llvm-libs"
"${OSSIA_SDK}/fftw"
"${OSSIA_SDK}/zlib"
"${OSSIA_SDK}/faust"
"${OSSIA_SDK}/openssl"
"${OSSIA_SDK}/freetype"
"${OSSIA_SDK}/harfbuzz"
"${OSSIA_SDK}/ysfx"
"${OSSIA_SDK}/pipewire"
"${OSSIA_SDK}/portaudio"
"${OSSIA_SDK}/portaudio/lib"
"${OSSIA_SDK}/portaudio/lib/cmake"
"${OSSIA_SDK}/sysroot"
"${OSSIA_SDK}/sysroot/lib"
"${OSSIA_SDK}/sysroot/lib/cmake"
"${OSSIA_SDK}/sysroot/lib/cmake/freetype"
"${OSSIA_SDK}/sysroot/lib/cmake/harfbuzz"
"${OSSIA_SDK}/sysroot/lib/cmake/liblzma"
"${OSSIA_SDK}/sysroot/lib/cmake/Snappy"
"${OSSIA_SDK}/sysroot/lib/cmake/zstd"
"${OSSIA_SDK}/SDL2/lib64"
"${OSSIA_SDK}/SDL2/lib64/cmake/SDL2"
"${OSSIA_SDK}/qt6-static-debug/lib64"
"${OSSIA_SDK}/qt6-static/lib64"
"${OSSIA_SDK}/llvm-libs/lib64"
"${OSSIA_SDK}/fftw/lib64"
"${OSSIA_SDK}/zlib/lib64"
"${OSSIA_SDK}/faust/lib64"
"${OSSIA_SDK}/openssl/lib64"
"${OSSIA_SDK}/freetype/lib64"
"${OSSIA_SDK}/harfbuzz/lib64"
"${OSSIA_SDK}/ysfx/lib64"
"${OSSIA_SDK}/portaudio/lib64"
"${OSSIA_SDK}/portaudio/lib64/cmake"
"${CMAKE_PREFIX_PATH}")
set(ENV{PKG_CONFIG_PATH} "$ENV{PKG_CONFIG_PATH}:${OSSIA_SDK}/sysroot/lib/pkgconfig")
if(EXISTS "${OSSIA_SDK}/ffmpeg/lib64/pkgconfig")
set(ENV{PKG_CONFIG_PATH} "$ENV{PKG_CONFIG_PATH}:${OSSIA_SDK}/ffmpeg/lib64/pkgconfig")
else()
set(ENV{PKG_CONFIG_PATH} "$ENV{PKG_CONFIG_PATH}:${OSSIA_SDK}/ffmpeg/lib/pkgconfig")
endif()
if(EXISTS "${OSSIA_SDK}/pipewire/include/pipewire-0.3")
include_directories("${OSSIA_SDK}/pipewire/include/pipewire-0.3")
include_directories("${OSSIA_SDK}/pipewire/include/spa-0.2")
endif()
endif()
project(score LANGUAGES C CXX)
include("${CMAKE_CURRENT_SOURCE_DIR}/cmake/ScoreCodeviewWindows.cmake")
if(APPLE)
enable_language(OBJC)
enable_language(OBJCXX)
endif()
set(QT_VERSION Qt6 6.2)
if(SCORE_MACOS_ONLY_SYSTEM_LIBARIES)
set(CMAKE_IGNORE_PATH "/opt/homebrew;/usr/local;/usr/X11R6;/usr/pkg;/sw;/opt/local")
set(CMAKE_SYSTEM_IGNORE_PATH "/opt/homebrew;/usr/local;/usr/X11R6;/usr/pkg;/sw;/opt/local")
set(CMAKE_IGNORE_PREFIX_PATH "/opt/homebrew;/usr/local;/usr/X11R6;/usr/pkg;/sw;/opt/local")
set(CMAKE_SYSTEM_IGNORE_PREFIX_PATH "/opt/homebrew;/usr/local;/usr/X11R6;/usr/pkg;/sw;/opt/local")
foreach(xpath "/opt/homebrew;/usr/local;/usr/X11R6;/usr/pkg;/opt;/sw;/opt/local;/")
list(REMOVE_ITEM CMAKE_SYSTEM_PREFIX_PATH ${xpath})
list(REMOVE_ITEM CMAKE_PREFIX_PATH ${xpath})
endforeach()
foreach(xpath ${CMAKE_SYSTEM_PREFIX_PATH})
if("${xpath}" MATCHES ".*homebrew.*")
list(REMOVE_ITEM CMAKE_SYSTEM_PREFIX_PATH ${xpath})
list(REMOVE_ITEM CMAKE_PREFIX_PATH ${xpath})
endif()
endforeach()
endif()
# QT_PREFIX: Qt5 / Qt6
list(GET QT_VERSION 0 QT_PREFIX)
set(SCORE_VERSION_MAJOR 3)
set(SCORE_VERSION_MINOR 8)
set(SCORE_VERSION_PATCH 2)
set(SCORE_VERSION_EXTRA "")
set(SCORE_CODENAME "Barcelona")
set(SCORE_VERSION "${SCORE_VERSION_MAJOR}.${SCORE_VERSION_MINOR}.${SCORE_VERSION_PATCH}")
if(NOT SCORE_DYNAMIC_PLUGINS)
set(SCORE_STATIC_PLUGINS ON)
endif()
# Unified switch for the score test suite (unit + integration + testbeds).
# Decoupled from deployment builds on purpose: tests are meant to be run from a
# normal developer (ideally dynamic-plugin) build, e.g. `cninja testing`.
option(SCORE_TESTING "Build the score test suite (unit, integration, testbeds)" OFF)
get_property(is_multi_config GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG)
if(NOT "${is_multi_config}")
if("${CMAKE_BUILD_TYPE}" STREQUAL "")
message("No build type defined. Please set CMAKE_BUILD_TYPE to Debug, Release, RelWithDebInfo...")
endif()
endif()
include(all-plugins)
if(SCORE_DISABLE_PLUGINS)
set(SCORE_DISABLED_PLUGINS "${SCORE_DISABLE_PLUGINS}")
endif()
if(SCORE_DISABLED_PLUGINS)
# handle complicated CI situations with unclear amount of quoting: we pass , instead of ;
string(REPLACE "," ";" SCORE_DISABLED_PLUGINS "${SCORE_DISABLED_PLUGINS}")
list(REMOVE_ITEM SCORE_PLUGINS_TO_BUILD ${SCORE_DISABLED_PLUGINS})
endif()
if(SCORE_ENABLE_ADDONS)
set(SCORE_ENABLED_ADDONS "${SCORE_ENABLE_ADDONS}")
endif()
if(SCORE_ENABLED_ADDONS)
string(REPLACE "," ";" SCORE_ENABLED_ADDONS "${SCORE_ENABLED_ADDONS}")
endif()
set_property(GLOBAL PROPERTY USE_FOLDERS ON)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
set(CMAKE_UNITY_BUILD_BATCH_SIZE 5000)
# Relinking a shared library does not change how anything links against it, so
# do not make dependents wait on the file: touching score_lib_base otherwise
# relinks every plugin and every test behind it. The trade-off is that removing
# an exported symbol is no longer caught at build time, only at load time.
option(SCORE_RELINK_ON_SHARED_LIB
"Relink a target when a shared library it links moves" OFF)
if(NOT SCORE_RELINK_ON_SHARED_LIB)
set(CMAKE_LINK_DEPENDS_NO_SHARED ON)
endif()
if(CMAKE_VERSION VERSION_GREATER 3.19)
set(CMAKE_PCH_INSTANTIATE_TEMPLATES 1)
endif()
if(CMAKE_VERSION VERSION_GREATER_EQUAL 4.5)
if("${CMAKE_CXX_COMPILER}" MATCHES ".*ccache.*")
set(CMAKE_CXX_SCAN_FOR_MODULES 0)
endif()
if(WIN32)
# https://gitlab.kitware.com/cmake/cmake/-/issues/26662
set(CMAKE_CXX_SCAN_FOR_MODULES 0)
endif()
if(NOT (CMAKE_CXX_COMPILER_ID STREQUAL "Clang"))
set(CMAKE_CXX_SCAN_FOR_MODULES 0)
endif()
if(NOT CMAKE_CXX_COMPILER_VERSION)
set(CMAKE_CXX_SCAN_FOR_MODULES 0)
endif()
if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS 21.0)
set(CMAKE_CXX_SCAN_FOR_MODULES 0)
endif()
else()
set(CMAKE_CXX_SCAN_FOR_MODULES 0)
endif()
set(CMAKE_CXX_SCAN_FOR_MODULES 0)
set(CMAKE_C_STANDARD 17)
set(CMAKE_CXX_STANDARD 23)
set(CMAKE_CXX_STANDARD_REQUIRED 23)
if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
if(CMAKE_CXX_COMPILER_FRONTEND_VARIANT STREQUAL "MSVC")
set(MSVC 1)
endif()
endif()
if(MSVC)
if(NOT OSSIA_SDK)
message(FATAL_ERROR "
For building on MSVC, it is required to extract:
https://github.com/ossia/sdk/releases/download/sdk18/sdk-msvc-release.zip
in c:\\score-sdk-msvc and pass -DOSSIA_SDK=c:\\score-sdk-msvc to CMake.
For Debug builds, use score-msvc-debug.zip and extract it to c:\\score-sdk-msvc-debug.
Note that the builds made through MSYS2 using clang are better as more feature are supported
and clang optimizes more than MSVC.
")
endif()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /EHsc /MP /std:c++latest /Zc:__cplusplus /Zc:preprocessor /permissive- /volatile:iso")
# NOMINMAX and WIN32_LEAN_AND_MEAN are set for every Windows compiler in
# ScoreConfiguration, not only for this one.
add_definitions(/D_SILENCE_ALL_CXX17_DEPRECATION_WARNINGS=1)
elseif(APPLE AND SCORE_PCH)
set(CMAKE_OBJC_FLAGS "${CMAKE_OBJC_FLAGS} -faligned-allocation ")
set(CMAKE_OBJCXX_FLAGS "${CMAKE_OBJCXX_FLAGS} -faligned-allocation ")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -faligned-allocation ")
endif()
if(SCORE_PCH)
if(EMSCRIPTEN)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -msse2 -mno-sse3 ")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -msse2 -mno-sse3 ")
elseif(NOT MSVC)
# Needed due to kfrlib injecting these flags:
# error: current translation unit is compiled with the target feature '+sse2' but the AST file was not
# error: current translation unit is compiled with the target feature '-sse3' but the AST file was not
if(CMAKE_SYSTEM_PROCESSOR MATCHES x86)
if(APPLE)
set(CMAKE_OBJC_FLAGS "${CMAKE_OBJC_FLAGS} -msse4.1 ")
set(CMAKE_OBJCXX_FLAGS "${CMAKE_OBJCXX_FLAGS} -msse4.1 ")
endif()
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -msse4.1 ")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -msse4.1 ")
endif()
endif()
endif()
if(MSYS OR MINGW)
find_package(ZLIB)
endif()
set(QT_NO_PRIVATE_MODULE_WARNING ON)
find_package(${QT_VERSION} REQUIRED
COMPONENTS
Core
Widgets
Gui
Network
Xml
StateMachine
OpenGL
OpenGLWidgets
Qml
ShaderTools Quick QmlModels
OPTIONAL_COMPONENTS
CanvasPainter
Canvas2DPrivate
WebSockets
WebView
Svg
CorePrivate
GuiPrivate
NetworkAuth
QmlPrivate
QuickPrivate
Quick3D
Quick3DAssetImport
Quick3DAssetUtils
Quick3DEffects
Quick3DGlslParser
Quick3DHelpers
Quick3DIblBaker
Quick3DParticleEffects
Quick3DParticles
Quick3DRuntimeRender
Quick3DUtils
Quick3DXr
ShaderToolsPrivate
WidgetsPrivate
)
if(EMSCRIPTEN)
find_package(${QT_VERSION} REQUIRED COMPONENTS QmlIntegration)
endif()
if(UNIX AND NOT APPLE AND NOT WIN32 AND NOT EMSCRIPTEN)
find_package(X11 QUIET)
endif()
enable_testing()
set(SCORE_LIBRARIES_LIST CACHE INTERNAL "List of libraries")
set(SCORE_PLUGINS_LIST CACHE INTERNAL "List of plugins")
set(SCORE_FEATURES_LIST CACHE INTERNAL "List of features")
unset(SCORE_BUNDLEUTILITIES_DIRS_LIST CACHE)
unset(SCORE_BUNDLEUTILITIES_LIB_LIST CACHE)
unset(SCORE_BUNDLEUTILITIES_PLUGIN_LIST CACHE)
set(SCORE_BUNDLEUTILITIES_DIRS_LIST CACHE INTERNAL "List of .dylibs paths to add to macOS bundle")
set(SCORE_BUNDLEUTILITIES_LIB_LIST CACHE INTERNAL "List of .dylibs to add to macOS bundle")
set(SCORE_BUNDLEUTILITIES_PLUGIN_LIST CACHE INTERNAL "List of plugins to add to macOS bundle")
include(ScoreFunctions)
include(ScoreAvndHelper)
include(ScoreConfiguration)
set(3RDPARTY_FOLDER "${CMAKE_CURRENT_SOURCE_DIR}/3rdparty/")
set(OSSIA_3RDPARTY_FOLDER "${CMAKE_CURRENT_SOURCE_DIR}/3rdparty/libossia/3rdparty/")
set(SCORE_ROOT_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}")
set(SCORE_ROOT_BINARY_DIR "${CMAKE_CURRENT_BINARY_DIR}")
set(SCORE_AVND_SOURCE_DIR "${SCORE_ROOT_SOURCE_DIR}/src/plugins/score-plugin-avnd")
set(SCORE_SRC "${CMAKE_CURRENT_SOURCE_DIR}/src")
# BOOST_ASIO_ENABLE_BUFFER_DEBUGGING changes the layout of asio's internal
# types, so every translation unit in a binary must agree on it. libossia sets
# it on its own target in Debug; score is what links libossia together with the
# other asio users (e.g. the vendored liblsl), so score is where it has to be
# made uniform. Same condition as libossia's: on Windows boost defines it
# itself and redefining it warns.
#
# Both branches name a macro on purpose. Qt before 6.6 copies the directory's
# COMPILE_DEFINITIONS into moc's parameter file as one "-D<def>" line each, so
# a definition that evaluates to nothing leaves a bare "-D" there; moc then
# takes the line after it -- the "-o" -- as that option's value and reports the
# output path as a second input file.
if(NOT WIN32)
add_compile_definitions(
$<IF:$<CONFIG:Debug>,BOOST_ASIO_ENABLE_BUFFER_DEBUGGING,OSSIA_ASIO_BUFFER_DEBUGGING_UNSET>)
endif()
include(3rdparty/3rdparty.cmake)
include_directories("${SCORE_ROOT_BINARY_DIR}")
include_directories(SYSTEM "${OSSIA_3RDPARTY_FOLDER}/nano-signal-slot")
include_directories(SYSTEM "${OSSIA_3RDPARTY_FOLDER}/readerwriterqueue")
include_directories(SYSTEM "${3RDPARTY_FOLDER}/magicitems/include/")
include_directories(SYSTEM "${3RDPARTY_FOLDER}/avendish/include/")
# Make the test helpers (score_add_test, Catch2) available to plugin
# CMakeLists so per-plugin tests can be declared in place during add_subdirectory(src).
if(SCORE_TESTING)
include(ScoreTests)
score_setup_catch2()
endif()
add_subdirectory(src)
# Static builds: complete application-based tester links with the full plugin
# list after add_subdirectory(src) has populated SCORE_PLUGINS_LIST.
if(SCORE_TESTING)
score_link_plugins_for_static(EncoderTester)
score_link_plugins_for_static(ReadbackTester)
endif()
include(cmake/ScoreFeatureCheck.cmake)
if(EXISTS Documentation/Models/score.qmodel)
add_custom_target(Docs SOURCES Documentation/Models/score.qmodel)
endif()
# Unified test suite. Replaces the old INTEGRATION_TESTING / SCORE_TESTBED flags.
if(SCORE_TESTING)
include(ScoreTests)
add_subdirectory(tests)
# Deliberately here and not in tests/CMakeLists.txt: this compares what the
# test tree registers against what it contains, and a rework of that tree
# must not be able to delete its own guard along with the registrations.
include(ScoreTestRegistrationGuard)
score_check_test_registration()
# Same placement rationale: CI compiles the tests against Qt 6.4.2 while the
# reference build here is 6.13, and two tests have already shipped using an
# API newer than that. See the header of the file for the two shapes it knows.
include(ScoreRhiPortabilityGuard)
score_check_rhi_portability()
# Same placement rationale again: this compares the expected-red inventory
# against the tree. Four conventions coexist for "this test is red on
# purpose", and a run that sees only some of them reports failures nobody can
# sort into known and new.
include(ScoreExpectedRedGuard)
score_check_expected_red()
# score_add_test() above already carries UBSAN_OPTIONS. tests/integration
# registers nine more with a raw add_test() (the live-edit, gfx-soak and
# golden-render harnesses), and vendored trees register their own. Walk every
# directory and give them all the same environment.
# set_property(TEST ... DIRECTORY ...)
# needs CMake 3.28; below that the score_add_test tests are still covered.
if(SCORE_UBSAN_OPTIONS AND CMAKE_VERSION VERSION_GREATER_EQUAL 3.28)
function(score_apply_ubsan_test_env dir)
get_property(_tests DIRECTORY "${dir}" PROPERTY TESTS)
foreach(_test IN LISTS _tests)
# score_add_test() already set this on the tests it registered; appending
# a second identical entry is harmless today but would double any future
# non-idempotent edit here, so only add it where it is missing.
get_property(_env TEST "${_test}" DIRECTORY "${dir}"
PROPERTY ENVIRONMENT_MODIFICATION)
if(NOT "${_env}" MATCHES "UBSAN_OPTIONS=")
set_property(TEST "${_test}" DIRECTORY "${dir}" APPEND PROPERTY
ENVIRONMENT_MODIFICATION "UBSAN_OPTIONS=set:${SCORE_UBSAN_OPTIONS}")
endif()
endforeach()
get_property(_subdirs DIRECTORY "${dir}" PROPERTY SUBDIRECTORIES)
foreach(_subdir IN LISTS _subdirs)
score_apply_ubsan_test_env("${_subdir}")
endforeach()
endfunction()
score_apply_ubsan_test_env("${CMAKE_CURRENT_SOURCE_DIR}")
endif()
endif()
# Backwards-compatible aliases for the legacy flags (kept temporarily).
if(INTEGRATION_TESTING AND NOT SCORE_TESTING)
message(WARNING "INTEGRATION_TESTING is deprecated; configure with -DSCORE_TESTING=ON instead.")
endif()
include(CTest)