InsightSoftwareConsortium / InsightSoftwareConsortium/ITK
ENH: Add tracked CMakePresets.json with common build configurations
- Dominant language
- C++
- Stars
- 1.7k
- Forks
- 748
- Avg merge
- 1d 1h
- Merged PRs (30d)
- 64
Description
## Proposal
Add a tracked `CMakePresets.json` to ITK with common build configurations, reducing the barrier for developers and CI to use consistent, well-tested settings. Currently every developer invents their own cmake flags; a shared presets file would codify the known-good configurations.
Raised by @blowekamp in #6040 — he maintains a local `CMakeUserPresets.json` with presets like "development", "wrapping", "system-libraries", and "doxygen", and asked whether this should be adopted more widely.
### Background
- PR #2870 (merged 2021) added `CMakeUserPresets.json` to `.gitignore`, enabling user-local presets
- No tracked `CMakePresets.json` exists yet — ITK has no shared preset definitions
- The pixi workflow (`pixi run configure-ci`) serves a similar role for CI but doesn't help developers using cmake directly
- CMake presets are supported by VS Code, CLion, Visual Studio, and command-line cmake since CMake 3.19
### Suggested presets
| Preset name | Purpose | Key flags |
|---|---|---|
| `dev` | Fast iteration, tests enabled | `Release`, `BUILD_TESTING=ON`, `BUILD_SHARED_LIBS=ON`, Ninja |
| `dev-debug` | Debug builds with assertions | `Debug`, `BUILD_TESTING=ON`, `BUILD_SHARED_LIBS=ON` |
| `wrapping` | Python wrapping | `Release`, `ITK_WRAP_PYTHON=ON`, `BUILD_SHARED_LIBS=OFF` |
| `minimal` | Fastest possible build | `MinSizeRel`, `BUILD_TESTING=OFF`, `BUILD_EXAMPLES=OFF` |
| `asan` | AddressSanitizer | `RelWithDebInfo`, `-fsanitize=address` |
These would live in `CMakePresets.json` (tracked in git). Developers can extend/override via `CMakeUserPresets.json` (gitignored, per PR #2870).
### Usage
```bash
# Configure with a preset
cmake --preset dev
# Build
cmake --build --preset dev
# Test
ctest --preset dev
```
### Questions to resolve
- Should presets specify the compiler, or leave that to the user/environment?
- Should CI pipelines migrate from ad-hoc cmake flags to presets?
- Should the CLAUDE.md / AI documentation reference presets as the recommended build method?
- Relationship to pixi: should pixi tasks call `cmake --preset` internally?
### References
- #2870 — Added `CMakeUserPresets.json` to `.gitignore`
- #6040 (comment) — @blowekamp's original suggestion
- [CMake Presets documentation](https://cmake.org/cmake/help/latest/manual/cmake-presets.7.html)
Contributor guide
Assessment
This issue has not been assessed yet.