Installation
Get cmakefmt running, wire it into your project, and never worry about CMake
formatting again.
Current Installation Options
Section titled “Current Installation Options”Homebrew
Section titled “Homebrew”Recommended for macOS users — no Rust toolchain needed:
brew install cmakefmt/cmakefmt/cmakefmtReference install path for developers already using Rust, works on any platform:
cargo install cmakefmt-rustVerify the binary is on your path:
cmakefmt --versioncmakefmt --helpYou can also install from a local checkout — for development, benchmarking, or reviewing changes:
cargo install --path .pip install cmakefmtThis installs the native cmakefmt binary into your environment’s bin/
directory. No Python runtime overhead — the binary is the same Rust-compiled
formatter available via Homebrew and Cargo.
Pre-built wheels are available for Linux (x86_64, aarch64), macOS (x86_64, aarch64), and Windows (x64). On unsupported platforms, pip falls back to building from the source distribution, which requires a Rust toolchain.
conda-forge
Section titled “conda-forge”conda install -c conda-forge cmakefmtBuilt from source by conda-forge. Future version bumps are handled automatically by the conda-forge autotick bot.
winget
Section titled “winget”Recommended for Windows users — installs a native binary, no Rust toolchain or Python environment needed:
winget install cmakefmt.cmakefmtThe package is published in the microsoft/winget-pkgs
community repository. New manifests are submitted automatically when each
GitHub Release is published, so the available version closely tracks the
latest tagged release once the upstream PR is merged.
Pre-built Binaries
Section titled “Pre-built Binaries”Native binaries for Linux, macOS, and Windows are published to
GitHub Releases.
Download the .zip / .tar.gz for your platform, extract, and place the
binary on your PATH.
Build From Source
Section titled “Build From Source”git clone https://github.com/cmakefmt/cmakefmtcd cmakefmtcargo build --release./target/release/cmakefmt --helpThis is the right path if you are actively developing cmakefmt, reviewing
changes, or benchmarking local modifications.
Support Levels
Section titled “Support Levels”The release plan separates channels into explicit support levels so users know what to trust:
| Channel | Support level | Notes |
|---|---|---|
Homebrew (cmakefmt/cmakefmt) | Officially maintained | Recommended for macOS users. Ships completions and man page. |
cargo install cmakefmt-rust | Officially maintained | Reference install path for developers already using Rust. |
pip install cmakefmt | Officially maintained | Native binary via pre-built wheel. |
conda install -c conda-forge cmakefmt | Community maintained | Built from source; autotick bot tracks releases. |
winget install cmakefmt.cmakefmt | Officially maintained | Recommended on Windows. Manifest lives in microsoft/winget-pkgs; new versions are submitted automatically on each release. |
| GitHub Releases binaries | Officially maintained | Native binaries for Linux, macOS, and Windows. |
| Docs site / CLI reference | Officially maintained | Stays in lock-step with each tagged release. |
| Scoop | Planned | Not published yet. |
| Additional package managers (AUR, Nix, containers, etc.) | Automated or best-effort | Useful channels, but not the first rollout priority. |
Shell Completions
Section titled “Shell Completions”Release archives include shell completion scripts for the supported shells:
cmakefmt.bashfor Bash_cmakefmtfor Zshcmakefmt.fishfor Fish
The Zsh file intentionally uses the conventional completion-function name
_cmakefmt rather than a .zsh suffix.
You can also generate the completion files yourself from any installed binary:
cmakefmt completions bash > cmakefmt.bashcmakefmt completions zsh > _cmakefmtcmakefmt completions fish > cmakefmt.fishSource the file from your .bashrc or .bash_profile:
cmakefmt completions bash > ~/.local/share/bash-completion/completions/cmakefmtOr for a system-wide install (requires write access):
cmakefmt completions bash | sudo tee /etc/bash_completion.d/cmakefmt > /dev/nullPlace the file somewhere on your fpath and reload completions:
cmakefmt completions zsh > ~/.zfunc/_cmakefmtThen add the following to your .zshrc if ~/.zfunc is not already on fpath:
fpath=(~/.zfunc $fpath)autoload -Uz compinit && compinitFish looks for completions in a fixed directory — just drop the file there:
cmakefmt completions fish > ~/.config/fish/completions/cmakefmt.fishFish picks up the new file automatically without a shell restart.
First Project Setup
Section titled “First Project Setup”Dump a starter config into your repo root:
cmakefmt config dump > .cmakefmt.yamlWhy YAML by default? For larger configs, YAML requires less punctuation and is
more readable with nested custom-command specs. TOML is still available via
config dump --format toml if you prefer it.
Do a dry run — check your whole project without rewriting a single file:
cmakefmt --check .When you are happy with what you see, apply the formatting:
cmakefmt --in-place .Typical Local Workflow
Section titled “Typical Local Workflow”The commands you will reach for every day:
cmakefmt --check .cmakefmt --in-place .cmakefmt --verify CMakeLists.txtcmakefmt --cache --check .cmakefmt --require-pragma --check .cmakefmt --staged --checkcmakefmt --changed --since origin/main --checkWhat each one does:
--check .: CI-safe validation for a repository or directory--in-place .: rewrite all discovered CMake files, with semantic verification by default--verify CMakeLists.txt: do a safe stdout-format run when you want the extra parse-tree check--cache --check .: speed up repeated whole-repo checks when your config is stable--require-pragma --check .: roll formatting out gradually, only touching opted-in files--staged --check: pre-commit guard — only touches staged files--changed --since origin/main --check: PR-scoped check for branch-only changes
CI-Friendly Shell Usage
Section titled “CI-Friendly Shell Usage”The simplest CI baseline:
cmakefmt --check .For quieter CI logs:
cmakefmt --check --quiet .For machine-readable output that scripts or dashboards can consume:
cmakefmt --check --report-format json .Editor And Stdin Workflows
Section titled “Editor And Stdin Workflows”Many editor integrations pipe a buffer through stdin rather than passing a real
file path. Use --stdin-path to give config discovery and diagnostics the
on-disk context they need:
cat src/CMakeLists.txt | cmakefmt - --stdin-path src/CMakeLists.txtThis is also the right pattern for ad-hoc scripts and custom editor commands.
Config Bootstrap Tips
Section titled “Config Bootstrap Tips”If your project uses many custom CMake functions or macros:
- start from
config dump - keep the file as
.cmakefmt.yaml - define command syntax under
commands: - use
per_command_overrides:only for layout and style tweaks
If you are debugging config discovery:
cmakefmt config path src/CMakeLists.txtcmakefmt config show src/CMakeLists.txtcmakefmt config explainUpgrade And Uninstall
Section titled “Upgrade And Uninstall”Upgrade a Homebrew install
Section titled “Upgrade a Homebrew install”brew updatebrew upgrade cmakefmtRemove a Homebrew install
Section titled “Remove a Homebrew install”brew uninstall cmakefmtbrew untap cmakefmt/cmakefmtUpgrade a local source install
Section titled “Upgrade a local source install”git pull --ff-onlycargo install --path . --forceRemove a Cargo-installed binary
Section titled “Remove a Cargo-installed binary”cargo uninstall cmakefmt-rustPin a specific release in CI later
Section titled “Pin a specific release in CI later”Once release tags exist, prefer explicit version pins:
cargo install cmakefmt-rust --version <tagged-version>The release docs and release notes will also publish SHA-256 sums for release artifacts so non-Cargo installs can verify downloads.
Troubleshooting Install Issues
Section titled “Troubleshooting Install Issues”cmakefmt is not found after cargo install
Section titled “cmakefmt is not found after cargo install”Make sure Cargo’s install bin directory is on your PATH.
The formatter is using the wrong config
Section titled “The formatter is using the wrong config”cmakefmt config path path/to/CMakeLists.txtcmakefmt config explainA hook or script only sees stdin and ignores my project config
Section titled “A hook or script only sees stdin and ignores my project config”Pass --stdin-path with the buffer’s real project-relative path.
I want TOML instead of YAML
Section titled “I want TOML instead of YAML”cmakefmt config dump --format toml > .cmakefmt.tomlYAML is the recommended default because it is more readable for larger configurations with nested custom command specs.
Docs track main. For historical docs, check out a release tag in
the repository and build
docs/ locally.