Share CMake configure and build settings with presets files
Answer: A common problem for CMake users is how to share settings with other people for the usual ways to configure a project. CMake added preset files in 3.19 for those settings. CMake supports two main files, CMakePresets and CMakeUserPresets, both json. Specify --preset when you invoke CMake.
Two files
Both files live in the project's root directory. They have exactly the same format. They are optional, though at least one must be present if --preset is specified. The first file is meant to specify project-wide build details. The second is meant for developers to specify their own local build details. CMakePresets may be checked into a version control system. CMakeUserPresets should not be checked in.
| project-wide | local | |---|---| | build details | build details | | version control | should NOT be checked in | | root directory | root directory |
Includes and inheritance
When both files are present, the user file implicitly includes the project-wide file. Include cycles are not allowed among files. From 4.4, --presets-file can name another file, and then presets in the two default files will be ignored.
The C++ graph checks preset inheritance for cycles. It also bubbles up fields through the inheritance hierarchy, then verifies that each preset has the required fields. The types include ConfigurePreset, BuildPreset, TestPreset, PackagePreset, and WorkflowPreset.
See also
Claims
- id: C1 claim: CMakePresets.json and CMakeUserPresets.json store common configure options that can be shared. source: S1 evidence: "that allow users to specify common configure options and share them with others"
- id: C2 claim: CMakeUserPresets.json is for local developer details and should not be checked in. source: S1 evidence: "`
CMakeUserPresets.json` should NOT be checked in"
- id: C3 claim: CMake's presets graph checks inheritance for cycles and inherited required fields. source: S2 evidence: "Check preset inheritance for cycles"
Sources
- [S1] cmake-presets(7). CMake docs. https://cmake.org/cmake/help/latest/manual/cmake-presets.7.html . License: BSD-3-Clause. Accessed 2026-11-19.
- [S2] cmCMakePresetsGraph.cxx. CMake source. https://raw.githubusercontent.com/Kitware/CMake/master/Source/cmCMakePresetsGraph.cxx . License: BSD-3-Clause. Accessed 2026-11-19.
License: this note is CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Summary by iinventedlight (AI-assisted). Sources: CMake docs, cmake-presets(7); CMake source, cmCMakePresetsGraph.cxx. BSD-3-Clause; BSD-3-Clause. Text was condensed and changed from the originals.
License: CC-BY-4.0 · Summary by iinventedlight (AI-assisted). Sources: CMake docs, cmake-presets(7); CMake source, cmCMakePresetsGraph.cxx. BSD-3-Clause; BSD-3-Clause.
Cite this
iinventedlight. 2026. "Share CMake configure and build settings with presets files." iinventedlight Library, iil:note:xd2mhnht, version of 2026-11-19. https://iinventedlight.com/library/notes/cmake-presets/. License: CC-BY-4.0.
@misc{iil_note_xd2mhnht,
author = {{iinventedlight}},
title = {{Share CMake configure and build settings with presets files}},
howpublished = {iinventedlight Library},
year = {2026},
date = {2026-11-19},
url = {https://iinventedlight.com/library/notes/cmake-presets/},
note = {Permanent ID iil:note:xd2mhnht. License: CC-BY-4.0.},
}
Spotted a mistake? Use the MCP feedback tool or email hello@iinventedlight.com. Or Report a correction (no account needed).
Extra files beside this note
These files use this note's license, shown below. Paper extras retain their reproduction status; a link is not a reproduction.
- cmake-presets.table.json (table; CC-BY-4.0)
- cmake-presets.schema.json (schema; CC-BY-4.0)
For language models and agents: start at /llms.txt | /agents.md | /.well-known/agent-library.json. This page in Markdown: /library/notes/cmake-presets.md.