Skip to content

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.

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.

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:

Terminal window
# macOS
brew install mise
# macOS / Linux / WSL
curl https://mise.run | sh

Then activate it in your shell (one-time):

Terminal window
# zsh
echo 'eval "$(mise activate zsh)"' >> ~/.zshrc && source ~/.zshrc
# bash
echo 'eval "$(mise activate bash)"' >> ~/.bashrc && source ~/.bashrc

Then from the repo root:

Terminal window
mise install

This 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.

Clone and build:

Terminal window
git clone https://github.com/cmakefmt/cmakefmt.git
cd cmakefmt
cargo build

Install locally for manual testing:

Terminal window
cargo install --path .

Run the full test suite:

Terminal window
cargo test

Hooks are installed automatically by mise install. To reinstall manually:

Terminal window
pre-commit install
pre-commit install --hook-type pre-push

Useful spot checks before pushing:

Terminal window
pre-commit run --all-files
cmakefmt --staged --check

The hook set covers code-quality checks, security scanning (cargo audit, cargo deny), and REUSE/license metadata validation.

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.

Terminal window
# Quick verification from the command line
echo 'your_cmake_snippet()' | cmakefmt -

Preview the published docs locally:

Terminal window
cd docs
npm install
npm run dev

Then open the local URL that Astro prints, usually http://localhost:4321.

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.