Contributing
Thanks for your interest in contributing to cmakefmt. This page covers the contributor workflow: setting up your environment, building from source, running tests, setting up hooks, and keeping docs accurate.
Feedback and Bug Reports
Section titled “Feedback and Bug Reports”Bug reports, feature requests, and questions are tracked on GitHub Issues:
github.com/cmakefmt/cmakefmt/issues
When filing a bug, include the output of cmakefmt --version, the command you
ran, and a minimal CMake file that reproduces the problem. For formatting
behaviour questions, the Playground is a quick way to
share a reproducible example.
Dev Environment Setup
Section titled “Dev Environment Setup”The repository ships a mise config that pins and installs every required tool — Rust, Node, Python, and all cargo/pip tools — in one step.
Install mise:
# macOSbrew install mise
# macOS / Linux / WSLcurl https://mise.run | shThen activate it in your shell (one-time):
# zshecho 'eval "$(mise activate zsh)"' >> ~/.zshrc && source ~/.zshrc
# bashecho 'eval "$(mise activate bash)"' >> ~/.bashrc && source ~/.bashrcThen from the repo root:
mise installThis installs Rust (stable), Node 22, Python 3.12, cargo-audit,
cargo-deny, cargo-llvm-cov, wasm-pack, pre-commit, reuse, and
bump-my-version — and automatically installs the pre-commit and pre-push
hooks as a post-install step.
Building From Source
Section titled “Building From Source”Clone and build:
git clone https://github.com/cmakefmt/cmakefmt.gitcd cmakefmtcargo buildInstall locally for manual testing:
cargo install --path .Run the full test suite:
cargo testPre-commit Hooks
Section titled “Pre-commit Hooks”Hooks are installed automatically by mise install. To reinstall manually:
pre-commit installpre-commit install --hook-type pre-pushUseful spot checks before pushing:
pre-commit run --all-filescmakefmt --staged --checkThe hook set covers code-quality checks, security scanning (cargo audit,
cargo deny), and REUSE/license metadata validation.
Before/After Examples in Docs
Section titled “Before/After Examples in Docs”When writing or updating documentation that shows a before/after formatting example, always verify the output using the actual CLI or the Playground before committing. Never write an expected “After” from memory — the formatter’s decisions (inline vs. hanging vs. vertical) depend on line-width and command spec, and can be surprising.
# Quick verification from the command lineecho 'your_cmake_snippet()' | cmakefmt -Local Docs Preview
Section titled “Local Docs Preview”Preview the published docs locally:
cd docsnpm installnpm run devThen open the local URL that Astro prints, usually http://localhost:4321.
Changelog
Section titled “Changelog”Add an entry to the ## Unreleased section of CHANGELOG.md for any
user-visible change. The docs site changelog is kept in sync automatically by
scripts/sync-changelog.py.