This repository was archived by the owner on Oct 4, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathCMakeLists.txt
160 lines (142 loc) · 5.62 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
cmake_minimum_required(VERSION 3.14)
# You need to generate the AppConfig.h and the JuceHeader.h through the Projucer; the rest is more or less here
project(sfizz VERSION 1.0.0 LANGUAGES CXX)
# Change this if needed
if(UNIX)
set(JUCE_ROOT_DIR "~/source/JUCE")
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -DJUCE_DEBUG")
else()
set(JUCE_ROOT_DIR "C:/Users/paulf/source/JUCE")
endif()
set(ASIO_SDK "C:/Users/paulf/source/ASIOSDK2.3.3/common")
if (CMAKE_CXX_COMPILER_ID MATCHES "Clang" AND NOT ANDROID)
add_compile_options(-stdlib=libc++)
# Presumably need the above for linking too, maybe other options missing as well
add_link_options(-stdlib=libc++) # New command on CMake master, not in 3.12 release
endif()
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
# Set these to match the juce header file, modulo the audio plugin clients
set(JUCE_MODULES
juce_audio_basics
juce_audio_devices
juce_audio_formats
juce_audio_processors
juce_audio_utils
juce_dsp
juce_core
juce_data_structures
juce_events
juce_graphics
juce_gui_basics
juce_gui_extra
)
set(SOURCES
Source/SfzRegion.cpp
Source/SfzSynth.cpp
Source/SfzVoice.cpp
Source/PluginProcessor.cpp
Source/PluginEditor.cpp
)
set(TEST_SOURCES
Source/SfzRegion.cpp
Source/SfzSynth.cpp
Source/SfzVoice.cpp
Tests/TrimViewTests.cpp
Tests/CCEnvelopeTest.cpp
Tests/BlockEnvelopeTest.cpp
Tests/OpcodeTests.cpp
Tests/RegexTests.cpp
Tests/FileTests.cpp
Tests/RegionBuildTests.cpp
Tests/RegionActivationTests.cpp
Tests/RegionTriggers.cpp
Tests/Main.cpp
)
# Multicore win32
if(WIN32)
add_compile_options(/MP)
endif(WIN32)
if (UNIX)
find_package(Freetype REQUIRED)
find_package(ALSA REQUIRED)
find_package(X11 REQUIRED)
find_package(CURL REQUIRED)
find_package(Threads REQUIRED)
find_package(PkgConfig REQUIRED)
pkg_check_modules(deps REQUIRED IMPORTED_TARGET gtk+-3.0 glib-2.0 webkit2gtk-4.0 jack)
endif()
# Juce modules as library targets
set(JUCE_MODULES_DIR "${JUCE_ROOT_DIR}/modules")
set(JUCE_STANDALONE_SOURCES ${JUCE_MODULES_DIR}/juce_audio_plugin_client/juce_audio_plugin_client_Standalone.cpp ${JUCE_MODULES_DIR}/juce_audio_plugin_client/juce_audio_plugin_client_utils.cpp)
set(JUCE_VST3_SOURCES ${JUCE_MODULES_DIR}/juce_audio_plugin_client/juce_audio_plugin_client_VST3.cpp ${JUCE_MODULES_DIR}/juce_audio_plugin_client/juce_audio_plugin_client_utils.cpp)
add_library(JUCE)
# Add sources
foreach(module ${JUCE_MODULES})
target_sources(JUCE PRIVATE ${JUCE_MODULES_DIR}/${module}/${module}.cpp)
endforeach()
# JUCE includes
target_include_directories(JUCE PUBLIC SYSTEM ${JUCE_MODULES_DIR})
target_include_directories(JUCE PUBLIC JuceLibraryCode)
target_include_directories(JUCE PUBLIC ${JUCE_MODULES_DIR}/juce_audio_processors/format_types/VST3_SDK)
# Compile features
target_compile_features(JUCE PRIVATE cxx_std_17)
if (UNIX)
target_link_libraries(JUCE ALSA::ALSA Freetype::Freetype X11::X11 X11::Xext X11::Xinerama CURL::libcurl PkgConfig::deps ${CMAKE_DL_LIBS})
# Force include the app config
target_compile_options(JUCE PUBLIC -include "AppConfig.h")
target_compile_options(JUCE PRIVATE -fPIC)
endif()
if(MSVC)
# Force include the app config
target_compile_options(JUCE PUBLIC /FI AppConfig.h)
target_compile_options(JUCE PUBLIC /DJUCE_ASIO)
target_include_directories(JUCE PRIVATE SYSTEM ${ASIO_SDK})
endif(MSVC)
###############################
# Standalone plugin application
add_executable(${PROJECT_NAME}_Standalone ${SOURCES} ${JUCE_STANDALONE_SOURCES})
# Per OS properties
if(WIN32)
set_target_properties(${PROJECT_NAME}_Standalone PROPERTIES WIN32_EXECUTABLE True)
# Required only for Range v3
target_compile_options(${PROJECT_NAME}_Standalone PRIVATE /permissive-)
endif(WIN32)
if(UNIX)
target_link_libraries(${PROJECT_NAME}_Standalone ${CMAKE_DL_LIBS} Threads::Threads stdc++fs)
endif(UNIX)
set_target_properties(${PROJECT_NAME}_Standalone PROPERTIES OUTPUT_NAME "sfizz")
target_link_libraries(${PROJECT_NAME}_Standalone JUCE)
target_include_directories(${PROJECT_NAME}_Standalone SYSTEM PRIVATE Includes)
target_compile_features(${PROJECT_NAME}_Standalone PRIVATE cxx_std_17)
###############################
# Test application (No WIN32 here, we want the main entry point and not WinMain)
add_executable(${PROJECT_NAME}_Test ${TEST_SOURCES})
# Per OS properties
if(UNIX)
target_link_libraries(${PROJECT_NAME}_Test ${CMAKE_DL_LIBS} Threads::Threads stdc++fs)
endif(UNIX)
if(WIN32)
# Required only for Range v3
target_compile_options(${PROJECT_NAME}_Test PRIVATE /permissive-)
endif(WIN32)
target_compile_definitions(${PROJECT_NAME}_Test PRIVATE JUCE_STANDALONE_APPLICATION=1)
set_target_properties(${PROJECT_NAME}_Test PROPERTIES OUTPUT_NAME "sfizz_Tests")
target_link_libraries(${PROJECT_NAME}_Test JUCE)
target_include_directories(${PROJECT_NAME}_Test SYSTEM PRIVATE Includes)
target_compile_features(${PROJECT_NAME}_Test PRIVATE cxx_std_17)
file(COPY "Tests" DESTINATION ${CMAKE_BINARY_DIR})
###############################
# VST3 library
add_library(${PROJECT_NAME}_VST SHARED ${SOURCES} ${JUCE_VST3_SOURCES})
if(WIN32)
# Required only for Range v3
target_compile_options(${PROJECT_NAME}_VST PRIVATE /permissive-)
endif(WIN32)
if(UNIX)
target_link_libraries(${PROJECT_NAME}_Test ${CMAKE_DL_LIBS} Threads::Threads stdc++fs)
endif(UNIX)
set_target_properties(${PROJECT_NAME}_VST PROPERTIES OUTPUT_NAME "sfizz")
set_target_properties(${PROJECT_NAME}_VST PROPERTIES SUFFIX ".vst3")
target_link_libraries(${PROJECT_NAME}_VST JUCE)
target_include_directories(${PROJECT_NAME}_VST SYSTEM PRIVATE Includes)
target_compile_features(${PROJECT_NAME}_VST PRIVATE cxx_std_17)