Direct answer
A CMake preset is a named, versioned set of configure or build inputs. A configure preset can pin the generator, the toolchain file, cache variables, and the binary directory; a build preset names a configure preset plus build arguments and a target. Treat a preset as the contract an agent reads before configuring anything. The concrete win is a build request that resolves to the same inputs every time, recorded in a file the repository owns. The concrete loss is that a preset declares inputs and does not prove the toolchain exists or that the build succeeds; a missing compiler or dependency still fails at configure or build time. The practical implication is that a requested build should be mapped to a preset name, never reconstructed from remembered flags. Ask Claude Code to print the selected preset’s resolved generator, toolchain, cache variables, and inherited base before running any configure.
Why a reconstructed configure costs a day
CMake accepts a long list of flags, and two engineers configuring the same project from memory produce two different build trees. The failure is not an error message. It is a build that works on one machine, a dependency found in one configuration and not another, and a cache that silently holds a value someone set six weeks ago.
The cost compounds when an agent is involved. An agent asked to “build the project” without a preset invents the generator, guesses at defines, and produces a build directory that matches nothing the team uses. The build may even succeed, which is worse, because the success hides the divergence until a consumer reports it.
Evidence and its limits
Official, F037: The CMake Presets Manual describes presets as reusable configure and build settings selectable through CMake command-line options. The presets manual was not full-page fetched in the research pass, so verify exact inheritance and schema details before drafting.
Official: The CMake command-line manual documents the --preset options and the configure and build invocations referenced below.
Official: The generators manual documents the generators a preset can name.
Official: The using dependencies guide documents the dependency-fetching methods a preset’s configure may trigger.
Official, agent loop: Claude Code best practices recommends pairing an edit with a pass-or-fail check. For preset work that check is a configure that reads only the preset’s declared inputs.
Derived, F038: The input inventory and inheritance map below are an editorial checklist, not evidence that the build environment satisfies those inputs.
No claim here depends on a specific CMake version beyond the presets feature, a compiler release, or a benchmark.
What CMake Presets Describe
Presets live in CMakePresets.json and come in several kinds. A configure preset is the one that matters most for reproducibility, because it is where the generator, toolchain, cache variables, and directories are declared. Build and test presets reference a configure preset rather than redeclaring its inputs.
| Preset kind | Declares | References | Purpose |
|---|---|---|---|
| Configure | Generator, toolchain, cache variables, binary dir | Optionally a base preset | Reproducible configure |
| Build | Build arguments, target, configuration | A configure preset | Reproducible build |
| Test | Test arguments | A configure preset | Reproducible test run |
| Workflow | An ordered list of build and test presets | Other presets | One-command sequence |
Treat the table as a division of labor. Configure inputs live once in a configure preset. Everything else points at it. A build request that redeclares a generator on the command line has stepped outside the contract.
Read Configure Presets
Start from the file, not from memory. A configure preset names itself and carries a generator, and most of the review is checking that the named generator and toolchain are the ones the team intends.
cmake --list-presetscmake --preset <name>The list command prints the available presets. Reading CMakePresets.json directly shows the cache variables and binary directory the preset sets, which the list output does not. Both are worth running: the list proves the preset is selectable, and the file shows what it will do.
| Configure input | Where declared | What to record | If absent |
|---|---|---|---|
| Generator | generator |
Named generator | Ask, do not guess |
| Toolchain file | toolchainFile or cache variable |
Path | Ask, do not guess |
| Cache variables | cacheVariables |
Name and value | Note as unset |
| Binary directory | binaryDir |
Path | Note the default |
| Base preset | inherits |
Chain of bases | None |
An absent input is a finding to record, not a gap to fill. F038 records that inventing a toolchain or generator the preset does not specify is the failure mode to avoid.
Inherit Base Presets
Presets can inherit from a base. Inheritance is how a team expresses one common configure with per-variant differences on top, and it is also how an input ends up somewhere a reviewer did not look.
| Preset | Inherits | Adds or overrides |
|---|---|---|
base |
none | Generator, toolchain, shared cache variables |
debug |
base |
Build type Debug |
release |
base |
Build type Release |
release-sanitize |
release |
Sanitizer flags |
Walk the chain top-down before interpreting any value. A cache variable set in base and overridden in a variant is the intended use. A variable set in a variant that contradicts a base value without an explicit override intent is the kind of thing the inheritance map exists to surface.
Record the full chain for the preset under review. A preset that inherits from a base that inherits from another base has three layers of inputs, and a reviewer who reads only the leaf will miss two of them.
Map Generator and Toolchain
The generator determines what build system CMake produces, and the toolchain file determines the compiler and platform. Both are declared in the configure preset, and both are things a preset cannot install.
| Input | Declared by | Verified by | Preset cannot |
|---|---|---|---|
| Generator | generator |
Generators manual | Install the generator |
| Toolchain file | toolchainFile |
File exists on the machine | Create the toolchain |
| Compiler | Toolchain or environment | Compiler invocation | Install a compiler |
| Platform | Toolchain or generator | Build output | Provide an SDK |
The right-hand column is the honest limit. A preset that names a toolchain file that is not on the machine fails at configure, and a preset cannot repair that. Record the generator and toolchain as declared, then verify they exist in the environment before promising a build.
Inventory Cache Variables
Cache variables are the parameters a configure sets. They persist in the build directory, which is why a stale cache is a recurring source of confusion: a variable set once keeps influencing every later configure until it is cleared.
| Cache variable | Value in preset | Purpose | Risk if stale |
|---|---|---|---|
CMAKE_BUILD_TYPE |
Release | Optimization and asserts | Wrong build analyzed |
BUILD_SHARED_LIBS |
On | Library linkage | Mixed linkage |
FETCHCONTENT_FULLY_DISCONNECTED |
Off | Dependency fetching | Network behavior surprises |
CMAKE_INSTALL_PREFIX |
Local path | Install location | Installs to the wrong place |
Examine the cache variables as the contract’s parameters, and record each one’s value for the preset under review. A variable the preset does not set is not necessarily unset; the environment or an earlier configure may have set it. Note the difference.
Ask Claude Code to print the resolved cache for the selected preset rather than to reconstruct the flags. The CMake find_package vs FetchContent guide covers what happens when the configure step fetches dependencies.
Connect Build Presets
A build preset points at a configure preset and adds build-time arguments. The connection is the part that makes the whole sequence reproducible, because a build preset that references the wrong configure preset produces a build from inputs nobody intended.
| Build preset | Configure preset | Build args | Target |
|---|---|---|---|
build-debug |
debug |
none | all |
build-release |
release |
none | all |
build-tests |
debug |
none | tests |
Verify the reference before building. A build preset referencing a configure preset that was renamed is a finding, and the fix is in the file, not in a command-line override that steps outside the contract again.
Review a Preset Request
A preset request is complete when a reviewer can answer four questions from the change or the build description.
| Question | Where the answer lives | Pass condition |
|---|---|---|
| Which preset was requested | Preset name | Named, not reconstructed |
| What inputs it resolves to | Input inventory with inheritance chain | Generator, toolchain, cache variables listed |
| Which build preset applies | Build preset reference | Points at the intended configure preset |
| What the preset does not prove | Honest limit | Toolchain existence and build success named separately |
The last row is the one to keep. A preset that resolves cleanly is not a build that succeeded, and saying so is part of the review rather than a caveat to omit.
A worked walkthrough of one preset request
Consider a repository with a base configure preset naming the Ninja generator and a toolchain file, a debug preset inheriting from base, and a release preset also inheriting from base. An agent is asked to “build the project”. With no preset named, it invents a generator, guesses at the build type, and produces a build directory the team does not use. The build may even succeed.
The correct sequence starts with the preset list, not a configure command.
Run cmake --list-presets and read CMakePresets.json directly. The list proves the preset is selectable. The file shows the cache variables and binary directory the list output does not. For release, record the generator from base, the toolchain from base, the build type from release, and the full inheritance chain.
cmake --list-presets
cmake --preset releaseVerify the toolchain file exists on the machine before promising a build. A preset declares the path and cannot create the file, so a configure that fails on a missing toolchain is a finding about the environment, not about the preset. This is the honest limit F038 records: a preset makes inputs explicit without proving the environment satisfies them.
Run the configure and report the result separately from any build. A configure that resolves cleanly is configure evidence. A build that compiles is build evidence. Reporting them as one success hides which one actually happened.
Anti-patterns that look like presets
Four patterns recur around preset work, and each one hides a decision a reviewer needs to see.
| Pattern | What it looks like | Why it hurts | Do instead |
|---|---|---|---|
| Reconstructing flags from memory | Typing a configure command by hand | Produces a build tree nobody uses | Name the preset |
| Filling in a silent generator | Guessing when the preset omits one | Build directory differs from the team’s | Record as unset and ask |
| Reading only the leaf preset | Ignoring the inheritance chain | Misses inputs set in the base | Walk the full chain |
| Treating configure as build success | “It configured, so it builds” | Configure and build are separate evidence | Report them apart |
Filling in a silent generator deserves the most caution. F038 records inventing a toolchain or generator the preset does not specify as the failure to avoid, because the guessed value becomes an undocumented assumption baked into a build directory.
None of these is a CMake defect. They are review hazards, and the preset list plus the inheritance map are what catch them.
A runbook for the next build request
The checklist earlier in this post is the pass condition. The runbook below is the sequence to follow when a build request arrives.
Find the preset that matches the request. A request with no preset match is a question for the team, not a command line to reconstruct.
Read CMakePresets.json and walk the full inheritance chain for the selected preset. Record the generator, toolchain, cache variables, and binary directory as resolved.
Verify the toolchain file and generator exist in the environment. A preset cannot install either, and a missing tool is an environment finding.
Run the configure using the preset name and record the result. If a build preset is requested, confirm which configure preset it references before building.
Report configure and build as separate evidence, and name what the preset does not prove.
The runbook takes minutes and produces the artifacts a reviewer needs: the resolved input inventory and the separation of configure from build. Skipping it produces a build directory that matches nothing the team uses.
Where this habit pays across the batch
The preset-first habit in this post is the same one the rest of the batch applies to different constructs. CMake find_package vs FetchContent asks for a resolution trace before choosing a dependency path, and Conan CMakeDeps asks for the target contract before a layout change.
The JVM posts apply the same discipline to version and variant policy. Gradle constraints vs dependencies asks for a resolved-graph diff, Gradle capability conflicts asks for a component inventory, Gradle variant attributes asks for the consumer request, and Maven optional dependencies asks for an import scan.
The .NET posts apply it to package versions and generated code. NuGet central package management asks for a props and override inventory, .NET multi-targeting asks for a per-framework matrix and build, and C# source generators asks for the generator’s input change before reading its output.
That consistency is deliberate. The constructs differ, but the shape is the same: read the evidence the tool already produces, then make the smallest change the evidence supports.
The same shape extends to the ecosystems covered in earlier batches. On the Python side, dependency groups versus extras separates local workflow requirements from published optional features, and stub drift audits a package’s declared types against its documented runtime surface. TypedDict boundaries covers separating truly optional keys from missing data before replacing broad dictionary annotations.
On the Go side, module compatibility covers keeping an exported API change inside an import contract, and graph pruning covers why an indirect dependency entry is graph metadata rather than something to delete. Workspace boundaries covers deciding what belongs in go.work versus what stays a module requirement.
On the Rust side, feature unification covers mapping which optional APIs a workspace build actually exposes, and workspace inheritance covers centralizing metadata without hiding crate-local exceptions. Profile boundaries covers separating diagnostic and optimization settings from options that change observable program behavior.
Recording build inputs has a direct analog in Cargo build scripts, where the same “declare the inputs a build consumes” question applies to build-time scripts rather than configure presets. Both are input-contract questions, and both reward reading the declared inputs before running the build.
Reading a configure output as evidence
Configure output is worth reading deliberately, because it is the evidence that the resolved inputs produced a working build tree. Three parts carry the review.
The generator line confirms which generator the preset resolved to. Compare it against the generator you recorded from the inheritance chain. A mismatch means a command-line flag or an environment variable overrode the preset, and that is a divergence from the contract worth naming.
The compiler detection lines show which compiler the toolchain produced. This is where a missing or unexpected compiler surfaces, and it is configure evidence rather than build evidence. A configure that reaches compiler detection has satisfied more of the preset than one that failed earlier, but neither is a build.
The cache variables section lists what was actually written to the cache, including variables the preset did not set. Read this against the inventory. A variable you expected to be set and is not, or one you did not expect and is, is the divergence to investigate before building.
| Configure output | What it confirms | What it does not |
|---|---|---|
| Generator line | The resolved generator | That the build will run |
| Compiler detection | The toolchain produced a compiler | That the compiler is the intended one |
| Cache variables | What the cache now holds | That every variable was preset-declared |
A configure read this way separates preset evidence from environment evidence. The same separation answers the question in the runbook above: a configure failure on a missing tool is an environment finding, and the preset is not at fault.
Working alongside the review bottleneck
A build request with a named preset and a pasted input inventory is cheap to review. A request described as “built the project” is a reviewer reproducing the work, and reproduction is the expensive part. The Claude Code code review bottleneck covers what happens when generation outpaces the review that has to accept it.
The same reasoning appears in Claude Code cost per verified change, which treats verified work as a separate unit from generated output. A resolved input inventory is a verified unit. A “trust me, it builds” description is not.
When the review queue is long enough that verification slips, the failure mode is a merge that nobody actually checked. Prevent false success from passing tests covers the case where a successful configure is the only evidence, and a preset is exactly the case where configure proves less than it appears to.
The concrete win, loss, and implication
The concrete win is a build request that is a name. A new contributor or an agent asked to build the project runs one preset and gets the inputs the team agreed on, recorded in a file the repository versions.
The concrete loss is the gap between declaration and environment. A preset declares inputs and cannot install a compiler, create a toolchain file, or fetch a dependency the network will not provide. A configure that fails on a missing tool is a finding about the machine, not about the preset, and the distinction has to be stated rather than glossed.
The practical implication is that configure inputs are a contract worth writing down once. Teams that keep CMakePresets.json as the only path to a build resolve fewer “why does this configure differently on my machine” questions. Teams that rely on remembered flags pay for the difference in divergent build trees.
Related reading on build inputs and boundaries
Build-input questions continue in the C++ posts. CMake find_package vs FetchContent covers choosing a dependency boundary, and Conan CMakeDeps covers keeping consumer target names stable while package layout changes.
The JVM posts cover the same input-contract discipline in another ecosystem. Gradle constraints vs dependencies covers version policy without graph edges, and Gradle variant attributes covers matching a consumer to the right artifact.
The .NET posts cover version and generated-code boundaries: NuGet central package management, .NET multi-targeting, and C# source generators.
Review habits sit upstream of every configure. Ask what Claude Code verification requires before calling a build reproducible, and prevent false success from passing tests when a configure that runs is the only evidence.
Checklist before running a preset build
Run this list against the request. Each row is a pass condition.
| Check | Pass condition | If it fails |
|---|---|---|
| Preset named | Selected by name, not flags | Find the matching preset |
| Generator | Named in the resolved chain | Record as unset, do not guess |
| Toolchain | Named and present on the machine | Verify the file exists |
| Cache variables | Each recorded with value | Inventory the chain |
| Inheritance chain | Full chain recorded | Walk up from the leaf |
| Build preset reference | Points at the intended configure preset | Fix the reference in the file |
| Build result | Treated as separate from configure | Report configure and build apart |
Working with Claude Code on a preset request
Give the agent the requested build in plain terms and the repository root. Ask for the preset list and the resolved input inventory, including the inheritance chain, before running any configure. The agent session works best when the check is a configure that reads only the preset’s declared inputs, which is the shape the official best-practices guidance recommends.
Ask the agent to report four things when it finishes. The preset name it selected. The generator, toolchain, and cache variables the chain resolves to. The build preset it used and which configure preset that references. What the preset does not prove, named as toolchain existence and build success. A report that omits the last item has overstated the evidence.
Reviewing whether the resolved inputs match the team’s intent is the reviewer’s job. The agent reads the JSON and can run configure, but deciding which generator and toolchain the project should use is a design decision. The Claude Code verification guide covers the review questions: what changed, what proves it, and what was not checked.
Data gap and future update
F037 rests on a presets manual that was not full-page fetched, so exact schema keys, inheritance semantics, and version requirements should be rechecked against the current CMake documentation before a real change. A future update should record, per repository, which presets exist, which base each inherits from, and the CMake version the observations were taken at.
No build-time measurement, toolchain benchmark, or configure-duration claim is made here. Whether a named generator is the fastest for a project is out of scope and requires a separate measurement pass.
One AI API Key option for OpenAI-format agents
Claude Code uses an Anthropic-format route, so the One AI free model IDs are not a Claude Code model source. The packet records Claude IDs as unavailable on 2026-11-27.
OpenAI-format agents have a separate route: One AI API Key offers https://api.oneaiapikey.com/v1, one key, and 46 live free IDs. It is a different client and request format, not a workaround for Claude Code authentication. Check the free model list and eligibility notes before choosing an agent route, or read the quickstart for the request shape.
FAQ
Does a preset install the tools it names?
No. A preset declares the generator, toolchain, and cache variables to use. A missing compiler or toolchain file still fails at configure, and installing it is a separate environment step.
What should I do when a preset does not name a generator?
Record it as unset and ask rather than filling it in. F038 records inventing a toolchain or generator the preset is silent about as the failure to avoid, because a guessed generator produces a build tree the team does not use.
Can one preset inherit from another?
Yes, through the inherits field. Inheritance is how a team expresses one common configure with per-variant differences. Record the full chain, because a reviewer who reads only the leaf preset misses the base inputs.
Why did my build use stale cache values?
Cache variables persist in the binary directory across configures. A variable set once keeps influencing later configures until the cache is cleared or overridden. The cache variable inventory is what makes this visible.
Does a preset guarantee the build succeeds?
No. A preset resolves the inputs and the configure can still fail on a missing tool or dependency, and a successful configure is not a successful build. Report configure and build as separate evidence.
Related reading in this batch
This post is one of ten build-system and dependency guides written together. CMake find_package vs FetchContent and Conan CMakeDeps complete the C++ set.
The JVM posts cover dependency and variant boundaries: Gradle Constraints vs Dependencies, Gradle Capability Conflicts, Gradle Variant Attributes, and Maven Optional Dependencies.
The .NET posts cover version and generated-code boundaries: NuGet Central Package Management, .NET Multi-Targeting, and C# Source Generators.
More from this batch
- CMake find_package vs FetchContent: Choose a Dependency Boundary
- Conan CMakeDeps: Keep Consumer Targets Stable for Claude Code
- Gradle Variant Attributes: Match Consumers to the Right Artifact
- NuGet Central Package Management: Plan a Cross-Project Migration
- C# Source Generators: Review Generated Contracts With Claude Code
More Claude Code troubleshooting
- Python Protocols vs ABCs: Preserve Interface Contracts With Claude Code
- pnpm Peer Diagnostics: Read Resolution Reports Before Claude Code Pins
- TypeScript Project References: A Claude Code Boundary Guide
- OpenAPI Generator Customization: Keep Templates and Config in Sync
- GraphQL Code Generator Client Presets: Review Generated Boundaries
- Protocol Buffer Reserved Fields: A Claude Code Wire Compatibility Guide
- sqlc Query Annotations: Align SQL and Generated Types With Claude Code
- Django Deprecation Runway: Plan Framework Maintenance With Claude Code
- Rails Upgrade Sequence: Order Major Changes With Claude Code
- Angular Update Guide: Build a Migration Plan With Claude Code
Sources
- Official: CMake Presets Manual, supporting F037 on presets as reusable configure and build settings.
- Official: CMake Command-Line Manual,
--presetoptions for configure and build. - Official: CMake Generators Manual, generators a preset can name.
- Official: CMake: Using Dependencies Guide, dependency fetching during configure.
- Official: Claude Code Docs: Best Practices, supporting the pass-or-fail configure check.