Skip to content

Add CMakePresets.json #392

Description

@Bronek

The repo has no committed, runnable spelling of its build configurations. They exist three times over, none of them canonical:

  • .github/workflows/build.yml assembles them from nested GitHub ternaries (build.yml:92);
  • CONTRIBUTING.md describes the options in prose;
  • the contributor types a third spelling by hand.

A CMakePresets.json would make one spelling authoritative. cmake_minimum_required(VERSION 3.25) admits schema v6, so there is no version constraint.

Worth covering:

  • configure presets for the everyday builds — the default build, coverage, sanitizers, docs, and the LIBFN_CXX26 mode;
  • presets that bundle the option dependencies the CMake code already enforces, so an invalid combination cannot be assembled by hand: VALIDATE_CXX23 requires LIBFN_TESTS; VALIDATE_CXX26 requires LIBFN_TESTS and LIBFN_CXX26; LIBFN_COVERAGE and LIBFN_DOCS require LIBFN_TESTS and a top-level build; LIBFN_SANITIZERS requires a Debug build type;
  • build and test presets, so cmake --build --preset and ctest --preset work.

The value is mostly in migrating CI onto them — that is what retires the ternary chains and collapses the three spellings into one. A preset file that CI does not use becomes a second source of truth and drifts, while looking authoritative; so this should not land as a preset file alone.

Two design points to settle first:

  • The matrix is heterogeneous. Linux containers with explicit compilers, macOS/AppleClang, and MSVC taking its generator from the matrix and building multi-config. Covering that needs either a combinatorial preset set or preset inheritance plus matrix-supplied -D overrides — and the latter partly defeats the purpose.
  • binaryDir is conventionally derived from ${sourceDir}. A single worktree reachable from two environments — a host and a devcontainer, say — resolves the same preset to the same physical build tree, whose cache pins both an absolute source path and a toolchain. Preset naming has to keep those apart, or the two environments will fight over one directory.

Assisted-by: Claude:claude-opus-5

Metadata

Metadata

Assignees

No one assigned

    Labels

    release-0.2Planned for release 0.2toolchainSupported compilers, tools or workflows

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions