-
-
Notifications
You must be signed in to change notification settings - Fork 104
/
CMakeLists.txt
268 lines (228 loc) · 8.7 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
cmake_minimum_required(VERSION 3.25 FATAL_ERROR)
if(CMAKE_VERSION VERSION_GREATER_EQUAL 3.27)
# BOOST_ROOT handling on RPi
cmake_policy(VERSION 3.27)
elseif(CMAKE_VERSION VERSION_GREATER_EQUAL 3.26)
cmake_policy(VERSION 3.26)
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}/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()
include_directories("${OSSIA_SDK}/pipewire/include/pipewire-0.3")
include_directories("${OSSIA_SDK}/pipewire/include/spa-0.2")
endif()
project(score LANGUAGES C CXX)
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()
# set(CMAKE_SYSTEM_PREFIX_PATH "${CMAKE_SYSTEM_PREFIX_PATH}" CACHE INTERNAL "" FORCE)
# set(CMAKE_PREFIX_PATH "${CMAKE_PREFIX_PATH}" CACHE INTERNAL "" FORCE)
# QT_PREFIX: Qt5 / Qt6
list(GET QT_VERSION 0 QT_PREFIX)
set(SCORE_VERSION_MAJOR 3)
set(SCORE_VERSION_MINOR 3)
set(SCORE_VERSION_PATCH 2)
set(SCORE_VERSION_EXTRA "")
set(SCORE_CODENAME "Artachat")
set(SCORE_VERSION "${SCORE_VERSION_MAJOR}.${SCORE_VERSION_MINOR}.${SCORE_VERSION_PATCH}")
if(NOT SCORE_DYNAMIC_PLUGINS)
set(SCORE_STATIC_PLUGINS ON)
endif()
if("${CMAKE_BUILD_TYPE}" STREQUAL "")
message("No build type defined. Please set CMAKE_BUILD_TYPE to Debug, Release, RelWithDebInfo...")
endif()
include(all-plugins)
if(SCORE_DISABLED_PLUGINS)
list(REMOVE_ITEM SCORE_PLUGINS_TO_BUILD ${SCORE_DISABLED_PLUGINS})
endif()
set_property(GLOBAL PROPERTY USE_FOLDERS ON)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
set(CMAKE_UNITY_BUILD_BATCH_SIZE 5000)
if(CMAKE_VERSION VERSION_GREATER 3.19)
set(CMAKE_PCH_INSTANTIATE_TEMPLATES 1)
endif()
if(CMAKE_VERSION VERSION_GREATER_EQUAL 3.31)
if("${CMAKE_CXX_COMPILER}" MATCHES ".*ccache.*")
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 19.0)
set(CMAKE_CXX_SCAN_FOR_MODULES 0)
endif()
else()
set(CMAKE_CXX_SCAN_FOR_MODULES 0)
endif()
set(CMAKE_C_STANDARD 11)
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED 20)
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")
add_definitions(/D_SILENCE_ALL_CXX17_DEPRECATION_WARNINGS=1
/DNOMINMAX
/DWIN32_LEAN_AND_MEAN
)
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(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} -msse2 -mno-sse3 ")
set(CMAKE_OBJCXX_FLAGS "${CMAKE_OBJCXX_FLAGS} -msse2 -mno-sse3 ")
endif()
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -msse2 -mno-sse3 ")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -msse2 -mno-sse3 ")
endif()
endif()
endif()
if(MSYS OR MINGW)
find_package(ZLIB)
endif()
find_package(${QT_VERSION} REQUIRED
COMPONENTS
Core
Widgets
Gui
Network
Xml
StateMachine
OpenGL
OpenGLWidgets
Qml
ShaderTools Quick QmlModels
OPTIONAL_COMPONENTS WebSockets Svg
)
if(EMSCRIPTEN)
find_package(${QT_VERSION} REQUIRED COMPONENTS QmlIntegration)
endif()
enable_testing()
include(ScoreFunctions)
include(ScoreAvndHelper)
include(ScoreConfiguration)
include(3rdparty/3rdparty.cmake)
set(3RDPARTY_FOLDER "${CMAKE_CURRENT_SOURCE_DIR}/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")
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/")
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")
add_subdirectory(src)
include(cmake/ScoreFeatureCheck.cmake)
if(SCORE_TESTBED)
add_subdirectory(Tests/testbed)
endif()
if(EXISTS Documentation/Models/score.qmodel)
add_custom_target(Docs SOURCES Documentation/Models/score.qmodel)
endif()
if(INTEGRATION_TESTING)
file(COPY
"${CMAKE_CURRENT_SOURCE_DIR}/tests/testdata"
DESTINATION
"${CMAKE_CURRENT_BINARY_DIR}/tests/Integration/")
include_directories("${CMAKE_CURRENT_SOURCE_DIR}/tests")
file(GLOB_RECURSE TESTS_HDRS "${CMAKE_CURRENT_SOURCE_DIR}/tests/*.hpp")
add_custom_target(MocksHeaders SOURCES ${TESTS_HDRS})
setup_score_tests(tests/Integration)
endif()
include(CTest)