-
-
Notifications
You must be signed in to change notification settings - Fork 5
/
CMakeLists.txt
262 lines (232 loc) · 9.2 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
cmake_minimum_required (VERSION 3.15)
project (VocalShaper VERSION 0.0.2 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)# Using C++20
set(CMAKE_CXX_EXTENSIONS OFF)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_C_STANDARD 17)# Using C17
set(CMAKE_C_EXTENSIONS OFF)
set(CMAKE_C_STANDARD_REQUIRED ON)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)# For Clang-Tidy
set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>DLL")# Using /MD and /MDd on MSVC
if (WIN32)
add_compile_definitions ("_CRT_SECURE_NO_WARNINGS")
endif (WIN32)
if (WIN32)
set (COMPILE_SYS_DEF "WIN32=1")
elseif (UNIX AND NOT APPLE)
set (COMPILE_SYS_DEF "LINUX=1")
elseif (APPLE)
set (COMPILE_SYS_DEF "DARWIN=1")
endif ()
# Packages
find_package (juce-host-dev-kit CONFIG REQUIRED)
find_package (SynthEngineDemo CONFIG REQUIRED)
find_package (Lua REQUIRED)
find_package (cmake-lame CONFIG REQUIRED)
find_package (vsp4 CONFIG REQUIRED)
find_package (flowui CONFIG REQUIRED)
set (OUTPUT_DIR "${CMAKE_BINARY_DIR}/bin")
set (ENGINES_DIR "${OUTPUT_DIR}/synth-engines")
# App Configs
file (GLOB_RECURSE APP_CONFIG_SRC CONFIGURE_DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/app/*")
set (APP_CONFIG_OUTPUT "")
foreach (ITEM ${APP_CONFIG_SRC})
string (REPLACE "${CMAKE_CURRENT_SOURCE_DIR}/app" "${OUTPUT_DIR}" ITEM_TARGET ${ITEM})
list (APPEND APP_CONFIG_OUTPUT ${ITEM_TARGET})
cmake_path (CONVERT ${ITEM} TO_NATIVE_PATH_LIST ITEM_INPUT)
cmake_path (CONVERT ${ITEM_TARGET} TO_NATIVE_PATH_LIST ITEM_OUTPUT)
add_custom_command (
OUTPUT ${ITEM_TARGET}
COMMAND copy ${ITEM_INPUT} ${ITEM_OUTPUT}
DEPENDS ${ITEM}
COMMENT "Copying application config file: ${ITEM}"
VERBATIM)
endforeach (ITEM ${APP_CONFIG_SRC})
add_custom_target (app_config_copy
DEPENDS ${APP_CONFIG_OUTPUT}
COMMENT "Copy application configs"
VERBATIM)
# RemixIcon
file (GLOB_RECURSE REMIXICON_SRC CONFIGURE_DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/RemixIcon/icons/*.svg")
set (REMIXICON_OUTPUT "")
foreach (ITEM ${REMIXICON_SRC})
string(REPLACE "${CMAKE_CURRENT_SOURCE_DIR}/RemixIcon/icons" "${OUTPUT_DIR}/RemixIcon" ITEM_TARGET ${ITEM})
list (APPEND REMIXICON_OUTPUT ${ITEM_TARGET})
cmake_path (CONVERT ${ITEM} TO_NATIVE_PATH_LIST ITEM_INPUT)
cmake_path (CONVERT ${ITEM_TARGET} TO_NATIVE_PATH_LIST ITEM_OUTPUT)
add_custom_command (
OUTPUT ${ITEM_TARGET}
COMMAND copy ${ITEM_INPUT} ${ITEM_OUTPUT}
DEPENDS ${ITEM}
COMMENT "Copying icon file: ${ITEM}"
VERBATIM)
endforeach (ITEM ${REMIXICON_SRC})
add_custom_target (remix_icon_copy
DEPENDS ${REMIXICON_OUTPUT}
COMMENT "Copy RemixIcon files"
VERBATIM)
# Engines
function (engine_get_pdb var vst3_path)
get_filename_component (vst3_dir ${vst3_path} DIRECTORY)
get_filename_component (vst3_name ${vst3_path} NAME_WE)
set (${var} "${vst3_dir}/${vst3_name}.pdb" PARENT_SCOPE)
endfunction (engine_get_pdb var vst3_path)
if (${CMAKE_BUILD_TYPE} STREQUAL "Debug")
get_target_property (ENGINE_PATH SynthEngineDemo::SynthEngineDemo IMPORTED_LOCATION_DEBUG)
engine_get_pdb (ENGINE_PDB_PATH ${ENGINE_PATH})
else (${CMAKE_BUILD_TYPE} STREQUAL "Debug")
get_target_property (ENGINE_PATH SynthEngineDemo::SynthEngineDemo IMPORTED_LOCATION_RELEASE)
set (ENGINE_PDB_PATH "")
endif (${CMAKE_BUILD_TYPE} STREQUAL "Debug")
set (ENGINE_LIST ${ENGINE_LIST} "${ENGINE_PATH}")
if (MSVC)
set (ENGINE_LIST ${ENGINE_LIST} "${ENGINE_PDB_PATH}")
endif (MSVC)
set (ENGINE_OUTPUT "")
foreach (ITEM ${ENGINE_LIST})
get_filename_component (ITEM_NAME ${ITEM} NAME)
set (ITEM_TARGET "${ENGINES_DIR}/${ITEM_NAME}")
list (APPEND ENGINE_OUTPUT ${ITEM_TARGET})
cmake_path (CONVERT ${ITEM} TO_NATIVE_PATH_LIST ITEM_INPUT)
cmake_path (CONVERT ${ITEM_TARGET} TO_NATIVE_PATH_LIST ITEM_OUTPUT)
add_custom_command (
OUTPUT ${ITEM_TARGET}
COMMAND copy ${ITEM_INPUT} ${ITEM_OUTPUT}
DEPENDS ${ITEM}
COMMENT "Copying engine file: ${ITEM}"
VERBATIM)
endforeach (ITEM ${ENGINE_LIST})
add_custom_target (engines_copy
DEPENDS ${ENGINE_OUTPUT}
COMMENT "Copy engines"
VERBATIM)
add_dependencies (engines_copy
SynthEngineDemo::SynthEngineDemo
)
# lame
function (lame_get_pdb var bin_path)
get_filename_component (bin_dir ${bin_path} DIRECTORY)
get_filename_component (bin_name ${bin_path} NAME_WE)
set (${var} "${bin_dir}/${bin_name}.pdb" PARENT_SCOPE)
endfunction (lame_get_pdb var bin_path)
if (${CMAKE_BUILD_TYPE} STREQUAL "Debug")
get_target_property (LAME_PATH cmake-lame::lame IMPORTED_LOCATION_DEBUG)
lame_get_pdb (LAME_PDB_PATH ${LAME_PATH})
else (${CMAKE_BUILD_TYPE} STREQUAL "Debug")
get_target_property (LAME_PATH cmake-lame::lame IMPORTED_LOCATION_RELEASE)
set (LAME_PDB_PATH "")
endif (${CMAKE_BUILD_TYPE} STREQUAL "Debug")
set (LAME_LIST ${LAME_LIST} "${LAME_PATH}")
if (MSVC)
set (LAME_LIST ${LAME_LIST} "${LAME_PDB_PATH}")
endif (MSVC)
set (LAME_OUTPUT "")
foreach (ITEM ${LAME_LIST})
get_filename_component (ITEM_NAME ${ITEM} NAME)
set (ITEM_TARGET "${OUTPUT_DIR}/${ITEM_NAME}")
list (APPEND LAME_OUTPUT ${ITEM_TARGET})
cmake_path (CONVERT ${ITEM} TO_NATIVE_PATH_LIST ITEM_INPUT)
cmake_path (CONVERT ${ITEM_TARGET} TO_NATIVE_PATH_LIST ITEM_OUTPUT)
add_custom_command (
OUTPUT ${ITEM_TARGET}
COMMAND copy ${ITEM_INPUT} ${ITEM_OUTPUT}
DEPENDS ${ITEM}
COMMENT "Copying lame executable file: ${ITEM}"
VERBATIM)
endforeach (ITEM ${LAME_LIST})
add_custom_target (lame_copy
DEPENDS ${LAME_OUTPUT}
COMMENT "Copy lame executable file"
VERBATIM)
add_dependencies (lame_copy
cmake-lame::lame
)
# Plugin Searcher Target
file (GLOB_RECURSE PLUGINSEARCHER_SRC CONFIGURE_DEPENDS "./pluginSearcher/*.cpp" "./pluginSearcher/*.h")
add_executable (PluginSearcher ${PLUGINSEARCHER_SRC})
target_compile_definitions (PluginSearcher PRIVATE
"PROJECT_VERSION_MAJOR=${PROJECT_VERSION_MAJOR}"
"PROJECT_VERSION_MINOR=${PROJECT_VERSION_MINOR}"
"PROJECT_VERSION_PATCH=${PROJECT_VERSION_PATCH}"
)
if (NOT MSVC)
target_compile_options (PluginSearcher PRIVATE -pthread)
if (NOT (("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang") AND WIN32))
target_compile_options (PluginSearcher PRIVATE -fPIE)
endif ()
if (${CMAKE_BUILD_TYPE} STREQUAL "Debug")
target_compile_options (PluginSearcher PRIVATE -g)
endif (${CMAKE_BUILD_TYPE} STREQUAL "Debug")
endif (NOT MSVC)
target_link_libraries (PluginSearcher PRIVATE juce-host-dev-kit::juce-full)
if (MSVC)
target_link_options (PluginSearcher PRIVATE /SUBSYSTEM:WINDOWS)
elseif (("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang") AND WIN32)
target_link_options (PluginSearcher PRIVATE -Xlinker /SUBSYSTEM:WINDOWS)
endif ()
set_target_properties (PluginSearcher PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${OUTPUT_DIR}")
# File Registrar Target
file (GLOB_RECURSE FILEREGISTRAR_SRC CONFIGURE_DEPENDS "./fileRegistrar/*.cpp" "./fileRegistrar/*.h")
add_executable (FileRegistrar ${FILEREGISTRAR_SRC})
target_compile_definitions (FileRegistrar PRIVATE
"PROJECT_VERSION_MAJOR=${PROJECT_VERSION_MAJOR}"
"PROJECT_VERSION_MINOR=${PROJECT_VERSION_MINOR}"
"PROJECT_VERSION_PATCH=${PROJECT_VERSION_PATCH}"
)
if (NOT MSVC)
target_compile_options (FileRegistrar PRIVATE -pthread)
if (NOT (("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang") AND WIN32))
target_compile_options (FileRegistrar PRIVATE -fPIE)
endif ()
if (${CMAKE_BUILD_TYPE} STREQUAL "Debug")
target_compile_options (FileRegistrar PRIVATE -g)
endif (${CMAKE_BUILD_TYPE} STREQUAL "Debug")
endif (NOT MSVC)
target_link_libraries (FileRegistrar PRIVATE juce-host-dev-kit::juce-core)
if (MSVC)
target_link_options (FileRegistrar PRIVATE /SUBSYSTEM:WINDOWS)
elseif (("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang") AND WIN32)
target_link_options (FileRegistrar PRIVATE -Xlinker /SUBSYSTEM:WINDOWS)
endif ()
set_target_properties (FileRegistrar PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${OUTPUT_DIR}")
# Main Target
file (GLOB_RECURSE VOCALSHAPER_SRC CONFIGURE_DEPENDS "./src/*.cpp" "./src/*.c" "./src/*.rc" "./src/*.hpp" "./src/*.h")
add_executable (VocalShaper ${VOCALSHAPER_SRC})
target_include_directories (VocalShaper PRIVATE ${LUA_INCLUDE_DIR} "./src")
target_compile_definitions (VocalShaper PRIVATE ${COMPILE_SYS_DEF})
target_compile_definitions (VocalShaper PRIVATE
"PROJECT_VERSION_MAJOR=${PROJECT_VERSION_MAJOR}"
"PROJECT_VERSION_MINOR=${PROJECT_VERSION_MINOR}"
"PROJECT_VERSION_PATCH=${PROJECT_VERSION_PATCH}"
)
target_link_libraries (VocalShaper PRIVATE
flowui::flowui
${LUA_LIBRARIES}
vsp4::vsp4
)
if (NOT MSVC)
target_compile_options (VocalShaper PRIVATE -pthread)
if (NOT (("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang") AND WIN32))
target_compile_options (VocalShaper PRIVATE -fPIE)
endif ()
if (${CMAKE_BUILD_TYPE} STREQUAL "Debug")
target_compile_options (VocalShaper PRIVATE -g)
endif (${CMAKE_BUILD_TYPE} STREQUAL "Debug")
endif (NOT MSVC)
target_link_libraries (VocalShaper PRIVATE juce-host-dev-kit::juce-full)
if (WIN32)
target_link_libraries (VocalShaper PRIVATE Dbghelp ntdll)
endif (WIN32)
if (MSVC)
target_link_options (VocalShaper PRIVATE /SUBSYSTEM:WINDOWS)
elseif (("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang") AND WIN32)
target_link_options (VocalShaper PRIVATE -Xlinker /SUBSYSTEM:WINDOWS)
endif ()
add_dependencies (VocalShaper
PluginSearcher FileRegistrar
app_config_copy remix_icon_copy engines_copy lame_copy
)
set_target_properties (VocalShaper PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${OUTPUT_DIR}")