InsightSoftwareConsortium / InsightSoftwareConsortium/ITK

ENH: Add tracked CMakePresets.json with common build configurations

Open
#6,077 0 comments 0 reactions 0 assignees View on GitHub
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

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.