A fast, correct CMake formatter — cmake-format, reimagined in Rust.
- Drop-in replacement for
cmake-format. A single native binary with the same workflows and no Python environment to manage. - 100× faster. Geometric-mean speedup over
cmake-formatacross a corpus of 14 large open-source repositories (see Performance). - Workflow-first design.
--check,--diff,--staged,--changed, semantic verification, JSON/SARIF/JUnit reports, an LSP server, and a GitHub Action are all first-class features rather than scripted afterthoughts.
brew install cmakefmt/cmakefmt/cmakefmt # macOS / Linux (Homebrew)
pip install cmakefmt # any platform with Python
cargo install cmakefmt-rust # any platform
winget install cmakefmt.cmakefmt # WindowsConda, Docker, pre-built binaries, and full setup notes are documented at Installation.
Building the current source checkout or next release requires Rust 1.89 or newer. Prebuilt binaries and wheels do not require Rust.
cmakefmt --in-place . # format every CMake file in the projectThe full CLI reference, configuration schema, editor integrations, and
migration guide from cmake-format all live at
cmakefmt.dev.
Wrapped target_sources(FILE_SET ...) calls keep TYPE, BASE_DIRS, and FILES
on separate nested lines; calls that fit on one line stay inline.
The official cmakefmt-action
wraps the binary for use in CI workflows:
- uses: actions/checkout@v6
- uses: cmakefmt/cmakefmt-action@v2That snippet is the strict whole-repo check: it fails the job and emits inline PR annotations for any file that would change under formatting. The action also supports other modes and file-selection scopes:
- uses: cmakefmt/cmakefmt-action@v2
with:
mode: diff # check, diff, fix, or setup
scope: changed # all, changed, or stagedFor the complete list of inputs and recommended rollout patterns, see the
cmakefmt-action README.
The full documentation lives at cmakefmt.dev.
| Page | Description |
|---|---|
| Getting Started | First format in under a minute |
| Installation | Every install channel and setup notes |
| CLI Reference | Every flag, subcommand, exit code |
| Config Reference | Full config schema with examples |
Migration from cmake-format |
Incremental rollout guide |
| Editor Integration | VS Code, Neovim, Helix, Zed, Emacs |
| Comparison | vs cmake-format and gersemi |
| Performance | Benchmark methodology and numbers |
| Library API | Embed cmakefmt in Rust code |
| Troubleshooting | Common issues and debug workflow |
| Playground | Try cmakefmt in your browser |
| Contributing / Changelog | How to help; what changed |
cmakefmt is stable and actively maintained. The built-in command spec is
audited against CMake 4.3.1. The release contract and per-channel support
levels are documented at Release.
cmakefmt is dual-licensed under MIT or
Apache-2.0, at your option.
This project is independent from other Rust crates of the same name —
it is not affiliated with
azais-corentin/cmakefmt or
yamadapc/cmakefmt.
