Skip to content

Commit 6953168

Browse files
committed
CMake definitions and format rearrangement
- Rename some SFIZZ_ prefixed definitions where possible to permit some modules to be generic and be reused in other projects, keep project' information in the same place and more explicit - Fixed non-compliant code formatting
1 parent 8fd17c1 commit 6953168

26 files changed

+389
-333
lines changed

.github/workflows/build.yml

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -70,10 +70,10 @@ jobs:
7070
-D SFIZZ_JACK=OFF
7171
-D SFIZZ_RENDER=OFF
7272
-D SFIZZ_SHARED=OFF
73-
-D SFIZZ_LV2=ON
74-
-D SFIZZ_LV2_UI=ON
75-
-D SFIZZ_PUREDATA=ON
76-
-D SFIZZ_VST=ON
73+
-D PLUGIN_LV2=ON
74+
-D PLUGIN_LV2_UI=ON
75+
-D PLUGIN_PUREDATA=ON
76+
-D PLUGIN_VST3=ON
7777
)
7878
cmake "${options[@]}"
7979
- name: Build
@@ -106,10 +106,10 @@ jobs:
106106
-D CMAKE_BUILD_TYPE=${{ env.build_type }}
107107
-D CMAKE_CXX_STANDARD=17
108108
-D SFIZZ_SHARED=OFF
109-
-D SFIZZ_AU=ON
110-
-D SFIZZ_LV2=ON
111-
-D SFIZZ_LV2_UI=ON
112-
-D SFIZZ_VST=ON
109+
-D PLUGIN_AU=ON
110+
-D PLUGIN_LV2=ON
111+
-D PLUGIN_LV2_UI=ON
112+
-D PLUGIN_VST3=ON
113113
)
114114
if [[ ${{ github.ref_type }} == 'branch' ]]; then
115115
options=(
@@ -182,9 +182,9 @@ jobs:
182182
-S "${Env:GITHUB_WORKSPACE}" `
183183
-D CMAKE_BUILD_TYPE=${{ env.build_type }} `
184184
-D CMAKE_CXX_STANDARD=17 `
185-
-D SFIZZ_LV2=ON `
186-
-D SFIZZ_PUREDATA=ON `
187-
-D SFIZZ_VST=ON `
185+
-D PLUGIN_LV2=ON `
186+
-D PLUGIN_PUREDATA=ON `
187+
-D PLUGIN_VST3=ON `
188188
- name: Build
189189
working-directory: ${{ runner.workspace }}
190190
run: cmake --build build --config ${{ env.build_type }} --verbose -j 2
@@ -301,8 +301,8 @@ jobs:
301301
-D ENABLE_LTO=OFF
302302
-D SFIZZ_STATIC_DEPENDENCIES=ON
303303
-D SFIZZ_JACK=OFF
304-
-D SFIZZ_PUREDATA=ON
305-
-D SFIZZ_VST=ON
304+
-D PLUGIN_PUREDATA=ON
305+
-D PLUGIN_VST3=ON
306306
)
307307
${{ matrix.platform }}-w64-mingw32-cmake "${options[@]}"
308308
- name: Build
@@ -353,8 +353,8 @@ jobs:
353353
-D PROJECT_SYSTEM_PROCESSOR=armv7-a \
354354
-D CMAKE_BUILD_TYPE=Release \
355355
-D SFIZZ_JACK=OFF \
356-
-D SFIZZ_VST=OFF \
357-
-D SFIZZ_LV2_UI=OFF
356+
-D PLUGIN_VST3=OFF \
357+
-D PLUGIN_LV2_UI=OFF
358358
- name: Build
359359
shell: bash
360360
working-directory: ${{ runner.workspace }}

CMakeLists.txt

Lines changed: 38 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,34 @@
1-
if (WIN32)
2-
cmake_minimum_required (VERSION 3.15)
1+
if(WIN32)
2+
cmake_minimum_required(VERSION 3.15)
33
cmake_policy(SET CMP0091 NEW)
44
else()
55
# FIXME: The old JPC fork of mod-plugin-builder image used in CI requires 3.5.
66
# The current upstream one needs a different configuration.
7-
# Minimum required to use SFIZZ_USE_SYSTEM_ABSEIL is 3.11,
8-
# see library/cmake/SfizzDeps.cmake at line 70.
9-
cmake_minimum_required(VERSION 3.11)
7+
# Minimum required to use SFIZZ_USE_SYSTEM_ABSEIL is 3.11,
8+
# see library/cmake/SfizzDeps.cmake at line 70.
9+
# CMake 3.12 supports object libraries, can be used to share a single build
10+
# between AU, VST2 and VST3 plugins; also to use project' HOMEPAGE_URL.
11+
cmake_minimum_required(VERSION 3.12)
1012
endif()
1113

12-
project (sfizz VERSION 1.2.2 LANGUAGES CXX C)
13-
set (PROJECT_DESCRIPTION
14-
"SFZ based sampler, providing AU, LV2, PureData and VST plugins."
14+
# The project was splitted in 2 repositories:
15+
# - `sfizz` for the library, which represents the main repository reference
16+
# - `sfizz-ui` for UIs (plugins with a future standalone UI in mind).
17+
# However, to keep the original structure, we assume this as "sfizz" project,
18+
# containing the "libsfizz" sub project in the `library` git submodule.
19+
project(sfizz
20+
DESCRIPTION "SFZ sampler, providing AU, LV2, PureData and VST plugins."
21+
HOMEPAGE_URL "http://sfztools.github.io/sfizz"
22+
LANGUAGES CXX C
23+
VERSION 1.2.2
1524
)
25+
set(PROJECT_REPOSITORY "https://github.com/sfztools/sfizz")
26+
set(PROJECT_AUTHOR "SFZTools")
27+
set(PROJECT_EMAIL "paul@ferrand.cc")
28+
29+
set(LV2_PLUGIN_VERSION_MINOR 10)
30+
set(LV2_PLUGIN_VERSION_MICRO 3)
31+
1632
# External configuration CMake scripts
1733
set (CMAKE_MODULE_PATH "${CMAKE_MODULE_PATH};"
1834
"${CMAKE_CURRENT_SOURCE_DIR}/library/cmake;"
@@ -21,16 +37,21 @@ set (CMAKE_MODULE_PATH "${CMAKE_MODULE_PATH};"
2137
include(BuildType)
2238
include(OptionEx)
2339

24-
option_ex(SFIZZ_AU "Enable AU plug-in build" APPLE)
25-
option_ex(SFIZZ_LV2 "Enable LV2 plug-in build" ON)
26-
option_ex(SFIZZ_LV2_UI "Enable LV2 plug-in user interface" ON)
27-
option_ex(SFIZZ_PUREDATA "Enable Puredata plug-in build" OFF)
40+
option_ex(PLUGIN_AU "Enable AU plug-in build" APPLE)
41+
option_ex(PLUGIN_LV2 "Enable LV2 plug-in build" ON)
42+
option_ex(PLUGIN_LV2_UI "Enable LV2 plug-in user interface" ON)
43+
option_ex(PLUGIN_PUREDATA "Enable Puredata plug-in build" OFF)
44+
option_ex(PLUGIN_VST2 "Enable VST2 plug-in build (unsupported)" OFF)
45+
option_ex(PLUGIN_VST3 "Enable VST3 plug-in build" ON)
2846
option_ex(SFIZZ_USE_SYSTEM_LV2 "Use LV2 headers preinstalled on system" OFF)
2947
option_ex(SFIZZ_USE_SYSTEM_VST3SDK "Use VST3SDK source files preinstalled on system" OFF)
30-
option_ex(SFIZZ_VST2 "Enable VST2 plug-in build (unsupported)" OFF)
31-
option_ex(SFIZZ_VST "Enable VST plug-in build" ON)
3248

33-
set(MIDI_CC_MAX 512 CACHE STRING "Maximum amount of Control Change Messages")
49+
set(MIDI_CC_COUNT 512 CACHE STRING "Maximum amount of Control Change Messages")
50+
51+
# TODO: VCPKG OR SNDFILE_STATIC?
52+
if(PLUGIN_LV2 AND SFIZZ_USE_VCPKG)
53+
set(LV2_PLUGIN_SPDX_LICENSE_ID "LGPL-3.0-only")
54+
endif()
3455

3556
# Set Windows compatibility level to 10 required by VSTGUI
3657
if(WIN32)
@@ -50,8 +71,8 @@ if(WIN32)
5071
${PROJECT_BINARY_DIR}/innosetup.iss @ONLY)
5172
endif()
5273

53-
# Put it at the end so that the vst/lv2 directories are registered
54-
if (NOT MSVC)
74+
# Leave this at the end so that the vst/lv2 directories are registered
75+
if(NOT MSVC)
5576
include(PluginsUninstall)
5677
endif()
5778

cmake/BundleDylibs.cmake

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
# SPDX-License-Identifier: BSD-2-Clause
2+
3+
# This code is part of the sfizz library and is licensed under a BSD 2-clause
4+
# license. You should have receive a LICENSE.md file along with the code.
5+
# If not, contact the sfizz maintainers at https://github.com/sfztools/sfizz
6+
17
# Dylib bundler for macOS
28
# Requires the external program "dylibbundler"
39

cmake/LV2Config.cmake

Lines changed: 40 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,27 @@
1+
# SPDX-License-Identifier: BSD-2-Clause
2+
3+
# This code is part of the sfizz library and is licensed under a BSD 2-clause
4+
# license. You should have receive a LICENSE.md file along with the code.
5+
# If not, contact the sfizz maintainers at https://github.com/sfztools/sfizz
6+
17
# This option is for MIDI CC support in absence of host midi:binding support
2-
option(SFIZZ_LV2_PSA "Enable plugin-side MIDI automations" ON)
8+
option(PLUGIN_LV2_PSA "Enable plugin-side MIDI automations" ON)
39

4-
# Configuration for this plugin
5-
# TODO: generate version from git
6-
set(LV2PLUGIN_VERSION_MINOR 10)
7-
set(LV2PLUGIN_VERSION_MICRO 3)
8-
set(LV2PLUGIN_NAME "sfizz")
9-
set(LV2PLUGIN_COMMENT "SFZ sampler")
10-
set(LV2PLUGIN_URI "http://sfztools.github.io/sfizz")
11-
set(LV2PLUGIN_REPOSITORY SFIZZ_REPOSITORY)
12-
set(LV2PLUGIN_AUTHOR "SFZTools")
13-
set(LV2PLUGIN_EMAIL "paul@ferrand.cc")
14-
if(SFIZZ_USE_VCPKG)
15-
set(LV2PLUGIN_SPDX_LICENSE_ID "LGPL-3.0-only")
16-
else()
17-
set(LV2PLUGIN_SPDX_LICENSE_ID "ISC")
10+
set(LV2_PLUGIN_NAME "${PROJECT_NAME}")
11+
set(LV2_PLUGIN_COMMENT "${PROJECT_DESCRIPTION}")
12+
set(LV2_PLUGIN_URI "${PROJECT_HOMEPAGE_URL}")
13+
set(LV2_PLUGIN_REPOSITORY "${PROJECT_REPOSITORY}")
14+
set(LV2_PLUGIN_AUTHOR "${PROJECT_AUTHOR}")
15+
set(LV2_PLUGIN_EMAIL "${PROJECT_EMAIL}")
16+
17+
if(NOT LV2_PLUGIN_SPDX_LICENSE_ID)
18+
set(LV2_PLUGIN_SPDX_LICENSE_ID "ISC") # default license
1819
endif()
1920

20-
if(SFIZZ_LV2_UI)
21-
set(LV2PLUGIN_IF_ENABLE_UI "")
21+
if(PLUGIN_LV2_UI)
22+
set(LV2_PLUGIN_IF_ENABLE_UI "")
2223
else()
23-
set(LV2PLUGIN_IF_ENABLE_UI "#")
24+
set(LV2_PLUGIN_IF_ENABLE_UI "#")
2425
endif()
2526

2627
if(WIN32)
@@ -34,43 +35,43 @@ else()
3435
endif()
3536

3637
if(APPLE)
37-
set(LV2PLUGIN_INSTALL_DIR "$ENV{HOME}/Library/Audio/Plug-Ins/LV2" CACHE STRING
38+
set(LV2_PLUGIN_INSTALL_DIR "$ENV{HOME}/Library/Audio/Plug-Ins/LV2" CACHE STRING
3839
"Install destination for LV2 bundle [default: $ENV{HOME}/Library/Audio/Plug-Ins/LV2]")
3940
elseif(MSVC)
40-
set(LV2PLUGIN_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/lv2" CACHE STRING
41+
set(LV2_PLUGIN_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/lv2" CACHE STRING
4142
"Install destination for LV2 bundle [default: ${CMAKE_INSTALL_PREFIX}/lv2]")
4243
else()
43-
set(LV2PLUGIN_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/lib/lv2" CACHE STRING
44+
set(LV2_PLUGIN_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/lib/lv2" CACHE STRING
4445
"Install destination for LV2 bundle [default: ${CMAKE_INSTALL_PREFIX}/lib/lv2]")
4546
endif()
4647

4748
include(StringUtility)
4849

49-
function(sfizz_lv2_generate_controllers_ttl FILE)
50-
file(WRITE "${FILE}" "# LV2 parameters for SFZ controllers
50+
function(generate_lv2_controllers_ttl FILE)
51+
file(WRITE "${FILE}" "# LV2 parameters for MIDI CC controllers
5152
@prefix atom: <http://lv2plug.in/ns/ext/atom#> .
5253
@prefix lv2: <http://lv2plug.in/ns/lv2core#> .
5354
@prefix midi: <http://lv2plug.in/ns/ext/midi#> .
5455
@prefix patch: <http://lv2plug.in/ns/ext/patch#> .
5556
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
56-
@prefix sfizz: <${LV2PLUGIN_URI}#> .
57+
@prefix ${PROJECT_NAME}: <${LV2_PLUGIN_URI}#> .
5758
")
58-
math(EXPR _j "${MIDI_CC_MAX}-1")
59+
math(EXPR _j "${MIDI_CC_COUNT}-1")
5960
foreach(_i RANGE "${_j}")
60-
if(_i LESS 128 AND SFIZZ_LV2_PSA)
61+
if(_i LESS 128 AND PLUGIN_LV2_PSA)
6162
continue() # Don't generate automation parameters for CCs with plugin-side automation
6263
endif()
6364

6465
string_left_pad(_i "${_i}" 3 0)
6566
file(APPEND "${FILE}" "
66-
sfizz:cc${_i}
67+
${PROJECT_NAME}:cc${_i}
6768
a lv2:Parameter ;
6869
rdfs:label \"Controller ${_i}\" ;
6970
rdfs:range atom:Float ;
7071
lv2:minimum 0.0 ;
7172
lv2:maximum 1.0")
7273

73-
if(_i LESS 128 AND NOT SFIZZ_LV2_PSA)
74+
if(_i LESS 128 AND NOT PLUGIN_LV2_PSA)
7475
math(EXPR _digit1 "${_i}>>4")
7576
math(EXPR _digit2 "${_i}&15")
7677
string(SUBSTRING "0123456789ABCDEF" "${_digit1}" 1 _digit1)
@@ -85,40 +86,40 @@ sfizz:cc${_i}
8586
endforeach()
8687

8788
file(APPEND "${FILE}" "
88-
<${LV2PLUGIN_URI}>
89+
<${LV2_PLUGIN_URI}>
8990
a lv2:Plugin ;
9091
")
9192

9293
file(APPEND "${FILE}" " patch:readable")
93-
if(NOT SFIZZ_LV2_PSA)
94-
file(APPEND "${FILE}" " sfizz:cc000")
94+
if(NOT PLUGIN_LV2_PSA)
95+
file(APPEND "${FILE}" " ${PROJECT_NAME}:cc000")
9596
foreach(_i RANGE 1 "${_j}")
9697
string_left_pad(_i "${_i}" 3 0)
97-
file(APPEND "${FILE}" ", sfizz:cc${_i}")
98+
file(APPEND "${FILE}" ", ${PROJECT_NAME}:cc${_i}")
9899
endforeach()
99100
else()
100-
file(APPEND "${FILE}" " sfizz:cc128")
101+
file(APPEND "${FILE}" " ${PROJECT_NAME}:cc128")
101102
foreach(_i RANGE 129 "${_j}")
102103
string_left_pad(_i "${_i}" 3 0)
103-
file(APPEND "${FILE}" ", sfizz:cc${_i}")
104+
file(APPEND "${FILE}" ", ${PROJECT_NAME}:cc${_i}")
104105
endforeach()
105106
endif()
106107

107108
file(APPEND "${FILE}" " ;
108109
")
109110

110111
file(APPEND "${FILE}" " patch:writable")
111-
if(NOT SFIZZ_LV2_PSA)
112-
file(APPEND "${FILE}" " sfizz:cc000")
112+
if(NOT PLUGIN_LV2_PSA)
113+
file(APPEND "${FILE}" " ${PROJECT_NAME}:cc000")
113114
foreach(_i RANGE 1 "${_j}")
114115
string_left_pad(_i "${_i}" 3 0)
115-
file(APPEND "${FILE}" ", sfizz:cc${_i}")
116+
file(APPEND "${FILE}" ", ${PROJECT_NAME}:cc${_i}")
116117
endforeach()
117118
else()
118-
file(APPEND "${FILE}" " sfizz:cc128")
119+
file(APPEND "${FILE}" " ${PROJECT_NAME}:cc128")
119120
foreach(_i RANGE 129 "${_j}")
120121
string_left_pad(_i "${_i}" 3 0)
121-
file(APPEND "${FILE}" ", sfizz:cc${_i}")
122+
file(APPEND "${FILE}" ", ${PROJECT_NAME}:cc${_i}")
122123
endforeach()
123124
endif()
124125
file(APPEND "${FILE}" " .

cmake/MakeUninstall.cmake.in

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
# SPDX-License-Identifier: BSD-2-Clause
2+
3+
# This code is part of the sfizz library and is licensed under a BSD 2-clause
4+
# license. You should have receive a LICENSE.md file along with the code.
5+
# If not, contact the sfizz maintainers at https://github.com/sfztools/sfizz
6+
17
if(NOT EXISTS "@CMAKE_BINARY_DIR@/install_manifest.txt")
28
message(FATAL_ERROR "Cannot find install manifest: @CMAKE_BINARY_DIR@/install_manifest.txt")
39
endif()

cmake/PluginsUninstall.cmake

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
# SPDX-License-Identifier: BSD-2-Clause
2+
3+
# This code is part of the sfizz library and is licensed under a BSD 2-clause
4+
# license. You should have receive a LICENSE.md file along with the code.
5+
# If not, contact the sfizz maintainers at https://github.com/sfztools/sfizz
6+
17
if(NOT TARGET uninstall)
28
configure_file(
39
"${CMAKE_CURRENT_SOURCE_DIR}/cmake/MakeUninstall.cmake.in"
@@ -7,13 +13,13 @@ if(NOT TARGET uninstall)
713
add_custom_target(uninstall
814
COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_BINARY_DIR}/MakeUninstall.cmake)
915

10-
if(SFIZZ_LV2 AND LV2PLUGIN_INSTALL_DIR)
16+
if(PLUGIN_LV2 AND LV2_PLUGIN_INSTALL_DIR)
1117
add_custom_command(TARGET uninstall
12-
COMMAND rm -rv "${LV2PLUGIN_INSTALL_DIR}/${PROJECT_NAME}.lv2")
18+
COMMAND rm -rv "${LV2_PLUGIN_INSTALL_DIR}/${PROJECT_NAME}.lv2")
1319
endif()
1420

15-
if(SFIZZ_VST AND VSTPLUGIN_INSTALL_DIR)
21+
if(PLUGIN_VST3 AND VST3_PLUGIN_INSTALL_DIR)
1622
add_custom_command(TARGET uninstall
17-
COMMAND rm -rv "${VSTPLUGIN_INSTALL_DIR}/${PROJECT_NAME}.vst3")
23+
COMMAND rm -rv "${VST3_PLUGIN_INSTALL_DIR}/${PROJECT_NAME}.vst3")
1824
endif()
1925
endif()

cmake/PuredataConfig.cmake

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
# SPDX-License-Identifier: BSD-2-Clause
2+
3+
# This code is part of the sfizz library and is licensed under a BSD 2-clause
4+
# license. You should have receive a LICENSE.md file along with the code.
5+
# If not, contact the sfizz maintainers at https://github.com/sfztools/sfizz
6+
17
find_path(PD_INCLUDE_BASEDIR "m_pd.h" PATH_SUFFIXES "pd")
28
set(PD_IMP_DEF "${PROJECT_SOURCE_DIR}/plugins/puredata/external/pd/bin/pd.def")
39

@@ -17,13 +23,13 @@ else()
1723
endif()
1824

1925
if(APPLE)
20-
set(PDPLUGIN_INSTALL_DIR "$ENV{HOME}/Library/Pd" CACHE STRING
26+
set(PD_PLUGIN_INSTALL_DIR "$ENV{HOME}/Library/Pd" CACHE STRING
2127
"Install destination for Puredata bundle [default: $ENV{HOME}/Library/Pd]")
2228
elseif(MSVC)
23-
set(PDPLUGIN_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/Pd/extra" CACHE STRING
29+
set(PD_PLUGIN_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/Pd/extra" CACHE STRING
2430
"Install destination for Puredata bundle [default: ${CMAKE_INSTALL_PREFIX}/Pd/extra]")
2531
else()
26-
set(PDPLUGIN_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/lib/pd/extra" CACHE STRING
32+
set(PD_PLUGIN_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/lib/pd/extra" CACHE STRING
2733
"Install destination for Puredata bundle [default: ${CMAKE_INSTALL_PREFIX}/lib/pd/extra]")
2834
endif()
2935

cmake/StringUtility.cmake

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# SPDX-License-Identifier: BSD-2-Clause
22

3+
# This code is part of the sfizz library and is licensed under a BSD 2-clause
4+
# license. You should have receive a LICENSE.md file along with the code.
5+
# If not, contact the sfizz maintainers at https://github.com/sfztools/sfizz
6+
37
function(string_left_pad VAR INPUT LENGTH FILLCHAR)
48
set(_output "${INPUT}")
59
string(LENGTH "${_output}" _length)

0 commit comments

Comments
 (0)