-
Notifications
You must be signed in to change notification settings - Fork 34
/
CMakeLists.txt
151 lines (128 loc) · 5.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
# CMakeList.txt to build Shortcircuit XT
#
# Shortcircuit XT began with a not-building snap of the code which was used
# at some point in the SC2 product cycle, so we took a different strategy which was:
#
# 1. Have a libshortcircuit-core basically which contains all the code to be SC
# 2. Expose that in an shortcircuit-headless, shortcircuitpy library and exe
# 3. Rebuild the plugin using that library and JUCE
#
# At least that's the plan. Critically this no longer builds any of the old GUI or
# VST2 code, which we couldn't make work anyway. That code is still in the codebase for
# reference as we port, but we should remove it before we ship Shortcircuit XT
#
cmake_minimum_required(VERSION 3.20)
cmake_policy(SET CMP0091 NEW)
cmake_policy(SET CMP0063 NEW)
set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>")
# https://github.com/taocpp/PEGTL/issues/347 would let us go to 13
set(CMAKE_OSX_DEPLOYMENT_TARGET 10.14 CACHE STRING "Minimum macOS version")
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
# TODO Remove This before we ship non beta version. Remember
# the AU rescans only when versions change even if binaries are
# different.
message(STATUS "ShortcircuitXT: Using date-driven version while in alpha")
string(TIMESTAMP DAY_OF_YEAR "%j")
string(TIMESTAMP YEAR "%Y")
math(EXPR PART0 "${YEAR}-2023 + 6")
math(EXPR PART1 "${DAY_OF_YEAR} + 1")
project(ShortcircuitXT VERSION 0.${PART0}.${PART1}.0 LANGUAGES C CXX ASM)
set(ShortcircuitXT_VERSION ${PROJECT_VERSION})
if (APPLE)
enable_language(OBJC)
enable_language(OBJCXX)
set(CMAKE_OBJC_VISIBILITY_PRESET hidden)
set(CMAKE_OBJCXX_VISIBILITY_PRESET hidden)
if( ${CMAKE_CXX_COMPILER_VERSION} VERSION_GREATER_EQUAL "15.0.0" AND ${CMAKE_CXX_COMPILER_VERSION} VERSION_LESS "15.1")
add_link_options(-Wl,-ld_classic)
add_compile_definitions(JUCE_SILENCE_XCODE_15_LINKER_WARNING=1)
endif()
endif ()
set(BUILD_SHARED_LIBS OFF CACHE BOOL "Never want shared if not specified")
set(CMAKE_CXX_EXTENSIONS OFF)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_VISIBILITY_PRESET hidden)
set(CMAKE_VISIBILITY_INLINES_HIDDEN ON)
set(CMAKE_POSITION_INDEPENDENT_CODE TRUE)
# Build Time Options
option(SCXT_BUILD_VST3 "Build a VST3 plugin" ON)
option(SCXT_BUILD_AU "Build an AU plugin" ON)
option(SCXT_BUILD_CLAP "Build a CLAP" ON)
option(SCXT_BUILD_STANDALONE "Build a standalone executable" ON)
option(SCXT_USE_ALSA "Build with ALSA when appropriate" ON)
option(SCXT_USE_JACK "Build with JACK when appropriate" ON)
option(SCXT_COPY_PLUGIN_AFTER_BUILD "Copy plugin after build if possible" OFF)
option(SCXT_SKIP_PIE_CHANGE "Dont add -no-pie to executables" OFF)
if ("${CMAKE_GENERATOR_PLATFORM}" STREQUAL "arm64ec")
message(STATUS "Default skipping FLAC and MP3 on arm64ec for now")
option(SCXT_USE_FLAC "Include FLAC support" OFF)
option(SCXT_USE_MP3 "Include MP3 support" OFF)
else()
option(SCXT_USE_FLAC "Include FLAC support" ON)
option(SCXT_USE_MP3 "Include MP3 support" ON)
endif()
option(SCXT_SANITIZE "Build with clang/gcc address and undef sanitizer" OFF)
if (WIN32)
option(SCXT_USE_CLAP_WRAPPER_STANDALONE "Build with the clap wrapper standalone rather than our temp one" ON)
else()
option(SCXT_USE_CLAP_WRAPPER_STANDALONE "Build with the clap wrapper standalone rather than our temp one" OFF)
endif()
# Calculate bitness
math(EXPR BITS "8*${CMAKE_SIZEOF_VOID_P}")
if (NOT ${BITS} EQUAL 64)
message(WARNING "${PROJECT_NAME} has only been tested on 64 bits. This may not work")
endif ()
# Share some information about the build
message(STATUS "Shortcircuit XT ${CMAKE_PROJECT_VERSION}")
message(STATUS "Compiler Version is ${CMAKE_CXX_COMPILER_VERSION}")
if (MSVC)
message(STATUS "Windows Architecture is ${CMAKE_GENERATOR_PLATFORM}")
endif()
# Everything here is C++ 17 now
if (CMAKE_CXX_COMPILER_ID MATCHES "GNU" AND UNIX AND NOT APPLE AND NOT SCXT_SKIP_PIE_CHANGE)
message(STATUS "Setting -no-pie on EXE flags; use SCXT_SKIP_PIE_CHANGE=TRUE to avoid")
set(CMAKE_EXE_LINKER_FLAGS "-no-pie")
endif ()
if (CMAKE_CXX_COMPILER_ID MATCHES "Clang|GNU")
if (${SCXT_SANITIZE})
message(STATUS "Sanitizer is ON")
endif ()
# BP note: If you want to turn on llvm/gcc sanitize, remove this and the link options below
add_compile_options(
$<$<BOOL:${SCXT_SANITIZE}>:-fsanitize=address>
$<$<BOOL:${SCXT_SANITIZE}>:-fsanitize=undefined>
)
add_link_options(
$<$<BOOL:${SCXT_SANITIZE}>:-fsanitize=address>
$<$<BOOL:${SCXT_SANITIZE}>:-fsanitize=undefined>
)
endif ()
add_compile_definitions(SCXT_ROOT_BUILD_DIR="${CMAKE_SOURCE_DIR}")
include(cmake/compiler-and-git.cmake)
include(cmake/CmakeRC.cmake)
add_subdirectory(libs)
# Next for now
add_subdirectory(src)
add_subdirectory(resources)
add_subdirectory(src-ui)
add_subdirectory(tests)
add_subdirectory(clients)
include(cmake/basic-installer.cmake)
add_custom_target(scxt-code-checks)
# Clang Format checks
find_program(CLANG_FORMAT_EXE NAMES clang-format-12 clang-format)
set(CLANG_FORMAT_DIRS src src-ui tests clients)
set(CLANG_FORMAT_EXTS cpp h)
foreach (dir ${CLANG_FORMAT_DIRS})
foreach (ext ${CLANG_FORMAT_EXTS})
list(APPEND CLANG_FORMAT_GLOBS "':(glob)${dir}/**/*.${ext}'")
endforeach ()
endforeach ()
add_custom_command(TARGET scxt-code-checks
POST_BUILD
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
COMMAND ${CMAKE_COMMAND} -E echo About to check clang-format using ${CLANG_FORMAT_EXE}
COMMAND git ls-files -- ${CLANG_FORMAT_GLOBS} | xargs ${CLANG_FORMAT_EXE} --dry-run --Werror
)
# }}}