Migrated from Make to CMake.

This commit is contained in:
Johannes Findeisen 2026-11-06 19:05:14 +01:00
commit b6ba093000
52 changed files with 1276 additions and 1210 deletions

View file

@ -1,11 +1,11 @@
# Examples
`native_gain.c` is a complete trusted native C effect compiled into an offline
graph. Build/run with `make build/native-gain && ./build/native-gain`; it needs
graph. Build/run with `cmake --build build --target native-gain && ./build/native-gain`; it needs
no GUI/server/plugin SDK. See ../docs/NATIVE_API.md for lifecycle/event contracts.
`quality_preview.c` uses public C MIDI, recorder and gain-ramp APIs to generate
matched raw/smoothed listening fixtures. Run `make quality-preview`; generated
matched raw/smoothed listening fixtures. Run `cmake --build build --target quality-preview`; generated
WAVs remain in the ignored build directory. See docs/AUDIO_QUALITY.md for the
listening sequence and the distinction between automated checks and human
listening acceptance. It never starts a backend or plays audio.

View file

@ -1,5 +1,6 @@
cmake_minimum_required(VERSION 3.25)
project(xtc_juce_examples VERSION 0.1.0 LANGUAGES C CXX)
include(CTest)
set(XTC_JUCE_ROOT "" CACHE PATH "External JUCE source checkout")
if(NOT EXISTS "${XTC_JUCE_ROOT}/modules/juce_audio_utils/juce_audio_utils.h")
message(FATAL_ERROR "Set XTC_JUCE_ROOT to an external JUCE checkout; normal xtc builds do not download JUCE")
@ -11,21 +12,17 @@ message(STATUS "JUCE is AGPLv3/commercial: review the external SDK LICENSE.md be
set(JUCE_BUILD_EXAMPLES OFF CACHE BOOL "" FORCE)
set(JUCE_BUILD_EXTRAS OFF CACHE BOOL "" FORCE)
add_subdirectory("${XTC_JUCE_ROOT}" juce-sdk EXCLUDE_FROM_ALL)
find_program(XTC_MAKE_EXECUTABLE NAMES gmake make REQUIRED)
get_filename_component(XTC_ROOT "${CMAKE_CURRENT_SOURCE_DIR}/../.." ABSOLUTE)
set(XTC_CORE_BUILD "${CMAKE_CURRENT_BINARY_DIR}/c-core")
add_custom_target(xtc-juce-core
COMMAND "${XTC_MAKE_EXECUTABLE}" -C "${XTC_ROOT}"
"BUILD_DIR=${XTC_CORE_BUILD}" "CC=${CMAKE_C_COMPILER}"
"CFLAGS=-O2 -g -fPIC -std=c99 -Wall -Wextra -Wpedantic -Wconversion -Wshadow -Iinclude"
PKG_CONFIG=false FLTK_CONFIG=false "${XTC_CORE_BUILD}/libxtc.a"
BYPRODUCTS "${XTC_CORE_BUILD}/libxtc.a"
VERBATIM USES_TERMINAL)
add_library(xtc-juce-c-core STATIC IMPORTED)
set_target_properties(xtc-juce-c-core PROPERTIES
IMPORTED_LOCATION "${XTC_CORE_BUILD}/libxtc.a"
INTERFACE_INCLUDE_DIRECTORIES "${XTC_ROOT}/include")
add_dependencies(xtc-juce-c-core xtc-juce-core)
if(NOT TARGET xtc-core)
set(XTC_BUILD_GUI OFF CACHE BOOL "" FORCE)
set(XTC_WITH_JACK OFF CACHE BOOL "" FORCE)
set(XTC_BUILD_JUCE OFF CACHE BOOL "" FORCE)
set(XTC_BUILD_STEINBERG OFF CACHE BOOL "" FORCE)
set(xtc_saved_testing ${BUILD_TESTING})
set(BUILD_TESTING OFF)
add_subdirectory("${XTC_ROOT}" c-core EXCLUDE_FROM_ALL)
set(BUILD_TESTING ${xtc_saved_testing})
endif()
juce_add_plugin(XtcJuceSynth
COMPANY_NAME xtc
@ -42,12 +39,15 @@ juce_add_plugin(XtcJuceSynth
NEEDS_WEB_BROWSER FALSE
NEEDS_CURL FALSE)
target_sources(XtcJuceSynth PRIVATE Processor.cpp Editor.cpp PluginEntry.cpp)
# JUCE’s bundled FLAC uses POSIX fileno; its C module sources need GNU extensions.
# The xtc-core target remains strict C99.
set_target_properties(XtcJuceSynth PROPERTIES C_STANDARD 11 C_EXTENSIONS ON)
target_compile_features(XtcJuceSynth PUBLIC cxx_std_17)
target_compile_definitions(XtcJuceSynth PUBLIC
JUCE_WEB_BROWSER=0 JUCE_USE_CURL=0 JUCE_VST3_CAN_REPLACE_VST2=0 JUCE_PLUGINHOST_VST3=1
)
target_include_directories(XtcJuceSynth PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}" "${XTC_ROOT}/include")
target_link_libraries(XtcJuceSynth PRIVATE xtc-juce-c-core juce::juce_audio_utils juce::juce_dsp
target_link_libraries(XtcJuceSynth PRIVATE xtc-core juce::juce_audio_utils juce::juce_dsp
PUBLIC juce::juce_recommended_config_flags juce::juce_recommended_warning_flags)
add_executable(xtc-juce-render Render.cpp)
@ -57,8 +57,11 @@ target_include_directories(xtc-juce-render PRIVATE "${XTC_JUCE_ROOT}/modules")
# Exact float comparisons intentionally check bit-identical C bridge output.
set_source_files_properties(Render.cpp PROPERTIES COMPILE_OPTIONS "-Wno-float-equal")
target_compile_definitions(xtc-juce-render PRIVATE JUCE_GLOBAL_MODULE_SETTINGS_INCLUDED=1)
target_link_libraries(xtc-juce-render PRIVATE XtcJuceSynth xtc-juce-c-core)
enable_testing()
add_test(NAME xtc-juce-processor COMMAND xtc-juce-render --self-test)
add_test(NAME xtc-juce-vst3 COMMAND xtc-juce-render --host-check "$<TARGET_FILE_DIR:XtcJuceSynth_VST3>/../..")
target_link_libraries(xtc-juce-render PRIVATE XtcJuceSynth xtc-core)
if(BUILD_TESTING)
find_program(XTC_XVFB_RUN xvfb-run REQUIRED)
add_test(NAME xtc-juce-processor COMMAND ${XTC_XVFB_RUN} -a $<TARGET_FILE:xtc-juce-render> --self-test)
add_test(NAME xtc-juce-vst3 COMMAND ${XTC_XVFB_RUN} -a $<TARGET_FILE:xtc-juce-render>
--host-check "$<PATH:GET_PARENT_PATH,$<PATH:GET_PARENT_PATH,$<TARGET_FILE_DIR:XtcJuceSynth_VST3>>>")
set_tests_properties(xtc-juce-processor xtc-juce-vst3 PROPERTIES LABELS sdk)
endif()

View file

@ -10,27 +10,34 @@ No SDK or linked binary is copied into normal xtc packages.
## Build and test (Linux)
Supply JUCE explicitly, for example in `/your/path/JUCE`. With CMake >= 3.25,
GNU Make, a C/C++17 toolchain and JUCE's Linux development prerequisites:
Ninja or another CMake backend, a C/C++17 toolchain and JUCE's Linux development
prerequisites, configure from the repository root:
```sh
make JUCE_ROOT=/your/path/JUCE juce-examples
make JUCE_ROOT=/your/path/JUCE test-juce
cmake -S . -B build -DCMAKE_BUILD_TYPE=Release \
-DXTC_BUILD_JUCE=ON -DXTC_JUCE_ROOT=/your/path/JUCE
cmake --build build --target juce-examples --parallel 3
cmake --build build --target test-juce
```
The build never downloads JUCE, installs dependencies or copies plugins into
user plugin directories. It builds its own C99 PIC archive with JACK/FLTK disabled
under `build/juce/c-core`. `test-juce` also requires Xvfb and runs the processor
and JUCE-host checks, then loads the built instrument through xtc's C VST3 host.
Normal `make`, `make gui` and `make test` remain JUCE-independent.
user plugin directories. The bridge links the root `xtc-core` PIC C99 target;
there is no recursive Make build or duplicate core archive. `test-juce` requires
Xvfb and runs the processor, JUCE-host, file/editor and xtc C-host checks.
Normal builds leave `XTC_BUILD_JUCE=OFF` and remain JUCE-independent.
Build products:
Build products (Release):
- `build/juce/XtcJuceSynth_artefacts/Release/VST3/xtc JUCE Synth.vst3`
- `build/juce/XtcJuceSynth_artefacts/Release/Standalone/xtc JUCE Synth`
- `build/juce/xtc-juce-render_artefacts/Release/xtc-juce-render`
Set `BUILD_DIR=...` to move the main build root, or `JUCE_BUILD_DIR=...` to select
only the SDK example build directory.
Use CMake's `-B` argument to select another binary directory. Debug builds use
`Debug` in place of `Release`. The examples can also be configured directly with
`cmake -S examples/juce -B build/juce-only -DXTC_JUCE_ROOT=/your/path/JUCE
-DCMAKE_BUILD_TYPE=Release`; that standalone path adds the same root CMake core
with GUI/JACK/tests disabled rather than invoking Make. Its artefacts are directly
under `build/juce-only`, without the additional `juce` directory.
## Play and shape Soft Keys
@ -84,7 +91,7 @@ VST3 host. These operations do not start an audio device.
## Regression checks and an actual editor image
```sh
xvfb-run -a ctest --test-dir build/juce --output-on-failure
ctest --test-dir build --output-on-failure -R juce
xvfb-run -a ./build/juce/xtc-juce-render_artefacts/Release/xtc-juce-render --snapshot /absolute/new-editor.png
```

View file

@ -16,6 +16,7 @@ if(XTC_VST3_SDK_ROOT)
set(SMTG_ENABLE_VST3_HOSTING_EXAMPLES ON CACHE BOOL "" FORCE)
add_subdirectory("${XTC_VST3_SDK_ROOT}" sdk)
set(public_sdk_SOURCE_DIR "${XTC_VST3_SDK_ROOT}/public.sdk")
set(SMTG_CUSTOM_BINARY_LOCATION "${CMAKE_CURRENT_BINARY_DIR}")
smtg_add_vst3plugin(xtc-sdk-examples sdk_plugins.cpp)
target_link_libraries(xtc-sdk-examples PRIVATE sdk)
target_compile_features(xtc-sdk-examples PRIVATE cxx_std_17)

View file

@ -1,6 +1,6 @@
# Official Steinberg SDK examples
These are optional integration examples. Normal `make` / `make test` uses the
These are optional integration examples. Normal CMake builds and CTest use the
existing pinned C ABI headers and never downloads SDKs. Original example source
is MIT-licensed like xtc. SDK code is compiled from an external checkout, not
vendored or installed by these targets. C++ is confined to the SDK examples;
@ -26,13 +26,17 @@ trademark distribution rights.
From the xtc repository root:
```sh
make VST3_SDK_ROOT=/your/path/vst3sdk test-steinberg-sdk
cmake -S . -B build -DCMAKE_BUILD_TYPE=Release \
-DXTC_BUILD_STEINBERG=ON -DXTC_VST3_SDK_ROOT=/your/path/vst3sdk
cmake --build build --parallel 3
ctest --test-dir build --output-on-failure -R steinberg
```
This builds the original `xtc-sdk-examples.vst3` bundle using Steinberg's factory,
AudioEffect, controller and platform-entry implementations; runs the official
validator; and runs xtc's gain/MIDI interoperability checks. Build output stays
under `build/steinberg-sdk`; automatic plugin-directory links and installation
validator; and runs xtc's gain/MIDI interoperability checks. The plugin bundle stays
under `build/steinberg-sdk`; SDK helper executables use `build/bin`. Automatic
plugin-directory links and installation
are disabled. SDK source may emit its own compiler warnings.
The bundle contains:
@ -56,9 +60,9 @@ xtc synth -> effect host path:
/absolute/path/to/new-sdk-demo.wav
```
The destination must not exist. This executable is built by `test-steinberg-sdk`.
To use a different xtc build directory, pass `BUILD_DIR=...`; the SDK build then
lives under that directory unless `STEINBERG_BUILD_DIR=...` is explicitly set.
The destination must not exist. This executable is built when the SDK option is enabled.
Use CMake’s `-B` argument to select another binary directory; the SDK build then
lives under its `steinberg-sdk` subdirectory.
The main app's existing plugin loader can use the bundle path through its C API;
its file chooser may require selecting the inner `.so`. The effect loads as a