cmakefmt-rust 1.5.0

A fast, correct CMake formatter
Documentation

A fast, correct CMake formatter — cmake-format, reimagined in Rust.

cmakefmt demo

Why cmakefmt?

  • 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-format across 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.

Install

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          # Windows

Conda, Docker, pre-built binaries, and full setup notes are documented at Installation.

Quick start

cmakefmt --in-place .   # format every CMake file in the project

The full CLI reference, configuration schema, editor integrations, and migration guide from cmake-format all live at cmakefmt.dev.

GitHub Action

The official cmakefmt-action wraps the binary for use in CI workflows:

- uses: actions/checkout@v6
- uses: cmakefmt/cmakefmt-action@v2

That 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 staged

For the complete list of inputs and recommended rollout patterns, see the cmakefmt-action README.

Documentation

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

Status

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.

License

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.