-
Notifications
You must be signed in to change notification settings - Fork 20
/
CMakeLists.txt
154 lines (139 loc) · 6.03 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
#
# clap-wrapper project
#
# Copyright (c) 2022-2024 Timo Kaluza (defiantnerd)
# Paul Walker (baconpaul)
#
# There are a variety of advanced options to configure and build this wrapper, but
# for the simple case of single plugin in a single clap, here are some relevant
# cmake-time options which this wrapper will use. See the documentation for a more
# complete description
#
# CLAP_SDK_ROOT The location of the clap library. Defaults to ../clap
# VST3_SDK_ROOT The location of the VST3 sdk. Defaults tp ../vst3sdk
#
# CLAP_WRAPPER_OUTPUT_NAME The name of the resulting .vst3 or .component
# CLAP_SUPPORTS_ALL_NOTE_EXPRESSIONS The wrapper will forward all VST3 note expressions to your CLAP
# CLAP_VST3_TUID_STRING The VST3 component ::iid as a string; absent this wrapper hashes clap id
# CLAP_WRAPPER_BUNDLE_IDENTIFIER the macOS Bundle Identifier. Absent this it is 'org.cleveraudio.wrapper.(name)'
# CLAP_WRAPPER_BUNDLE_VERSION the macOS Bundle Version. Defaults to 1.0
# CLAP_WRAPPER_WINDOWS_SINGLE_FILE if set to TRUE (default) the windows .vst3 is a single file; false a 3.7 spec folder
# CLAP_WRAPPER_DOWNLOAD_DEPENDENCIES if set will download the needed SDKs using CPM from github
# CLAP_WRAPPER_DONT_ADD_TARGETS if included in a CMakeList above skip adding targets
# CLAP_WRAPPER_COPY_AFTER_BUILD if included mac and lin will copy to ~/... (lin t/k)
cmake_minimum_required(VERSION 3.21)
cmake_policy(SET CMP0091 NEW)
cmake_policy(SET CMP0149 NEW)
if (NOT DEFINED CMAKE_OSX_DEPLOYMENT_TARGET)
message(STATUS "[clap-wrapper]: OSX_DEPLOYEMNT_TARGET is undefined. Setting to 10.13")
set(CMAKE_OSX_DEPLOYMENT_TARGET 10.13 CACHE STRING "Minimum macOS version")
endif()
if (NOT DEFINED CMAKE_OSX_ARCHITECTURES)
message(STATUS "[clap-wrapper]: CMAKE_OSX_ARCHITECTURES is not set. Using native build for clap wrapper")
endif()
if (NOT DEFINED CMAKE_MSVC_RUNTIME_LIBRARY)
if (WIN32)
message(STATUS "CMAKE_MSVC_RUNTIME_LIBRARY not defined. Setting to static link")
endif()
set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>") # Statically link the MSVC Runtime
endif()
set(CMAKE_COLOR_DIAGNOSTICS ON)
# If your clap supports note expressions you *can* implement the wrapper extension here or you
# can just build with this turned on and it will forward all note expressions to your CLAP
option(CLAP_SUPPORTS_ALL_NOTE_EXPRESSIONS "Does the underlying CLAP support note expressions" OFF)
option(CLAP_WRAPPER_WINDOWS_SINGLE_FILE "Build a single fine (rather than folder) on windows" ON)
option(CLAP_WRAPPER_BUILD_TESTS "Build test CLAP wrappers" OFF)
project(clap-wrapper
LANGUAGES C CXX
VERSION 0.11.0
DESCRIPTION "CLAP-as-X wrappers"
)
set(CLAP_WRAPPER_VERSION "${PROJECT_VERSION}" CACHE STRING "Version of the wrapper project")
message(STATUS "clap-wrapper: CLAP_WRAPPER_VERSION is ${CLAP_WRAPPER_VERSION}")
if (APPLE)
enable_language(OBJC)
enable_language(OBJCXX)
endif()
if (PROJECT_IS_TOP_LEVEL)
if (DEFINED CLAP_WRAPPER_CXX_STANDARD)
set(CMAKE_CXX_STANDARD ${CLAP_WRAPPER_CXX_STANDARD})
else()
if (NOT DEFINED CMAKE_CXX_STANDARD)
set(CMAKE_CXX_STANDARD 17)
elseif ( ${CMAKE_CXX_STANDARD} VERSION_LESS 17)
message(WARNING "CMAKE_CXX_STANDARD of ${CMAKE_CXX_STANDARD} < 17 not well tested")
endif()
endif()
endif()
message(STATUS "clap-wrapper: Building with C++ standard ${CMAKE_CXX_STANDARD}")
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
set(CMAKE_CXX_VISIBILITY_PRESET hidden)
set(CMAKE_OBJC_VISIBILITY_PRESET hidden)
set(CMAKE_OBJCXX_VISIBILITY_PRESET hidden)
set(CMAKE_VISIBILITY_INLINES_HIDDEN ON)
# discover the plugin paths and enable them. The library
# defines functions relative to this, so needs a cache
# variable with the source dir
set(CLAP_WRAPPER_CMAKE_CURRENT_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR} CACHE STRING "Clap Wrapper Source Location")
if (DEFINED CLAP_WRAPPER_CODE_CHECKS_ONLY)
message(STATUS "clap-wrapper: code checks only; skipping wrapper functions")
else()
include(cmake/wrapper_functions.cmake)
endif()
# automatically build the wrapper only if this is the top level project
set(skipbuild FALSE)
if (NOT PROJECT_IS_TOP_LEVEL)
if(DEFINED CLAP_WRAPPER_DONT_ADD_TARGETS)
set(skipbuild TRUE)
endif()
endif()
if (DEFINED CLAP_WRAPPER_CODE_CHECKS_ONLY)
set(skipbuild ${CLAP_WRAPPER_CODE_CHECKS_ONLY})
endif()
if (${skipbuild})
message(STATUS "clap-wrapper: Skipping clap wrapper target ejection")
else()
# provide the CLAP_WRAPPER_OUTPUT_NAME to specify the matching plugin name.
if((NOT CLAP_WRAPPER_OUTPUT_NAME ) OR (CLAP_WRAPPER_OUTPUT_NAME STREQUAL ""))
set(CLAP_WRAPPER_OUTPUT_NAME "clapasvst3")
message(WARNING "clap-wrapper: CLAP_WRAPPER_OUTPUT_NAME not set - continuing with a default name `clapasvst3`")
endif()
string(MAKE_C_IDENTIFIER ${CLAP_WRAPPER_OUTPUT_NAME} pluginname)
# Link the actual plugin library
add_library(${pluginname}_as_vst3 MODULE)
target_add_vst3_wrapper(
TARGET ${pluginname}_as_vst3
OUTPUT_NAME "${CLAP_WRAPPER_OUTPUT_NAME}"
SUPPORTS_ALL_NOTE_EXPRESSIONS $<BOOL:${CLAP_SUPPORTS_ALL_NOTE_EXPRESSIONS}>
SINGLE_PLUGIN_TUID "${CLAP_VST3_TUID_STRING}"
BUNDLE_IDENTIFIER "${CLAP_WRAPPER_BUNDLE_IDENTIFIER}"
BUNDLE_VERSION "${CLAP_WRAPPER_BUNDLE_VERSION}"
)
if (APPLE)
if (${CLAP_WRAPPER_BUILD_AUV2})
add_library(${pluginname}_as_auv2 MODULE)
target_add_auv2_wrapper(
TARGET ${pluginname}_as_auv2
OUTPUT_NAME "${CLAP_WRAPPER_OUTPUT_NAME}"
BUNDLE_IDENTIFIER "${CLAP_WRAPPER_BUNDLE_IDENTIFIER}"
BUNDLE_VERSION "${CLAP_WRAPPER_BUNDLE_VERSION}"
# AUv2 is still a work in progress. For now make this an
# explict option to the single plugin version
INSTRUMENT_TYPE "aumu"
MANUFACTURER_NAME "cleveraudio.org"
MANUFACTURER_CODE "clAd"
SUBTYPE_CODE "gWrp"
)
endif()
endif()
if (${CLAP_WRAPPER_BUILD_STANDALONE})
add_executable(${pluginname}_as_standalone)
target_add_standalone_wrapper(TARGET ${pluginname}_as_standalone
OUTPUT_NAME ${CLAP_WRAPPER_OUTPUT_NAME}
HOSTED_CLAP_NAME ${CLAP_WRAPPER_OUTPUT_NAME}
PLUGIN_INDEX 0)
endif()
endif()
if (${CLAP_WRAPPER_BUILD_TESTS})
add_subdirectory(tests)
endif()