-
Notifications
You must be signed in to change notification settings - Fork 7
/
CMakeLists.txt
300 lines (261 loc) · 9.34 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
cmake_minimum_required(VERSION 3.10)
set(CMAKE_OSX_DEPLOYMENT_TARGET 10.11 CACHE STRING "Build for 10.11")
project(surge-fx VERSION 0.9.0 LANGUAGES CXX)
add_subdirectory(deps/JUCE)
execute_process(
COMMAND git rev-parse --abbrev-ref HEAD
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
OUTPUT_VARIABLE GIT_BRANCH
OUTPUT_STRIP_TRAILING_WHITESPACE
)
# Get the latest abbreviated commit hash of the working branch
execute_process(
COMMAND git log -1 --format=%h
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
OUTPUT_VARIABLE GIT_COMMIT_HASH
OUTPUT_STRIP_TRAILING_WHITESPACE
)
juce_add_plugin(surge-fx
PRODUCT_NAME "SurgeEffectsBank"
COMPANY_NAME "Surge Synth Team"
BUNDLE_ID "org.surge-synth-team.surge-fx"
PLUGIN_MANUFACTURER_CODE VmbA
PLUGIN_CODE SFXB
IS_SYNTH FALSE
NEEDS_MIDI_INPUT FALSE
NEEDS_MIDI_OUTPUT FALSE
IS_MIDI_EFFECT FALSE
FORMATS AU VST3 Standalone
)
juce_generate_juce_header( surge-fx )
set_property(TARGET surge-fx PROPERTY CXX_STANDARD 17)
file(GLOB TWS_RESOURCES_GLOB
resources/*.svg
deps/surge/resources/data/configuration.xml
)
juce_add_binary_data( surge-fx-binary
SOURCES ${TWS_RESOURCES_GLOB}
)
set_target_properties(surge-fx-binary PROPERTIES
POSITION_INDEPENDENT_CODE TRUE)
target_include_directories(surge-fx
PRIVATE
src
deps/surge/src/common
deps/surge/src/common/dsp
deps/surge/src/common/effects
deps/surge/src/headless
deps/surge/libs/xml
deps/surge/libs/tuning-library/include
deps/surge/libs/strnatcmp
deps/surge/libs/filesystem
)
configure_file(
${CMAKE_SOURCE_DIR}/src/version.cpp.in
${CMAKE_BINARY_DIR}/generated/version.cpp
)
target_sources(surge-fx PRIVATE
src/OSSpecificHacks.cpp
src/SurgeFXEditor.cpp
src/SurgeFXProcessor.cpp
deps/surge/libs/strnatcmp/strnatcmp.cpp
deps/surge/libs/filesystem/filesystem.cpp
deps/surge/libs/xml/tinyxml.cpp
deps/surge/libs/xml/tinyxmlerror.cpp
deps/surge/libs/xml/tinyxmlparser.cpp
deps/surge/src/common/dsp/effect/ConditionerEffect.cpp
deps/surge/src/common/dsp/effect/DistortionEffect.cpp
deps/surge/src/common/dsp/effect/DualDelayEffect.cpp
deps/surge/src/common/dsp/effect/Effect.cpp
deps/surge/src/common/dsp/effect/FlangerEffect.cpp
deps/surge/src/common/dsp/effect/FreqshiftEffect.cpp
deps/surge/src/common/dsp/effect/PhaserEffect.cpp
deps/surge/src/common/dsp/effect/Reverb1Effect.cpp
deps/surge/src/common/dsp/effect/Reverb2Effect.cpp
deps/surge/src/common/dsp/effect/RingModulatorEffect.cpp
deps/surge/src/common/dsp/effect/RotarySpeakerEffect.cpp
deps/surge/src/common/dsp/effect/VocoderEffect.cpp
deps/surge/src/common/dsp/AdsrEnvelope.cpp
deps/surge/src/common/dsp/BiquadFilter.cpp
deps/surge/src/common/dsp/BiquadFilterSSE2.cpp
deps/surge/src/common/dsp/DspUtilities.cpp
deps/surge/src/common/dsp/FilterCoefficientMaker.cpp
deps/surge/src/common/dsp/FMOscillator.cpp
deps/surge/src/common/dsp/LfoModulationSource.cpp
deps/surge/src/common/dsp/Oscillator.cpp
deps/surge/src/common/dsp/QuadFilterChain.cpp
deps/surge/src/common/dsp/QuadFilterUnit.cpp
deps/surge/src/common/dsp/SampleAndHoldOscillator.cpp
deps/surge/src/common/dsp/SurgeSuperOscillator.cpp
deps/surge/src/common/dsp/SurgeVoice.cpp
deps/surge/src/common/dsp/VectorizedSvfFilter.cpp
deps/surge/src/common/dsp/Wavetable.cpp
deps/surge/src/common/dsp/WavetableOscillator.cpp
deps/surge/src/common/dsp/WindowOscillator.cpp
deps/surge/src/common/thread/CriticalSection.cpp
deps/surge/src/common/util/FpuState.cpp
deps/surge/src/common/vt_dsp/basic_dsp.cpp
deps/surge/src/common/vt_dsp/halfratefilter.cpp
deps/surge/src/common/vt_dsp/lipol.cpp
deps/surge/src/common/vt_dsp/macspecific.cpp
deps/surge/src/common/Parameter.cpp
deps/surge/src/common/precompiled.cpp
deps/surge/src/common/SurgeError.cpp
deps/surge/src/common/SurgePatch.cpp
deps/surge/src/common/SurgeStorage.cpp
deps/surge/src/common/SurgeSynthesizer.cpp
deps/surge/src/common/SurgeSynthesizerIO.cpp
deps/surge/src/common/UserDefaults.cpp
deps/surge/src/common/WavSupport.cpp
deps/surge/src/headless/UserInteractionsHeadless.cpp
${CMAKE_BINARY_DIR}/generated/version.cpp
)
target_compile_definitions(surge-fx PUBLIC
JUCE_ALLOW_STATIC_NULL_VARIABLES=0
JUCE_STRICT_REFCOUNTEDPOINTER=1
JUCE_VST3_CAN_REPLACE_VST2=0
JUCE_USE_CURL=0
JUCE_WEB_BROWSER=0
JUCE_DISPLAY_SPLASH_SCREEN=0
JUCE_REPORT_APP_USAGE=0
JUCE_ALSA=1
JUCE_JACK=1
TARGET_HEADLESS=1
)
target_link_libraries(surge-fx PRIVATE
surge-fx-binary
juce::juce_audio_utils
juce::juce_audio_processors
)
include(CheckCXXSymbolExists)
CHECK_CXX_SYMBOL_EXISTS(std::filesystem::path::preferred_separator "filesystem" CXX_STD_FS)
if( CXX_STD_FS )
set( FS_COMPILE_DEFINITIONS USE_STD_FILESYSTEM=1 )
message( STATUS "Using std::filesystem" )
else()
if( UNIX AND NOT APPLE )
set (CMAKE_REQUIRED_FLAGS "-std=c++11")
set (CMAKE_REQUIRED_LIBRARIES "stdc++fs")
endif()
CHECK_CXX_SYMBOL_EXISTS(std::experimental::filesystem::path::preferred_separator "experimental/filesystem" CXX_EXP_STD_FS)
if( UNIX AND NOT APPLE )
set (CMAKE_REQUIRED_FLAGS "")
set (CMAKE_REQUIRED_LIBRARIES "")
endif()
if( CXX_EXP_STD_FS )
set( FS_COMPILE_DEFINITIONS USE_STD_EXPERIMENTAL_FILESYSTEM=1 )
message( STATUS "Using std::experimental::filesystem" )
else()
CHECK_CXX_SYMBOL_EXISTS(std::experimental::filesystem::path::preferred_separator "filesystem" CXX_EXP_STD_FS_FS_HDR)
if( CXX_EXP_STD_FS_FS_HDR )
set( FS_COMPILE_DEFINITIONS USE_STD_EXPERIMENTAL_FILESYSTEM_FROM_FILESYSTEM=1 )
message( STATUS "Using std::experimental::filesystem but from <filesystem> header" )
else()
set( FS_COMPILE_DEFINITIONS USE_HOMEGROWN_FILESYSTEM=1 )
message( STATUS "Using homegrown filesystem" )
endif()
endif()
endif()
target_compile_definitions(surge-fx PUBLIC ${FS_COMPILE_DEFINITIONS} )
if( APPLE )
target_compile_definitions( surge-fx PUBLIC
MAC=1
)
target_compile_options( surge-fx PUBLIC
"-D_aligned_malloc(x,a)=malloc(x)"
"-D_aligned_free(x)=free(x)"
)
elseif( UNIX )
target_compile_definitions( surge-fx PUBLIC
LINUX=1
)
target_compile_options( surge-fx PUBLIC
"-D_aligned_malloc(x,a)=malloc(x)"
"-D_aligned_free(x)=free(x)"
)
target_include_directories( surge-fx PRIVATE deps/surge/src/linux )
target_link_libraries( surge-fx PRIVATE pthread stdc++fs )
else()
target_compile_definitions( surge-fx PUBLIC
WINDOWS=1
NOMINMAX=1
WIN32
_WIN32_WINNT=0x0601
_USRDLL
VA_SUBTRACTIVE_EXPORTS
TIXML_USE_STL
USE_LIBPNG
_CRT_SECURE_NO_WARNINGS=1
)
target_compile_options( surge-fx PUBLIC
/FIprecompiled.h
/Zc:alignedNew
/bigobj
)
target_include_directories( surge-fx PRIVATE deps/surge/src/windows )
endif()
# Build installers
get_target_property( OUTPUT_DIR surge-fx RUNTIME_OUTPUT_DIRECTORY )
add_custom_target( well-named-assets )
if( APPLE )
add_custom_target( well-named-au )
add_dependencies( well-named-au surge-fx_AU )
add_dependencies( well-named-assets well-named-au )
endif()
add_custom_target( well-named-vst3 )
add_dependencies( well-named-vst3 surge-fx_VST3 )
add_dependencies( well-named-assets well-named-vst3 )
add_custom_target( installer-pkg )
add_dependencies( installer-pkg well-named-vst3 )
add_dependencies( installer-pkg surge-fx )
add_dependencies( installer-pkg surge-fx_Standalone )
add_dependencies( installer-pkg surge-fx_VST3 )
set( INSTALLER_DIR ${CMAKE_BINARY_DIR}/asset )
set( WELL_NAMED_ASSET_DIR ${CMAKE_BINARY_DIR}/product )
set( INSTALLER_BASENAME "SurgeEffectsBank" )
add_custom_command(
TARGET well-named-vst3
POST_BUILD
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
COMMAND ${CMAKE_COMMAND} -E make_directory ${WELL_NAMED_ASSET_DIR}
COMMAND ${CMAKE_COMMAND} -E copy_directory ${OUTPUT_DIR}/VST3 ${WELL_NAMED_ASSET_DIR}
)
if( APPLE )
add_custom_command(
TARGET well-named-au
POST_BUILD
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
COMMAND ${CMAKE_COMMAND} -E make_directory ${WELL_NAMED_ASSET_DIR}
COMMAND ${CMAKE_COMMAND} -E copy_directory ${OUTPUT_DIR}/AU ${WELL_NAMED_ASSET_DIR}
)
endif()
if( APPLE )
add_custom_command(
TARGET installer-pkg
POST_BUILD
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
COMMAND ${CMAKE_COMMAND} -E make_directory ${INSTALLER_DIR}
COMMAND hdiutil create ${INSTALLER_DIR}/${INSTALLER_BASENAME}-macos-${GIT_COMMIT_HASH}.dmg -ov -volname "${INSTALLER_BASENAME}-${GIT_COMMIT_HASH}" -fs HFS+ -srcfolder ${OUTPUT_DIR}
)
elseif( UNIX )
add_custom_command(
TARGET installer-pkg
POST_BUILD
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
COMMAND ${CMAKE_COMMAND} -E make_directory ${INSTALLER_DIR}
COMMAND ls -l ${OUTPUT_DIR}
COMMAND cd ${OUTPUT_DIR} && tar czf "${INSTALLER_DIR}/${INSTALLER_BASENAME}-linux-${GIT_COMMIT_HASH}.tgz" "Standalone/${INSTALLER_BASENAME}" "VST3/${INSTALLER_BASENAME}.vst3"
)
else()
file( TO_NATIVE_PATH "${INSTALLER_DIR}/${INSTALLER_BASENAME}-win-${GIT_COMMIT_HASH}.zip" OUTPUT_ZIP )
message( STATUS "Final product will be ${OUTPUT_ZIP} from ${WELL_NAMED_ASSET_DIR}" )
add_custom_command(
TARGET installer-pkg
POST_BUILD
WORKING_DIRECTORY ${WELL_NAMED_ASSET_DIR}
COMMAND ${CMAKE_COMMAND} -E make_directory ${INSTALLER_DIR}
COMMAND powershell Compress-Archive
-DestinationPath "${OUTPUT_ZIP}"
-Path "."
)
endif()