-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
171 lines (135 loc) · 4.54 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
cmake_minimum_required (VERSION 3.20)
project (minaton
VERSION 0.2.0
LANGUAGES C CXX
)
add_subdirectory (dpf)
# Add our CMake extention module path
list (APPEND CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake")
#
# Manage dependencies
#
set (USE_SYSTEM_LIBSNDFILE OFF CACHE BOOL "Prefer system libsndfile (shared library). Otherwise build from source (static library)")
set (USE_SYSTEM_LIBSAMPLERATE OFF CACHE BOOL "Prefer system libsamplerate (shared library). Otherwise build from source (static library)")
if (USE_SYSTEM_LIBSNDFILE OR USE_SYSTEM_LIBSAMPLERATE)
find_package (PkgConfig REQUIRED)
endif ()
if (USE_SYSTEM_LIBSNDFILE)
pkg_check_modules (SNDFILE IMPORTED_TARGET REQUIRED sndfile)
if (SNDFILE_FOUND)
find_library (SNDFILE_LIBRARY NAMES ${SNDFILE_LIBRARIES} HINTS ${SNDFILE_LIBDIR})
endif ()
else ()
# Force build of static lib
set (BUILD_SHARED_LIBS OFF CACHE BOOL "")
# Disable external formats (FLAC, Opus, MPEG etc.), since we only decode WAV files
set (ENABLE_EXTERNAL_LIBS OFF CACHE BOOL "")
set (ENABLE_MPEG OFF CACHE BOOL "")
# Liten our builds
set (BUILD_EXAMPLES OFF CACHE BOOL "")
set (BUILD_PROGRAMS OFF CACHE BOOL "")
set (BUILD_REGTEST OFF CACHE BOOL "")
set (BUILD_TESTING OFF CACHE BOOL "")
set (ENABLE_BOW_DOCS OFF CACHE BOOL "")
set (ENABLE_CPACK OFF CACHE BOOL "")
add_subdirectory (vendor/libsndfile)
# Need this to fix linker errors around Glibc
target_compile_options (sndfile PRIVATE -fPIC)
include_directories (vendor/libsndfile/include)
endif ()
if (USE_SYSTEM_LIBSAMPLERATE)
pkg_check_modules (SAMPLERATE IMPORTED_TARGET REQUIRED samplerate)
if (SAMPLERATE_FOUND)
find_library (SAMPLERATE_LIBRARY NAMES ${SAMPLERATE_LIBRARIES} HINTS ${SAMPLERATE_LIBDIR})
endif ()
else ()
# Liten our builds
set (BUILD_TESTING OFF CACHE BOOL "")
set (LIBSAMPLERATE_EXAMPLES OFF CACHE BOOL "")
add_subdirectory (vendor/libsamplerate)
include_directories (vendor/libsamplerate/include)
endif ()
#
# Convert waves into C array
#
set (GENERATED_WAVES_DIR ${PROJECT_BINARY_DIR}/generated_waves)
make_directory (${GENERATED_WAVES_DIR})
# Binary-to-C converter from Dear ImGui
add_executable (binary_to_compressed_c utils/binary_to_compressed_c.cpp)
target_link_options (binary_to_compressed_c PRIVATE -static)
set (WAVES_DIR ${PROJECT_SOURCE_DIR}/src/waves)
set (GENERATED_WAVE_HEADER ${GENERATED_WAVES_DIR}/minaton_waves.hpp)
add_custom_command (
OUTPUT ${GENERATED_WAVE_HEADER}
COMMAND ${PROJECT_BINARY_DIR}/binary_to_compressed_c${CMAKE_EXECUTABLE_SUFFIX} ${WAVES_DIR} minaton_wave > ${GENERATED_WAVE_HEADER}
DEPENDS binary_to_compressed_c
VERBATIM
)
add_custom_target (generate_waves DEPENDS ${GENERATED_WAVE_HEADER})
#
# Build plug-ins
#
# Only build standalone (JACK) application on Linux
if (UNIX AND NOT APPLE)
set (BUILD_STANDALONE jack)
endif ()
dpf_add_plugin (${PROJECT_NAME}
TARGETS vst2 vst3 lv2 clap ${BUILD_STANDALONE}
UI_TYPE opengl
FILES_DSP
src/synth.cpp
src/synth_dpf.cpp
plugin/MinatonPlugin.cpp
plugin/MinatonProcess.cpp
plugin/MinatonParamAccess.cpp
vendor/resampler/resampler.cpp
FILES_UI
plugin/MinatonUI.cpp
plugin/MinatonUIHelper.cpp
plugin/MinatonArtwork.cpp
plugin/MinatonPresets.cpp
FILES_COMMON
plugin/MinatonParams.cpp
)
configure_file (plugin/config.h.in ${PROJECT_BINARY_DIR}/config.h)
target_include_directories (${PROJECT_NAME} PUBLIC
plugin/
src/
${GENERATED_WAVES_DIR}
vendor/resampler
${PROJECT_BINARY_DIR}
)
add_dependencies (${PROJECT_NAME}-dsp generate_waves)
if (USE_SYSTEM_LIBSNDFILE)
set (LINK_LIBSNDFILE PkgConfig::SNDFILE)
else ()
set (LINK_LIBSNDFILE sndfile)
endif ()
if (USE_SYSTEM_LIBSAMPLERATE)
set (LINK_LIBSAMPLERATE PkgConfig::SAMPLERATE)
else ()
set (LINK_LIBSAMPLERATE samplerate)
endif ()
target_link_libraries (${PROJECT_NAME} PRIVATE ${LINK_LIBSAMPLERATE} ${LINK_LIBSNDFILE})
#
# Convert factory patches into C array
# Should be included after dpf_add_plugin().
#
include (FactoryPresets)
#
# Context menu support
#
# Menu widget by Wolf Plugins (https://github.com/wolf-plugins/wolf-shaper)
set (WOLF_WIDGETS_SOURCE
ext/WolfWidgets/Margin.cpp
ext/WolfWidgets/WolfWidget.cpp
ext/WolfWidgets/MenuWidget.cpp
ext/WolfWidgets/Fonts/chivo_bold.cpp
)
target_sources (${PROJECT_NAME}-ui PRIVATE
${WOLF_WIDGETS_SOURCE}
plugin/MinatonUIMenu.cpp
)
target_include_directories (${PROJECT_NAME}-ui PRIVATE
ext/WolfWidgets
)