-
Notifications
You must be signed in to change notification settings - Fork 8
/
CMakeLists.txt
114 lines (97 loc) · 4.58 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
cmake_minimum_required(VERSION 3.15)
set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>")
set(CMAKE_OSX_DEPLOYMENT_TARGET 10.11 CACHE STRING "Build for 10.1")
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
if(NOT CMAKE_BUILD_TYPE)
message(STATUS "CMAKE_BUILD_TYPE Type Unspecified; picking Release")
set(CMAKE_BUILD_TYPE "Release" CACHE STRING "" FORCE)
endif()
project(clap-saw-demo VERSION 0.9.0 LANGUAGES C CXX)
set(CMAKE_CXX_EXTENSIONS OFF)
set(CMAKE_CXX_STANDARD 17)
# use asan as an option (currently mac only)
option(USE_SANITIZER "Build and link with ASAN" FALSE)
option(CSD_INCLUDE_GUI "Include a GUI in ClapSawDemo" TRUE)
# Copy on mac (could expand to other platforms)
option(COPY_AFTER_BUILD "Copy the clap to ~/Library on MACOS, ~/.clap on linux" FALSE)
add_subdirectory(libs/clap EXCLUDE_FROM_ALL)
add_subdirectory(libs/clap-helpers EXCLUDE_FROM_ALL)
add_subdirectory(libs/readerwriterqueue EXCLUDE_FROM_ALL)
if (${CSD_INCLUDE_GUI})
message(STATUS "Including VSTGUI")
add_subdirectory(libs/vstgui EXCLUDE_FROM_ALL)
else()
message(STATUS "GUI Bypassed. headless CSD generated")
endif()
if (APPLE AND ${CSD_INCLUDE_GUI})
target_compile_options(vstgui PRIVATE -Wno-deprecated-declarations)
endif()
add_library(${PROJECT_NAME} MODULE
src/clap-saw-demo.cpp
src/saw-voice.cpp
src/clap-saw-demo-pluginentry.cpp
)
target_link_libraries(${PROJECT_NAME} clap-core clap-helpers readerwriterqueue)
if (${CSD_INCLUDE_GUI})
target_sources(${PROJECT_NAME} PRIVATE
src/clap-saw-demo-editor.cpp
src/linux-vstgui-adapter.cpp src/linux-vstgui-adapter.h)
target_link_libraries(${PROJECT_NAME} vstgui)
else()
message(STATUS "Skipping GUI generation")
endif()
if (${CSD_INCLUDE_GUI})
# VSTGUI doesn't include the include paths and compile definitions in the library
# targets like other CMake libraries do, so explicitly include them here
target_include_directories(${PROJECT_NAME} PUBLIC libs/vstgui)
target_compile_definitions(${PROJECT_NAME} PRIVATE HAS_GUI=1 ${VSTGUI_COMPILE_DEFINITIONS})
endif()
if(APPLE)
set_target_properties(${PROJECT_NAME} PROPERTIES
BUNDLE True
BUNDLE_EXTENSION clap
MACOSX_BUNDLE_GUI_IDENTIFIER org.surge-synth-team.${PROJECT_NAME}
MACOSX_BUNDLE_BUNDLE_NAME ${PROJECT_NAME}
MACOSX_BUNDLE_BUNDLE_VERSION "0.1"
MACOSX_BUNDLE_SHORT_VERSION_STRING "0.1"
MACOSX_BUNDLE_INFO_PLIST ${CMAKE_SOURCE_DIR}/cmake/${PROJECT_NAME}.plist.in
)
target_link_libraries(${PROJECT_NAME} "-framework CoreFoundation" "-framework AppKit" "-framework CoreGraphics")
target_compile_definitions(${PROJECT_NAME} PRIVATE IS_MAC=1)
target_compile_options(${PROJECT_NAME} PRIVATE
-Werror
$<$<BOOL:${USE_SANITIZER}>:-fsanitize=address>
$<$<BOOL:${USE_SANITIZER}>:-fsanitize=undefined>
)
target_link_options(${PROJECT_NAME} PRIVATE
$<$<BOOL:${USE_SANITIZER}>:-fsanitize=address>
$<$<BOOL:${USE_SANITIZER}>:-fsanitize=undefined>
)
if (${COPY_AFTER_BUILD})
message(STATUS "Will copy plugin after every build" )
set(products_folder ${CMAKE_BINARY_DIR})
add_custom_command(TARGET ${PROJECT_NAME} POST_BUILD
COMMAND ${CMAKE_COMMAND} -E echo "Installing ${products_folder}/${PROJECT_NAME}.clap to ~/Library/Audio/Plug-Ins/CLAP/"
COMMAND ${CMAKE_COMMAND} -E make_directory "~/Library/Audio/Plug-Ins/CLAP"
COMMAND ${CMAKE_COMMAND} -E copy_directory "${products_folder}/${PROJECT_NAME}.clap" "~/Library/Audio/Plug-Ins/CLAP/${PROJECT_NAME}.clap"
)
endif()
elseif(UNIX)
target_compile_definitions(${PROJECT_NAME} PRIVATE IS_LINUX=1)
if (${CSD_INCLUDE_GUI})
target_sources(${PROJECT_NAME} PRIVATE src/linux-vstgui-adapter.cpp)
endif()
set_target_properties(${PROJECT_NAME} PROPERTIES SUFFIX ".clap" PREFIX "")
if (${COPY_AFTER_BUILD})
message(STATUS "Will copy plugin after every build" )
set(products_folder ${CMAKE_BINARY_DIR})
add_custom_command(TARGET ${PROJECT_NAME} POST_BUILD
COMMAND ${CMAKE_COMMAND} -E echo "Installing ${products_folder}/${PROJECT_NAME}.clap to ~/.clap"
COMMAND ${CMAKE_COMMAND} -E make_directory "~/.clap"
COMMAND ${CMAKE_COMMAND} -E copy "${products_folder}/${PROJECT_NAME}.clap" "~/.clap"
)
endif()
else()
target_compile_definitions(${PROJECT_NAME} PRIVATE IS_WIN=1)
set_target_properties(${PROJECT_NAME} PROPERTIES SUFFIX ".clap" PREFIX "")
endif()