Repository navigation
Expand file tree
/
Copy pathCMakeLists.txt
More file actions
106 lines (96 loc) · 4.26 KB
/
Copy pathCMakeLists.txt
File metadata and controls
106 lines (96 loc) · 4.26 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
# char-spectrogram: a scrolling spectrogram made only of chardraw's parts, from
# char-clap-template's libraries.
#
# cmake -B build && cmake --build build CLAP, VST3, AU (macOS), standalone
# WCLAP: see README.md for the one extra flag (the WASI SDK toolchain).
cmake_minimum_required(VERSION 3.28)
# macOS plugins here are universal (Apple silicon and Intel).
if(CMAKE_HOST_APPLE AND NOT CMAKE_SYSTEM_NAME AND NOT DEFINED CMAKE_OSX_ARCHITECTURES)
set(CMAKE_OSX_ARCHITECTURES "arm64;x86_64")
endif()
project(CharSpectrogram VERSION 0.2.0 LANGUAGES C CXX)
if(APPLE)
enable_language(OBJC OBJCXX)
endif()
if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
set(CMAKE_BUILD_TYPE Release)
endif()
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON) # build/compile_commands.json, where clangd finds the downloaded headers
if(MSVC) # clap-wrapper and the VST3 SDK use the DLL runtime (/MD)
set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>DLL")
endif()
if(CMAKE_SYSTEM_NAME STREQUAL "Linux") # VST3 modules link static libraries
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
endif()
# The libraries (libs/) come from char-clap-template, pinned to a release. To
# build against a local checkout instead, configure with
# -DFETCHCONTENT_SOURCE_DIR_CLAP_TEMPLATE=<path>.
include(FetchContent)
FetchContent_Declare(clap_template
GIT_REPOSITORY https://github.com/charCulbert/char-clap-template.git
GIT_TAG v0.4.0
GIT_SHALLOW TRUE
SOURCE_SUBDIR none)
FetchContent_MakeAvailable(clap_template)
set(LIBS "${clap_template_SOURCE_DIR}/libs")
include(${LIBS}/gpu/gpu.cmake)
include(${LIBS}/chardraw/chardraw.cmake)
include(signalsmith-dsp.cmake)
# chardsp_ConstantQ.h follows CiCueTea (MIT): its licence ships with the others.
set_property(GLOBAL APPEND PROPERTY CORE_THIRD_PARTY_LICENSES "cicuetea=${CMAKE_CURRENT_SOURCE_DIR}/licenses/CiCueTea.txt")
# WCLAP builds this file a second time with Emscripten, for the page the host shows.
if(GPU_PAGE)
gpu_add_page(page ASSETS resources) # the font, built into the page
chardraw_add_to(page)
target_sources(page PRIVATE ui/SpectrogramView.cpp)
return()
endif()
include(${LIBS}/core/core.cmake)
add_library(CharSpectrogram_impl STATIC plugin.cpp)
target_compile_definitions(CharSpectrogram_impl PRIVATE PLUGIN_VERSION="${PROJECT_VERSION}")
target_include_directories(CharSpectrogram_impl SYSTEM PRIVATE ${SIGNALSMITH_DSP_INCLUDE})
core_add_to(CharSpectrogram_impl)
gpu_add_to(CharSpectrogram_impl)
if(NOT CMAKE_SYSTEM_NAME STREQUAL "WASI")
chardraw_add_to(CharSpectrogram_impl)
target_sources(CharSpectrogram_impl PRIVATE ui/SpectrogramView.cpp)
endif()
set(formats CLAP VST3)
if(APPLE)
list(APPEND formats AUV2)
endif()
if(CMAKE_SYSTEM_NAME STREQUAL "WASI")
set(formats WCLAP)
endif()
make_clapfirst_plugins(
TARGET_NAME CharSpectrogram
IMPL_TARGET CharSpectrogram_impl
ENTRY_SOURCE "${CMAKE_CURRENT_SOURCE_DIR}/entry.cpp"
OUTPUT_NAME "char-spectrogram"
BUNDLE_IDENTIFIER "com.charlieculbert.char-spectrogram"
BUNDLE_VERSION "${PROJECT_VERSION}"
AUV2_MANUFACTURER_NAME "Charlie Culbert"
AUV2_MANUFACTURER_CODE "ChAr"
AUV2_SUBTYPE_CODE "ChSg"
AUV2_INSTRUMENT_TYPE "aufx"
PLUGIN_FORMATS ${formats}
WINDOWS_FOLDER_VST3 TRUE # a folder, so its resources can travel inside it
STANDALONE_CONFIGURATIONS standalone "char-spectrogram" "com.charlieculbert.char-spectrogram"
COPY_AFTER_BUILD FALSE)
# resources/ (its font) ships inside each plugin. The WCLAP adds page/: the
# interface built with Emscripten, which the host shows.
if(CMAKE_SYSTEM_NAME STREQUAL "WASI")
gpu_wclap_resources(resources CharSpectrogram resources)
core_ship_resources(CharSpectrogram "${resources}" DEPENDS CharSpectrogram_resources)
else()
core_ship_resources(CharSpectrogram "${CMAKE_CURRENT_SOURCE_DIR}/resources")
endif()
enable_testing()
if(NOT CMAKE_SYSTEM_NAME STREQUAL "WASI")
add_executable(spectrogram-tests tests/spectrogram_test.cpp)
target_include_directories(spectrogram-tests SYSTEM PRIVATE ${SIGNALSMITH_DSP_INCLUDE})
target_compile_options(spectrogram-tests PRIVATE $<IF:$<CXX_COMPILER_ID:MSVC>,/UNDEBUG,-UNDEBUG>) # the tests are assert()s
add_test(NAME spectrogram COMMAND spectrogram-tests)
endif()