Skip to content

ENH: Add tracked CMakePresets.json with common build configurations #6077

@hjmjohnson

Description

@hjmjohnson

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 ENH: Allow users to have a CMakeUserPresets.json file #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

# 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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions