-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCMakeLists.txt
More file actions
215 lines (188 loc) · 7.5 KB
/
CMakeLists.txt
File metadata and controls
215 lines (188 loc) · 7.5 KB
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
cmake_minimum_required(VERSION 3.22.1)
# ----------------------------------------
# 插件信息,改了记得改src/global.hpp
# ----------------------------------------
set(TEAM_NAME ManasWolrd)
set(PLUGIN_REPO_URL "https://github.com/ManasWolrd/plugin-template")
set(PLUGIN_NAME plugin-template)
set(PLUGIN_VERSION 0.0.1)
set(PLUGIN_BUNDLE_ID "com.ManasWolrd.${PLUGIN_NAME}")
option(BUILD_STANDALONE "Build Standalone plugin format" ON)
option(BUILD_VST3 "Build VST3 plugin format" ON)
option(BUILD_LV2 "Build LV2 plugin format" ON)
# cmake设置
set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>" CACHE STRING "Runtime Library")
set(CMAKE_OSX_DEPLOYMENT_TARGET 10.13 CACHE STRING "Build for 10.13")
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
project(${PLUGIN_NAME} VERSION ${PLUGIN_VERSION})
add_compile_definitions(PROJECT_VERSION="${PROJECT_VERSION}")
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_XCODE_GENERATE_SCHEME OFF)
set_property(GLOBAL PROPERTY USE_FOLDERS ON)
string(SUBSTRING plugin_codes ${PLUGIN_NAME} 0 4)
string(SUBSTRING plugin_manufacturer_code ${TEAM_NAME} 0 4)
add_subdirectory(libs/JUCE)
set(plugin_formats AU)
if(BUILD_STANDALONE)
list(APPEND plugin_formats Standalone)
endif()
if(BUILD_VST3)
list(APPEND plugin_formats VST3)
endif()
if (BUILD_LV2 AND UNIX AND NOT APPLE)
list(APPEND plugin_formats LV2)
endif()
# ----------------------------------------
# 插件信息在这里也可以设置
# ----------------------------------------
juce_add_plugin(${PROJECT_NAME}
COMPANY_NAME ${TEAM_NAME}
IS_SYNTH FALSE
NEEDS_MIDI_INPUT False
NEEDS_MIDI_OUTPUT false
IS_MIDI_EFFECT FALSE
EDITOR_WANTS_KEYBOARD_FOCUS FALSE
JUCE_VST3_CAN_REPLACE_VST2 FALSE
COPY_PLUGIN_AFTER_BUILD FALSE
PLUGIN_MANUFACTURER_CODE ${plugin_manufacturer_code}
PLUGIN_CODE ${plugin_codes}
FORMATS ${plugin_formats}
PRODUCT_NAME ${PLUGIN_NAME}
BUNDLE_ID ${PLUGIN_BUNDLE_ID}
LV2URI ${PLUGIN_REPO_URL}
)
# 添加源文件
target_sources(${PROJECT_NAME}
PRIVATE
# src/dsp/dsp_lane4_template.cpp
src/dsp/dsp_dispatch.cpp
src/ui/plugin_ui.cpp
src/PluginEditor.cpp
src/PluginProcessor.cpp
)
### simd dispatch
if(APPLE)
target_sources(${PROJECT_NAME}
PRIVATE
src/dsp/dsp_neon.cpp
src/dsp/dsp_avx2.cpp
src/dsp/dsp_avx.cpp
src/dsp/dsp_sse4.cpp
src/dsp/dsp_sse2.cpp
src/dsp/dsp_avx2_fma.cpp
)
set_source_files_properties("src/dsp/dsp_neon.cpp" PROPERTIES COMPILE_FLAGS "-arch arm64 -ffast-math -Wno-nan-infinity-disabled")
set_source_files_properties("src/dsp/dsp_sse2.cpp" PROPERTIES COMPILE_FLAGS "-arch x86_64 -msse2 -ffast-math -Wno-nan-infinity-disabled")
set_source_files_properties("src/dsp/dsp_sse4.cpp" PROPERTIES COMPILE_FLAGS "-arch x86_64 -msse4.1 -ffast-math -Wno-nan-infinity-disabled")
set_source_files_properties("src/dsp/dsp_avx.cpp" PROPERTIES COMPILE_FLAGS "-arch x86_64 -mavx -ffast-math -Wno-nan-infinity-disabled")
set_source_files_properties("src/dsp/dsp_avx2.cpp" PROPERTIES COMPILE_FLAGS "-arch x86_64 -mavx2 -ffast-math -Wno-nan-infinity-disabled")
set_source_files_properties("src/dsp/dsp_avx2_fma.cpp" PROPERTIES COMPILE_FLAGS "-arch x86_64 -mavx2 -mfma -ffast-math -Wno-nan-infinity-disabled")
else()
target_sources(${PROJECT_NAME}
PRIVATE
src/dsp/dsp_avx2_fma.cpp
src/dsp/dsp_avx2.cpp
src/dsp/dsp_avx.cpp
src/dsp/dsp_sse4.cpp
src/dsp/dsp_sse2.cpp
)
set_source_files_properties("src/dsp/dsp_sse2.cpp" PROPERTIES COMPILE_FLAGS "-msse2 -ffast-math -Wno-nan-infinity-disabled")
set_source_files_properties("src/dsp/dsp_sse4.cpp" PROPERTIES COMPILE_FLAGS "-msse4.1 -ffast-math -Wno-nan-infinity-disabled")
set_source_files_properties("src/dsp/dsp_avx.cpp" PROPERTIES COMPILE_FLAGS "-mavx -ffast-math -Wno-nan-infinity-disabled")
set_source_files_properties("src/dsp/dsp_avx2.cpp" PROPERTIES COMPILE_FLAGS "-mavx2 -ffast-math -Wno-nan-infinity-disabled")
set_source_files_properties("src/dsp/dsp_avx2_fma.cpp" PROPERTIES COMPILE_FLAGS "-mavx2 -mfma -ffast-math -Wno-nan-infinity-disabled")
endif()
# 头文件目录
target_include_directories(${PROJECT_NAME}
PUBLIC
"${CMAKE_CURRENT_SOURCE_DIR}/src"
)
# juce编译选项
target_compile_definitions(${PROJECT_NAME}
PUBLIC
JUCE_WEB_BROWSER=0
JUCE_USE_CURL=0
JUCE_VST3_CAN_REPLACE_VST2=0
)
# 要用 #include <juce.h> 去掉这个注释
# juce_generate_juce_header(${PROJECT_NAME})
target_link_libraries(${PROJECT_NAME}
PRIVATE
juce::juce_dsp
juce::juce_core
juce::juce_graphics
juce::juce_gui_basics
juce::juce_audio_utils
PUBLIC
juce::juce_recommended_config_flags
juce::juce_recommended_lto_flags
juce::juce_recommended_warning_flags
)
# 添加资源
file(GLOB_RECURSE res "${CMAKE_CURRENT_SOURCE_DIR}/resources/*.*")
if (NOT "${res}" STREQUAL "")
juce_add_binary_data(${PROJECT_NAME}_res SOURCES ${res})
target_link_libraries(${PROJECT_NAME} PRIVATE ${PROJECT_NAME}_res)
endif()
if(APPLE)
target_compile_definitions(${PROJECT_NAME} PUBLIC JUCE_AU=1)
endif()
# ----------------------------------------
# audiofft
# ----------------------------------------
add_library(audiofft STATIC libs/AudioFFT/AudioFFT.cpp libs/AudioFFT/AudioFFTcpx.cpp)
target_include_directories(audiofft PUBLIC libs/AudioFFT)
target_link_libraries(${PROJECT_NAME} PRIVATE audiofft)
# fft lib for audio fft
if(APPLE)
# use vDSP
target_link_libraries(audiofft PRIVATE "-framework Accelerate")
target_compile_definitions(audiofft PRIVATE AUDIOFFT_APPLE_ACCELERATE)
else()
find_package(IPP QUIET)
if(NOT IPP_FOUND)
# use CI Intel IPP
if(WIN32)
set(IPP_ROOT "$ENV{USERPROFILE}/.nuget/packages/intelipp.static.win-x64/2022.3.0.387")
set(IPP_INC "${IPP_ROOT}/build/native/include/ipp")
set(IPP_LIB "${IPP_ROOT}/build/native/win-x64/")
set(IPP_LIBS ippsmt ippcoremt ippimt ippcvmt ippvmmt)
elseif(UNIX)
set(IPP_ROOT "/opt/intel/oneapi/ipp/latest")
set(IPP_INC "${IPP_ROOT}/include")
set(IPP_LIB "${IPP_ROOT}/lib")
set(IPP_LIBS ipps ippcore ippi ippcv ippvm)
endif()
if(EXISTS "${IPP_INC}")
set(IPP_FOUND TRUE)
endif()
if(IPP_FOUND)
message(STATUS "AudioFFT: Using Intel IPP")
target_include_directories(audiofft PRIVATE ${IPP_INC})
target_link_directories(audiofft PUBLIC ${IPP_LIB})
target_link_libraries(audiofft PUBLIC ${IPP_LIBS})
target_compile_definitions(audiofft PRIVATE AUDIOFFT_INTEL_IPP)
else()
message(WARNING "AudioFFT: IPP not found, using default Ooura implementation")
endif()
else()
# use IPP on developer's pc
target_link_libraries(audiofft PUBLIC ${IPP_LIBRARIES})
target_compile_definitions(audiofft PRIVATE AUDIOFFT_INTEL_IPP)
endif()
endif()
if(DEFINED DBUILD_IN_CI)
target_compile_definitions(${PROJECT_NAME} PRIVATE DBUILD_IN_CI=1)
endif()
# ----------------------------------------
# cpp_simd_detector
# ----------------------------------------
set(CPP_SIMD_DETECTOR_BUILD_EXAMPLES OFF)
add_subdirectory(libs/cpp_simd_detector)
target_link_libraries(${PROJECT_NAME} PUBLIC cpp_simd_detector)
# ----------------------------------------
# simde
# ----------------------------------------
add_library(simde INTERFACE)
target_include_directories(simde INTERFACE libs/simde)
target_link_libraries(${PROJECT_NAME} PUBLIC simde)