-
Notifications
You must be signed in to change notification settings - Fork 1
/
CMakeLists.txt
220 lines (202 loc) · 7.5 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
cmake_minimum_required (VERSION 3.15)
project (SynthEngineDemo VERSION 1.0.0 LANGUAGES CXX C)
if (NOT DEFINED CMAKE_BUILD_TYPE)
set (CMAKE_BUILD_TYPE "Release" CACHE STRING "Choose the type of build." FORCE)
endif (NOT DEFINED CMAKE_BUILD_TYPE)
set (CMAKE_CXX_STANDARD 20)#使用C++20
set (CMAKE_CXX_EXTENSIONS OFF)
set (CMAKE_CXX_STANDARD_REQUIRED ON)
set (CMAKE_C_STANDARD 17)#使用C17
set (CMAKE_C_EXTENSIONS OFF)
set (CMAKE_C_STANDARD_REQUIRED ON)
set (CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>DLL")#MSVC下使用/MD和/MDd
# =============================================
# JUCE
# =============================================
set (JucePlugin_Name "SynthEngineDemo")
set (JucePlugin_Desc "VocalShaper Synth Engine Demo")
set (JucePlugin_Manufacturer "VocalSharp Org.")
set (JucePlugin_ManufacturerWebsite "https://daw.org.cn")
set (JucePlugin_ManufacturerEmail "[email protected]")
set (JucePlugin_Version "1.0.0")
set (JucePlugin_VersionCode "0x010000")
set (JucePlugin_ManufacturerCode "0x56736474")
set (JucePlugin_PluginCode "0x53656764")
set (JucePlugin_IsSynth ON)
set (JucePlugin_IsMidiEffect OFF)
set (JucePlugin_WantsMidiInput ON)
set (JucePlugin_ProducesMidiOutput OFF)
set (JucePlugin_EditorRequiresKeyboardFocus ON)
set (JucePlugin_Vst3Category "Instrument|Generator|Synth")
set (JucePlugin_CFBundleIdentifier "org.VocalSharp.VocalShaper.SynthEngineDemo")
set (JucePlugin_VSTNumMidiInputs "16")
set (JucePlugin_VSTNumMidiOutputs "0")
set (JucePlugin_MaxNumInputChannels "2")
set (JucePlugin_MaxNumOutputChannels "2")
set (JucePlugin_PreferredChannelConfigurations "{0, 1}, {0, 2}, {1, 1}, {1, 2}, {2, 1}, {2, 2}")
set (JucePlugin_Enable_ARA ON)
set (JucePlugin_ARACompatibleArchiveIDs "org.VocalSharp.VocalShaper.SynthEngineDemo")
set (JucePlugin_ARAContentTypes "0x01")
set (JucePlugin_ARATransformationFlags "0x00")
set (JucePlugin_ARAFactoryID "org.VocalSharp.VocalShaper.SynthEngineDemo")
set (JucePlugin_ARADocumentArchiveID "org.VocalSharp.VocalShaper.SynthEngineDemo")
add_subdirectory (juce-vst3-dev-kit)
# =============================================
# Target
# =============================================
file (GLOB_RECURSE TARGET_SRC "src/*.cpp" "src/*.h")
add_library (SynthEngineDemo SHARED ${TARGET_SRC})
target_link_libraries (SynthEngineDemo PRIVATE juce)
set_target_properties (SynthEngineDemo PROPERTIES
PREFIX "" OUTPUT_NAME "SynthEngineDemo" SUFFIX ".vst3")
if (NOT MSVC)
target_compile_options (SynthEngineDemo PRIVATE
-pthread
-fvisibility=hidden
-fvisibility-inlines-hidden
)
if (NOT (("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang") AND WIN32))
target_compile_options (SynthEngineDemo PRIVATE -fPIC)
endif ()
target_link_options (SynthEngineDemo PRIVATE
-shared
-fvisibility=hidden
-fvisibility-inlines-hidden
)
if (WIN32)
target_link_libraries (SynthEngineDemo PRIVATE
-m64
-lcomctl32
-lwinmm
-lwsock32
-lwininet
-lversion
-lws2_32
-loleaut32
-limm32
-lshlwapi
-lrpcrt4
-lopengl32
-ldxgi
)
if (NOT ("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang"))
target_link_libraries (${TARGET} PRIVATE -s)
endif ()
elseif (UNIX AND NOT APPLE)
target_link_libraries (SynthEngineDemo PRIVATE
${RT}
${DL}
${PTHREAD}
${GL}
${ALSA_LIBRARIES}
${FREETYPE2_LIBRARIES}
${LIBCURL_LIBRARIES}
)
elseif (APPLE)
target_link_libraries (SynthEngineDemo PRIVATE
"-framework Accelerate"
"-framework AudioToolbox"
"-framework AVFoundation"
"-framework AVKit"
"-framework Carbon"
"-framework Cocoa"
"-framework CoreAudio"
"-framework CoreAudioKit"
"-framework CoreMedia"
"-framework CoreMIDI"
"-framework DiscRecording"
"-framework Foundation"
"-framework IOKit"
"-framework OpenGL"
"-framework QuartzCore"
"-framework WebKit"
)
endif ()
else (NOT MSVC)
if (CMAKE_BUILD_TYPE STREQUAL Debug)
target_compile_options (SynthEngineDemo PRIVATE
/permissive-#符合模式:是
/GS#安全检查:启用安全检查
/Zc:wchar_t#将WChar_t视为内置类型:是
/Gm-#启用最小重新生成:否
/sdl#SDL检查:是
/fp:precise#浮点模型:精度
/Zc:forScope#强制For循环范围中的合规性:是
/Gd#调用约定:__cdecl
/nologo#取消显示启动版权标志:是
/bigobj#较大生成对象:是
)
target_link_options (SynthEngineDemo PRIVATE
/MANIFEST#生成清单:是
/NXCOMPAT#数据执行保护(DEP):是
/DYNAMICBASE#随机基址:是
/LARGEADDRESSAWARE#启用大地址:是
/SUBSYSTEM:WINDOWS#子系统:窗口
/MANIFESTUAC:NO#启用用户账户控制:否
/NOLOGO#取消显示启动版权标志:是
)
else (CMAKE_BUILD_TYPE STREQUAL Debug)
target_compile_options (SynthEngineDemo PRIVATE
/permissive-#符合模式:是
/GS#安全检查:启用安全检查
/GL#全程序优化:是
/Gy#启用函数级链接:是
/Zc:wchar_t#将WChar_t视为内置类型:是
/Gm-#启用最小重新生成:否
/sdl#SDL检查:是
/fp:precise#浮点模型:精度
/Zc:forScope#强制For循环范围中的合规性:是
/Gd#调用约定:__cdecl
/Oi#启用内部函数:是
/nologo#取消显示启动版权标志:是
/bigobj#较大生成对象:是
)
target_link_options (SynthEngineDemo PRIVATE
/MANIFEST#生成清单:是
/LTCG:incremental#链接时间代码生成:使用快速链接时间代码生成
/NXCOMPAT#数据执行保护(DEP):是
/DYNAMICBASE#随机基址:是
/LARGEADDRESSAWARE#启用大地址:是
/OPT:REF#引用:是
/SUBSYSTEM:WINDOWS#子系统:窗口
/MANIFESTUAC:NO#启用用户账户控制:否
/OPT:ICF#启用COMDAT折叠:是
/NOLOGO#取消显示启动版权标志:是
)
endif (CMAKE_BUILD_TYPE STREQUAL Debug)
endif (NOT MSVC)
# =============================================
# Install
# =============================================
include(GNUInstallDirs)
include(CMakePackageConfigHelpers)
set (ENGINE_INSTALL_NAME ${PROJECT_NAME})
set (ENGINE_CMAKE_CONFIG_INSTALL_DIR ${CMAKE_INSTALL_LIBDIR}/cmake/${ENGINE_INSTALL_NAME})
install (TARGETS SynthEngineDemo
EXPORT ${ENGINE_INSTALL_NAME}Targets
RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}" OPTIONAL
)
if (MSVC)
install (FILES $<TARGET_PDB_FILE:SynthEngineDemo> DESTINATION "${CMAKE_INSTALL_BINDIR}" OPTIONAL)
endif (MSVC)
write_basic_package_version_file (
"${CMAKE_CURRENT_BINARY_DIR}/${ENGINE_INSTALL_NAME}ConfigVersion.cmake"
VERSION ${PROJECT_VERSION}
COMPATIBILITY AnyNewerVersion
)
configure_package_config_file (
"${CMAKE_CURRENT_LIST_DIR}/${ENGINE_INSTALL_NAME}Config.cmake.in"
"${CMAKE_CURRENT_BINARY_DIR}/${ENGINE_INSTALL_NAME}Config.cmake"
INSTALL_DESTINATION ${ENGINE_CMAKE_CONFIG_INSTALL_DIR}
NO_CHECK_REQUIRED_COMPONENTS_MACRO
)
install (FILES
"${CMAKE_CURRENT_BINARY_DIR}/${ENGINE_INSTALL_NAME}Config.cmake"
"${CMAKE_CURRENT_BINARY_DIR}/${ENGINE_INSTALL_NAME}ConfigVersion.cmake"
DESTINATION ${ENGINE_CMAKE_CONFIG_INSTALL_DIR}
)
install (EXPORT ${ENGINE_INSTALL_NAME}Targets
FILE "${ENGINE_INSTALL_NAME}Targets.cmake"
NAMESPACE ${ENGINE_INSTALL_NAME}::
DESTINATION ${ENGINE_CMAKE_CONFIG_INSTALL_DIR}
)