-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathCMakeLists.txt
195 lines (165 loc) · 6.68 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
cmake_minimum_required(VERSION 3.11)
project(Formula VERSION 1.2.1 LANGUAGES CXX)
set(CMAKE_INCLUDE_CURRENT_DIR ON)
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
# ==================================================================================================
# Set preprocessor directives for Formula
add_compile_definitions(FORMULA_VERSION="${CMAKE_PROJECT_VERSION}")
set(FORMULA_COMPILE_FORMATS "AU" "VST3")
if(FORMULA_STANDALONE)
list (APPEND FORMULA_COMPILE_FORMATS "Standalone")
endif()
# ==================================================================================================
# Configure dependencies
add_compile_definitions(BOOST_BIND_GLOBAL_PLACEHOLDERS)
IF (WIN32)
# Force static linking and static CRT for cpprestsdk
add_compile_definitions(_NO_ASYNCRTIMP)
set(VCPKG_TARGET_TRIPLET x64-windows-static)
set(CMAKE_TOOLCHAIN_FILE ${CMAKE_CURRENT_SOURCE_DIR}/vcpkg/scripts/buildsystems/vcpkg.cmake)
set(VCPKG_WIN_DIR ${CMAKE_CURRENT_SOURCE_DIR}/vcpkg/installed/x64-windows-static)
IF (MSVC)
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /MT")
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /MTd")
ENDIF ()
set(Boost_USE_STATIC_RUNTIME ON)
set(Boost_USE_STATIC_LIBS ON)
ELSEIF (APPLE)
set(VCPKG_LIBRARY_LINKAGE static CACHE STRING "VCPKG_Library_Linkage")
set(Boost_USE_STATIC_LIBS ON)
add_compile_definitions(BOOST_NO_CXX98_FUNCTION_BASE)
ENDIF()
find_package(Boost 1.84.0 COMPONENTS REQUIRED filesystem date_time)
include_directories(Formula ${Boost_INCLUDE_DIR} SYSTEM)
find_package(cpprestsdk CONFIG REQUIRED)
add_compile_definitions(_TURN_OFF_PLATFORM_STRING)
# ==================================================================================================
# Configure JUCE
add_subdirectory(JUCE)
IF (FORMULA_VST2_SDK_DIR)
juce_set_vst2_sdk_path(${FORMULA_VST2_SDK_DIR})
list (APPEND FORMULA_COMPILE_FORMATS "VST")
ENDIF ()
juce_add_plugin(Formula
ICON_BIG assets/formula_icon.png
COMPANY_NAME Soundspear
IS_SYNTH FALSE
NEEDS_MIDI_INPUT FALSE
NEEDS_MIDI_OUTPUT FALSE
IS_MIDI_EFFECT FALSE
EDITOR_WANTS_KEYBOARD_FOCUS TRUE
COPY_PLUGIN_AFTER_BUILD FALSE
PLUGIN_MANUFACTURER_CODE Spea
PLUGIN_CODE Form
FORMATS "${FORMULA_COMPILE_FORMATS}"
VST2_CATEGORY kPlugCategEffect
VST3_CATEGORIES Fx Tools Network
AU_MAIN_TYPE kAudioUnitType_Effect
PRODUCT_NAME Formula)
# Embed all the Formulas from the 'formulas/' folder into an index readable by the app
include(packaging/generate_formulas_index.cmake)
set(community_formulas_directory "${CMAKE_SOURCE_DIR}/formulas")
set(community_index "${CMAKE_SOURCE_DIR}/assets/community_index.json")
generate_formulas_index(${community_formulas_directory} ${community_index})
juce_add_binary_data(FormulaBinaryData
NAMESPACE formula::binary
SOURCES
assets/build/libformula.h
assets/build/FormulaBaseMono.c
assets/build/FormulaBaseStereo.c
assets/default_index.json
assets/logo.svg
assets/icons/compile.svg
assets/icons/mute.svg
assets/icons/new.svg
assets/icons/pause.svg
assets/icons/save_local.svg
assets/icons/search.svg
assets/icons/show_debug.svg
assets/icons/show_knobs.svg
assets/icons/unmute.svg
assets/icons/unpause.svg
assets/icons/zoom_in.svg
assets/icons/zoom_out.svg
${community_index}
)
IF (UNIX)
set_target_properties(FormulaBinaryData PROPERTIES
POSITION_INDEPENDENT_CODE TRUE)
ENDIF()
add_compile_definitions(JUCE_MODAL_LOOPS_PERMITTED)
add_compile_definitions(JUCE_USE_MP3AUDIOFORMAT)
juce_generate_juce_header(Formula)
# ==================================================================================================
# Configure compiler
include_directories(Formula ${CMAKE_CURRENT_SOURCE_DIR}/src)
target_sources(Formula
PRIVATE
"src/http/GithubClient.cpp"
"src/compiler/TccWrapper.cpp"
"src/compiler/ClangWrapper.cpp"
"src/gui/PluginWindow.cpp"
"src/gui/FormulaCodeTokenizer.cpp"
"src/gui/tabs/FormulaListTabBase.cpp"
"src/gui/tabs/CodeEditorTab.cpp"
"src/gui/tabs/SavedFormulasTab.cpp"
"src/gui/tabs/CommunityFormulasTab.cpp"
"src/gui/tabs/SettingsTab.cpp"
"src/gui/components/popups/SaveLocalFormulaPopup.cpp"
"src/gui/components/popups/NoCompilerFoundPopup.cpp"
"src/gui/components/SpinnerOverlay.cpp"
"src/gui/components/FormulaCodeEditor.cpp"
"src/gui/components/FormulaDetailsPanel.cpp"
"src/gui/components/SearchBar.cpp"
"src/processor/FilePlayer.cpp"
"src/processor/library/FormulaLoader.cpp"
"src/processor/KnobsPanelListener.cpp"
"src/processor/PluginState.cpp"
"src/processor/PluginProcessor.cpp"
"src/compiler/CompilerWrapper.cpp"
"src/storage/LocalIndex.cpp"
"src/storage/CommunityIndex.cpp"
"src/storage/UserIndex.cpp"
"src/storage/LocalSettings.cpp"
"src/storage/CompilerStorage.cpp")
target_compile_definitions(Formula
PRIVATE
JUCE_WEB_BROWSER=0
JUCE_USE_CURL=0
JUCE_VST3_CAN_REPLACE_VST2=0
)
# ==================================================================================================
# Configure linker
target_link_libraries(Formula
PRIVATE
FormulaBinaryData
juce::juce_audio_utils
Boost::filesystem
Boost::date_time
cpprestsdk::cpprest
PUBLIC
juce::juce_recommended_config_flags
juce::juce_recommended_lto_flags
juce::juce_recommended_warning_flags)
IF (WIN32)
target_link_libraries(Formula PRIVATE
cpprestsdk::cpprestsdk_zlib_internal
cpprestsdk::cpprestsdk_brotli_internal
bcrypt.lib winhttp.lib crypt32.lib)
ELSEIF (UNIX)
target_link_libraries(Formula PRIVATE
OpenSSL::SSL)
ENDIF()
# ==================================================================================================
# Add a build step to generate the community Formulas index
add_custom_command(
OUTPUT ${community_index}
COMMAND ${CMAKE_COMMAND} -P "${CMAKE_SOURCE_DIR}/packaging/generate_formulas_index.cmake" ${community_formulas_directory} ${community_index}
DEPENDS ${community_formulas_directory}
COMMENT "Generating the community Formula index into ${community_index}"
)
# Build ordering IndexGeneration -> FormulaBinaryData -> Formula
add_custom_target(IndexGeneration ALL DEPENDS ${community_index} ${community_formulas_directory})
add_dependencies(FormulaBinaryData IndexGeneration)
# ==================================================================================================