-
Notifications
You must be signed in to change notification settings - Fork 5
/
CMakeLists.txt
executable file
·373 lines (331 loc) · 12.3 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
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
#########################################
# CMake Project for TRANSFORMANT Plugin #
#########################################
cmake_minimum_required(VERSION 3.19)
set(CMAKE_COLOR_MAKEFILE ON)
# uncomment to build as VST2.4 instead of VST3.0 (provides wider DAW compatibility), not supported on Linux
#set(SMTG_CREATE_VST2_VERSION "Use VST2" ON)
project(transformant)
set(PROJECT_VERSION 1)
set(target transformant)
set(copyright "igorski.nl 2020-2023")
set(major_version 1)
set(minor_version 0)
set(release_number 4)
set(build_number 1) # TODO supply through CLI (build number is not included in public facing version strings)
set(SMTG_CREATE_MODULE_INFO false)
#####################
# Compiler settings #
#####################
set(CMAKE_CXX_STANDARD 17)
add_definitions(-DNDEBUG)
add_compile_definitions(PLUGIN_COPYRIGHT=${copyright})
add_compile_definitions(PLUGIN_MAJOR_VERSION=${major_version})
add_compile_definitions(PLUGIN_MINOR_VERSION=${minor_version})
add_compile_definitions(PLUGIN_RELEASE_NUMBER=${release_number})
add_compile_definitions(PLUGIN_BUILD_NUMBER=${build_number})
if(MSVC)
add_definitions(/D _CRT_SECURE_NO_WARNINGS)
endif()
if(UNIX)
if(XCODE)
set(CMAKE_XCODE_ATTRIBUTE_CLANG_CXX_LANGUAGE_STANDARD "c++17")
set(CMAKE_XCODE_ATTRIBUTE_CLANG_CXX_LIBRARY "libc++")
elseif(APPLE)
set(CMAKE_POSITION_INDEPENDENT_CODE TRUE)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++17 -stdlib=libc++")
link_libraries(c++)
# support Yosemite and up
set(CMAKE_OSX_SYSROOT macosx10.13)
set(CMAKE_OSX_DEPLOYMENT_TARGET "10.13")
else()
set(LINUX true)
add_definitions( -D__cdecl= )
set(CMAKE_POSITION_INDEPENDENT_CODE TRUE)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++17 -Wno-multichar")
link_libraries(stdc++fs pthread dl)
endif()
else()
## spotted to not be set by default on VS CLI. Here we assume any non-Unix
## OS MUST be Windows. Then again that's the only other intended target for this project...
set(WIN true)
endif()
############
# Includes #
############
list(APPEND CMAKE_MODULE_PATH "${VST3_SDK_ROOT}/cmake/modules")
include(SMTG_Global)
include(SMTG_AddVST3Library)
include(SMTG_Bundle)
include(SMTG_ExportedSymbols)
include(SMTG_PrefixHeader)
include(SMTG_PlatformIOS)
include(SMTG_PlatformToolset)
include(SMTG_CoreAudioSupport)
include(SMTG_AAXSupport)
include(SMTG_VstGuiSupport)
include(SMTG_UniversalBinary)
include(SMTG_AddVST3Options)
#########################
# Steinberg VST sources #
#########################
set(VSTSDK_INCLUDE_DIR ${VST3_SDK_ROOT})
set(VSTSDK_PLUGIN_SOURCE
${VST3_SDK_ROOT}/public.sdk/source/common/commoniids.cpp
${VST3_SDK_ROOT}/public.sdk/source/vst/vstaudioeffect.cpp
${VST3_SDK_ROOT}/public.sdk/source/vst/vstaudioprocessoralgo.h
${VST3_SDK_ROOT}/public.sdk/source/vst/vsteditcontroller.h
${VST3_SDK_ROOT}/pluginterfaces/base/ibstream.h
${VST3_SDK_ROOT}/pluginterfaces/base/ustring.h
${VST3_SDK_ROOT}/pluginterfaces/vst/ivstevents.h
${VST3_SDK_ROOT}/pluginterfaces/vst/ivstparameterchanges.h
${VST3_SDK_ROOT}/pluginterfaces/vst/vstpresetkeys.h
)
set(vst2_sources
${VST3_SDK_ROOT}/public.sdk/source/vst/vst2wrapper/vst2wrapper.sdk.cpp
src/vstentry_vst2.cpp
)
if(APPLE)
set(vst2_sources
${vst2_sources}
${VST3_SDK_ROOT}/public.sdk/source/common/threadchecker_mac.mm
)
elseif(WIN)
set(vst2_sources
${vst2_sources}
${VST3_SDK_ROOT}/public.sdk/source/common/threadchecker_win32.cpp
)
endif()
##########################
# Plugin project sources #
##########################
set(vst_sources
src/global.h
src/audiobuffer.h
src/audiobuffer.cpp
src/bitcrusher.h
src/bitcrusher.cpp
src/formantfilter.h
src/formantfilter.cpp
src/lfo.h
src/lfo.cpp
src/limiter.h
src/limiter.cpp
src/paramids.h
src/pluginprocess.h
src/pluginprocess.cpp
src/vst.h
src/vst.cpp
src/vstentry.cpp
src/version.h
src/waveshaper.h
src/waveshaper.cpp
src/ui/controller.h
src/ui/controller.cpp
src/ui/uimessagecontroller.h
${VSTSDK_PLUGIN_SOURCE}
)
# add the VST2 source files when compiling a VST2 (not supported on Linux)
if(SMTG_CREATE_VST2_VERSION)
if(APPLE OR WIN)
set(vst_sources ${vst_sources} ${vst2_sources})
endif()
endif()
set(vst_resources
"resource/background.png"
"resource/version.png"
)
set(vst_ui_descr "resource/plugin.uidesc")
##############
# Audio Unit #
##############
if (JAMBA_ENABLE_AUDIO_UNIT)
set(JAMBA_TEST_CASES_DIR "${JAMBA_ROOT}/test/cpp")
set(JAMBA_TEST_CASES_SOURCES
${JAMBA_TEST_CASES_DIR}/pongasoft/Utils/Collection/test-CircularBuffer.cpp
${JAMBA_TEST_CASES_DIR}/pongasoft/Utils/Concurrent/test-concurrent.cpp
${JAMBA_TEST_CASES_DIR}/pongasoft/Utils/Concurrent/test-concurrent_lockfree.cpp
${JAMBA_TEST_CASES_DIR}/pongasoft/Utils/test-Lerp.cpp
${JAMBA_TEST_CASES_DIR}/pongasoft/Utils/test-StringUtils.cpp
${JAMBA_TEST_CASES_DIR}/pongasoft/VST/GUI/Params/test-GUIParameters.cpp
${JAMBA_TEST_CASES_DIR}/pongasoft/VST/GUI/Params/test-ParamAware.cpp
${JAMBA_TEST_CASES_DIR}/pongasoft/VST/GUI/Views/test-CustomViewCreator.cpp
${JAMBA_TEST_CASES_DIR}/pongasoft/VST/GUI/Views/test-SelfContainedViewListener.cpp
${JAMBA_TEST_CASES_DIR}/pongasoft/VST/test-AudioBuffers.cpp
${JAMBA_TEST_CASES_DIR}/pongasoft/VST/test-AudioUtils.cpp
${JAMBA_TEST_CASES_DIR}/pongasoft/VST/test-ParamConverters.cpp
${JAMBA_TEST_CASES_DIR}/pongasoft/VST/test-SampleRateBasedClock.cpp
${JAMBA_TEST_CASES_DIR}/pongasoft/VST/Utils/test-Utils.cpp
${JAMBA_TEST_CASES_DIR}/pongasoft/VST/Utils/test-FastWriteMemoryStream.cpp
${JAMBA_TEST_CASES_DIR}/pongasoft/VST/Utils/test-ReadOnlyMemoryStream.cpp
)
include(jamba.cmake)
set(CPP_SOURCES src)
configure_file(${CPP_SOURCES}/version.h ${CMAKE_BINARY_DIR}/generated/version.h)
include_directories(${CMAKE_BINARY_DIR}/generated/)
jamba_add_vst_plugin(
TARGET "${target}"
RELEASE_FILENAME "${target}.component"
TARGETS_PREFIX "jmb_"
VST_SOURCES "${vst_sources}"
UIDESC "${vst_ui_descr}"
RESOURCES "${vst_resources}"
TEST_CASE_SOURCES "${JAMBA_TEST_CASES_SOURCES}"
TEST_LINK_LIBRARIES "jamba"
)
else()
#######
# VST #
#######
smtg_add_vst3plugin(${target} ${vst_sources})
## include Steinberg libraries
set(steinberg_libs "base" "pluginterfaces" "sdk" "vstgui_support" "vstgui_uidescription" "vstgui")
include_directories(${VSTSDK_INCLUDE_DIR})
foreach(lib IN ITEMS ${steinberg_libs})
if(UNIX)
target_link_libraries(${target} PRIVATE ${VST3_SDK_ROOT}/build/lib/Release/lib${lib}.a)
elseif(WIN)
target_link_libraries(${target} PRIVATE ${VST3_SDK_ROOT}/build/lib/Release/${lib}.lib)
endif()
endforeach(lib)
## Include Steinberg VSTGUI
target_include_directories(${target} PUBLIC ${VST3_SDK_ROOT}/vstgui4)
target_sources(${target} PRIVATE
${VST3_SDK_ROOT}/vstgui4/vstgui/vstgui_uidescription.cpp
${VST3_SDK_ROOT}/vstgui4/vstgui/plugin-bindings/vst3editor.cpp
${VST3_SDK_ROOT}/public.sdk/source/vst/vstguieditor.cpp
)
## include macOS specific libraries
IF (APPLE)
target_sources (${target} PRIVATE
${VST3_SDK_ROOT}/public.sdk/source/main/macmain.cpp
${VST3_SDK_ROOT}/vstgui4/vstgui/vstgui_mac.mm
)
if(XCODE)
if(SMTG_IOS_DEVELOPMENT_TEAM)
## iOS plugin
set(target ${target}_ios)
smtg_add_ios_vst3plugin("${SMTG_CODE_SIGN_IDENTITY_IOS}" ${target} "${target}" "${vst_sources}")
set_target_properties(${target} PROPERTIES ${SDK_IDE_PLUGIN_EXAMPLES_FOLDER})
target_link_libraries(${target} PRIVATE
base_ios
sdk_ios
"-framework UIKit"
"-framework CoreGraphics"
"-framework QuartzCore"
"-framework CoreText"
"-framework Accelerate"
"-framework ImageIO"
"-framework MobileCoreServices"
)
target_sources(${target} PRIVATE
${VST3_SDK_ROOT}/vstgui4/vstgui/vstgui_ios.mm
)
else()
## macOS plugin
target_link_libraries(${target} PRIVATE "-framework Cocoa" "-framework OpenGL" "-framework Accelerate" "-framework QuartzCore" "-framework Carbon")
endif()
else()
find_library(COREFOUNDATION_FRAMEWORK CoreFoundation)
find_library(COCOA_FRAMEWORK Cocoa)
find_library(OPENGL_FRAMEWORK OpenGL)
find_library(ACCELERATE_FRAMEWORK Accelerate)
find_library(QUARTZCORE_FRAMEWORK QuartzCore)
find_library(CARBON_FRAMEWORK Carbon)
find_library(EXPAT Expat)
target_link_libraries(${target} PRIVATE ${COREFOUNDATION_FRAMEWORK} ${COCOA_FRAMEWORK} ${OPENGL_FRAMEWORK} ${ACCELERATE_FRAMEWORK} ${QUARTZCORE_FRAMEWORK} ${CARBON_FRAMEWORK} ${EXPAT})
endif()
set_target_properties(${target} PROPERTIES
BUNDLE true
BUNDLE_EXTENSION "vst3"
XCODE_ATTRIBUTE_WRAPPER_EXTENSION "vst3"
MACOSX_BUNDLE_INFO_PLIST "${CMAKE_CURRENT_SOURCE_DIR}/mac/Info.plist"
MACOSX_BUNDLE_BUNDLE_NAME "${project}"
MACOSX_BUNDLE_GUI_IDENTIFIER "nl.igorski.vst.${target}"
MACOSX_BUNDLE_ICON_FILE ""
MACOSX_BUNDLE_SHORT_VERSION_STRING "${major_version}.${minor_version}.${release_number}"
MACOSX_BUNDLE_COPYRIGHT "${copyright}"
)
endif()
## include Linux specific libraries
if (LINUX)
target_sources (${target} PRIVATE
${VST3_SDK_ROOT}/public.sdk/source/main/linuxmain.cpp
)
set(VSTGUI_LTO_COMPILER_FLAGS "-O3 -flto")
set(VSTGUI_LTO_LINKER_FLAGS "")
find_package(X11 REQUIRED)
find_package(Freetype REQUIRED)
find_package(PkgConfig REQUIRED)
pkg_check_modules(LIBXCB REQUIRED xcb)
pkg_check_modules(LIBXCB_UTIL REQUIRED xcb-util)
pkg_check_modules(LIBXCB_CURSOR REQUIRED xcb-cursor)
pkg_check_modules(LIBXCB_KEYSYMS REQUIRED xcb-keysyms)
pkg_check_modules(LIBXCB_XKB REQUIRED xcb-xkb)
pkg_check_modules(LIBXKB_COMMON REQUIRED xkbcommon)
pkg_check_modules(LIBXKB_COMMON_X11 REQUIRED xkbcommon-x11)
set(LINUX_LIBRARIES
${X11_LIBRARIES}
${FREETYPE_LIBRARIES}
${LIBXCB_LIBRARIES}
${LIBXCB_UTIL_LIBRARIES}
${LIBXCB_CURSOR_LIBRARIES}
${LIBXCB_KEYSYMS_LIBRARIES}
${LIBXCB_XKB_LIBRARIES}
${LIBXKB_COMMON_LIBRARIES}
${LIBXKB_COMMON_X11_LIBRARIES}
cairo
fontconfig
dl
)
target_link_libraries(${target} PRIVATE ${LINUX_LIBRARIES})
endif()
## Include Windows specific libraries
if(WIN)
target_sources (${target} PRIVATE
${VST3_SDK_ROOT}/public.sdk/source/main/dllmain.cpp
# ${VST3_SDK_ROOT}/vstgui4/vstgui/vstgui_win32.cpp
)
endif()
## Add the resource files to the bundle
smtg_target_add_plugin_resources(${target}
RESOURCES ${vst_ui_descr} ${vst_resources}
)
if(APPLE)
smtg_target_set_bundle(${target} INFOPLIST "${CMAKE_CURRENT_SOURCE_DIR}/mac/Info.plist" PREPROCESS)
# adding PkgInfo at root level makes plugin appear as a file instead of folder
smtg_target_add_plugin_resources(${target} RESOURCES "${CMAKE_CURRENT_SOURCE_DIR}/mac/PkgInfo" OUTPUT_SUBDIRECTORY "../")
elseif(WIN)
target_sources(${target} PRIVATE resource/plugin.rc)
endif()
if (SMTG_CREATE_VST2_VERSION)
message(STATUS "SMTG_CREATE_VST2_VERSION is set. A VST 2 version of the plug-in will be created (just rename the generated file from .vst3 to .vst).")
if(XCODE)
# fix missing VSTPluginMain symbol when also building VST 2 version
set_target_properties(${target} PROPERTIES XCODE_ATTRIBUTE_EXPORTED_SYMBOLS_FILE "")
endif()
if (WIN)
add_definitions(-D_CRT_SECURE_NO_WARNINGS)
endif()
endif()
endif()
######################
# Installation paths #
######################
if(APPLE)
install(TARGETS ${target}
DESTINATION "$ENV{HOME}/Library/Audio/Plug-Ins/VST"
)
elseif(WIN32)
install(TARGETS ${target}
DESTINATION "C:/Program Files (x86)/Common Files/VST3/"
)
elseif(WIN)
install(TARGETS ${target}
DESTINATION "C:/Program Files/Common Files/VST3/"
)
elseif(LINUX)
install(TARGETS ${target}
DESTINATION "/usr/lib/lxvst"
)
endif()