xtc/docs/BUILD.md

188 lines
9 KiB
Markdown
Raw Normal View History

2026-11-06 19:05:14 +01:00
# Building xtc with CMake
2026-10-26 23:03:17 +01:00
2026-11-06 19:05:14 +01:00
The root `CMakeLists.txt` is the authoritative build. C99 engine/model/DSP and
public C APIs remain in `include/xtc` and `src`; C++17 is used for the optional
FLTK interface and SDK examples. The small root Makefile only forwards common
commands to CMake/CTest; it contains no source lists or compilation rules.
Direct CMake builds need no Make wrapper. CMake does not download SDKs or
install system dependencies.
2026-11-06 15:20:20 +01:00
2026-11-06 19:05:14 +01:00
## Configure, build and test
2026-10-26 23:03:17 +01:00
2026-11-06 19:05:14 +01:00
Requirements: CMake 3.25+, a C99 compiler, Python 3.12+ for build/test/release
tools, a POSIX toolchain with threads, math and dynamic loading, and a CMake
backend such as Ninja or Unix Makefiles. C++17 is required when GUI/SDK targets
are enabled. `pkg-config` discovers optional JACK; FLTK discovery tries
`pkg-config` then `fltk-config`. LADSPA uses its installed development header.
Missing optional development files do not prevent the core from building.
From the source root:
2026-10-26 23:03:17 +01:00
```sh
2026-11-06 19:05:14 +01:00
cmake -S . -B build -DCMAKE_BUILD_TYPE=Debug
cmake --build build --parallel
ctest --test-dir build --output-on-failure
./build/xtc-check
2026-11-06 19:05:14 +01:00
./build/xtc # when FLTK was found
2026-10-26 23:03:17 +01:00
```
2026-11-06 19:05:14 +01:00
All binaries and the static `libxtc.a` are in the chosen binary directory.
The default build includes offline test binaries and plugin fixtures. CTest
runs offline, fault-injection, plugin, recovery, capacity/endurance, and available
GUI tests; live JACK tests require explicit opt-in. GUI tests use Xvfb and
startup checks also require xdotool. No physical ports are connected by tests.
CTest runs source-relative fixtures with an explicit working directory.
Assertions stay enabled in optimized test builds.
2026-10-26 23:03:17 +01:00
2026-11-06 19:05:14 +01:00
Use a new build directory when changing compiler, generator or instrumentation.
For Ninja, add `-G Ninja` to the configure command. CMake also writes
`compile_commands.json` for editors and analysis tools. In CLion, open the root
project and select a CMake profile/preset; do not import a Makefile project.
2026-11-06 15:20:20 +01:00
2026-11-06 19:05:14 +01:00
Optional presets separate configurations:
2026-10-26 23:03:17 +01:00
2026-11-06 19:05:14 +01:00
```sh
cmake --preset debug
cmake --build --preset debug --parallel
ctest --preset debug
```
`release`, `minimal` and `sanitize` presets follow the same three commands.
Release enables optimized builds and source/binary prefix maps. Minimal disables
FLTK, JACK and LADSPA. Sanitize selects Clang ASan/UBSan for offline C tests;
it does not enable GUI or physical-device tests. Existing GUI sanitizer caveats
and fontconfig leak suppressions are described in
[the integration notes](../tests/integration/README.md).
## Quick Make shortcuts
With GNU Make installed, `make` (or `make build`) configures and builds;
`make test`/`make check` also runs CTest. `make gui` builds the FLTK app,
`make run` builds and launches it, and `make clean` cleans products while keeping
the cache. `make configure` only configures, and `make help` lists shortcuts.
Defaults are `BUILD_DIR=build`, `BUILD_TYPE=Debug` and `JOBS=4`. For example:
```sh
make BUILD_DIR=build/release BUILD_TYPE=Release JOBS=8
make BUILD_DIR=build/minimal CMAKE_ARGS='-G Ninja -DXTC_BUILD_GUI=OFF -DXTC_WITH_JACK=OFF'
make test CTEST_ARGS='-R ^core$'
```
Use a fresh binary directory when changing generator/compiler. Extra configure
flags go in `CMAKE_ARGS`; extra CTest flags go in `CTEST_ARGS`. These shortcuts
use the same CMake targets and cache as the direct commands above. Keep source
lists, dependencies, SDK and packaging rules in CMake.
## Configuration
| Cache option | Default | Meaning |
2026-10-26 23:03:17 +01:00
| --- | --- | --- |
2026-11-06 19:05:14 +01:00
| `BUILD_TESTING` | `ON` | Build/register the test suite |
| `XTC_BUILD_GUI` | `ON` | Discover FLTK and build the application when available |
| `XTC_WITH_JACK` | `ON` | Discover/build the JACK/PipeWire backend |
| `XTC_WITH_LADSPA` | `ON` | Enable LADSPA when the system header exists |
| `XTC_ENABLE_LIVE_TESTS` | `OFF` | Register software JACK loopback and GUI/JACK workflows |
| `XTC_SANITIZE` | `OFF` | Address/undefined sanitizers, frame pointers |
| `XTC_REPRODUCIBLE` | `OFF` | Remove source/binary directory paths and debug information |
| `XTC_BUILD_JUCE` | `OFF` | Build externally supplied JUCE integration |
| `XTC_BUILD_STEINBERG` | `OFF` | Build externally supplied official VST3 SDK examples |
2026-10-26 23:03:17 +01:00
2026-11-06 19:05:14 +01:00
Use `-DNAME=VALUE` during configuration, not Make variables. Standard CMake
settings include `CMAKE_C_COMPILER`, `CMAKE_CXX_COMPILER`, `CMAKE_BUILD_TYPE`,
`CMAKE_C_FLAGS`, `CMAKE_CXX_FLAGS` and `CMAKE_EXE_LINKER_FLAGS`. CMake propagates
includes, definitions and link dependencies through targets. Core users can link
`xtc::core` inside this build; installed consumers use `pkg-config xtc`.
2026-10-26 23:03:17 +01:00
2026-11-06 19:05:14 +01:00
A fully offline minimal configuration:
2026-10-26 23:32:04 +01:00
```sh
2026-11-06 19:05:14 +01:00
cmake -S . -B build/minimal -G Ninja -DCMAKE_BUILD_TYPE=Release \
-DXTC_BUILD_GUI=OFF -DXTC_WITH_JACK=OFF -DXTC_WITH_LADSPA=OFF
cmake --build build/minimal --parallel
ctest --test-dir build/minimal --output-on-failure
2026-10-26 23:32:04 +01:00
```
2026-11-06 19:05:14 +01:00
This path needs no C++ compiler, FLTK, JACK or LADSPA development files. CLAP and
VST3 C headers stay pinned in `third_party`; VST2 uses original declarations.
No external plugin or SDK is included in normal packages. See [LICENSES.md](LICENSES.md).
2026-10-26 23:32:04 +01:00
2026-11-06 19:05:14 +01:00
## Focused tests and tools
2026-11-06 15:20:20 +01:00
2026-11-06 19:05:14 +01:00
Build before invoking CTest, or use `check`, which builds the test dependencies:
```sh
2026-11-06 19:05:14 +01:00
cmake --build build --target check --parallel
ctest --test-dir build --output-on-failure -R '^(core|realtime|modern-plugins)$'
ctest --test-dir build --output-on-failure -L gui
cmake --build build --target test-reliability test-recording test-scale test-soak
cmake --build build --target analyze
cmake --build build --target quality-preview builtin-preview
```
2026-11-06 19:05:14 +01:00
Each registered root test also has a `test-NAME` build target (for example
`test-core`, `test-gui`, `test-track-fx`). `test-builtins` aliases `test-builtin`.
`gui` builds the optional main application. Preview targets write WAVs below the
binary directory without playback. Screenshot commands are in
[the gallery](../screenshots/README.md). These commands assume configuration
has already completed; feature-specific docs use the same convention.
2026-11-06 19:05:14 +01:00
To qualify live software routing against an **existing** JACK-compatible server:
```sh
2026-11-06 19:05:14 +01:00
cmake -S . -B build -DXTC_ENABLE_LIVE_TESTS=ON
cmake --build build --parallel
ctest --test-dir build --output-on-failure -L live
./build/test_jack 30 # optional longer software loopback run
```
2026-11-06 19:05:14 +01:00
Live tests are serialized. They neither start/reconfigure the server nor
establish physical-device acceptance. See [AUDIO_ENGINE.md](AUDIO_ENGINE.md).
2026-11-06 19:05:14 +01:00
Developer targets include `benchmark`, `benchmark-compare`, `benchmark-project`,
`benchmark-project-compare`, `test-stress`, `test-stress-plugins`,
`test-plugins-real` and `check-development`. The latter combines the normal
suite, Clang static analysis and a separate sanitizer build. `debug`, `release`
and `test-sanitize` convenience targets configure/build/test child directories;
prefer presets when selecting the directory explicitly. Benchmark/stress cache
variables are `XTC_BENCHMARK_BLOCKS`, `XTC_BENCHMARK_MAX_REGRESSION`,
`XTC_BENCHMARK_BASELINE`, `XTC_PROJECT_BENCHMARK_BASELINE` and `XTC_STRESS_ROUNDS`.
Run benchmarks without concurrent testing/instrumentation for meaningful timing.
2026-11-06 15:20:20 +01:00
2026-11-06 19:05:14 +01:00
For ThreadSanitizer, use a separate configuration with
`-DCMAKE_C_FLAGS='-g -O1 -fsanitize=thread'` and
`-DCMAKE_EXE_LINKER_FLAGS=-fsanitize=thread`, build `test_realtime`/`test_audio`,
and run those binaries. Tool/runtime support depends on the host.
## SDKs, installation and release
See [JUCE.md](JUCE.md) and [STEINBERG.md](STEINBERG.md) for optional SDK
configuration, licenses and qualification limits. Both now build within the root
CMake project; the JUCE bridge links the same PIC C core target.
2026-10-26 23:03:17 +01:00
```sh
2026-11-06 19:05:14 +01:00
cmake -S . -B build/release -DCMAKE_BUILD_TYPE=Release -DXTC_REPRODUCIBLE=ON \
-DCMAKE_INSTALL_PREFIX=/usr
cmake --build build/release --parallel
ctest --test-dir build/release --output-on-failure
DESTDIR="$PWD/build/stage" cmake --install build/release --prefix /usr
DESTDIR="$PWD/build/stage" cmake --build build/release --target uninstall
```
2026-11-06 19:05:14 +01:00
For uninstall, configure with `-DCMAKE_INSTALL_PREFIX=/usr` first when that is
the desired permanent prefix, or invoke the generated `xtc-install.cmake` with
`-DCMAKE_INSTALL_PREFIX=/usr -DXTC_UNINSTALL=ON -P` explicitly. The `--prefix`
install override does not persist in CMake's cache. Prefer setting the prefix at
configure time for a matching install/uninstall pair. Standard `DESTDIR` staging
never enters installed metadata. The audited Python installer retains exact
owned-file inventory, atomic file replacement and symlink protection.
2026-11-06 19:05:14 +01:00
`test-install` and `test-install-layout` stage into temporary directories and
compile installed C/C++ consumers. `dist` exports indexed files; `test-release`
rebuilds two exports; `package-binary` (also aliased as `package`) and `test-package` stage and verify a local
Linux archive. See [RELEASING.md](RELEASING.md) for layout/manifest details.
2026-11-06 19:05:14 +01:00
Clean products with `cmake --build build --target clean`; to discard the cache,
remove only the selected build directory. Never configure in the source tree.
Historical validation entries in ROADMAP describe the build used at that time;
Phase 108 records the CMake migration and its verified results.