cmakefmt
cmake-format, reimagined.Why cmakefmt?
Section titled “Why cmakefmt?”Up-to-date specs
Built-in specs for 150+ commands, audited against
CMake 4.3. cmake-format hasn't been updated since
2021 and misses many modern commands and arguments.
Whole-project, instant
Recursive discovery and parallel formatting by default. Point it at your project root — no file lists, no wrapper scripts.
Zero dependencies
One binary. No Python, no virtualenv, no dependency drift. Drop it in CI and forget about it.
Editor-ready
Built-in LSP server, VS Code extension, format-on-save for Neovim, Helix, Zed, and Emacs — plus config autocomplete via SchemaStore.
Built for workflows
--check, --diff,
--staged, --explain,
Git-aware file selection, semantic verification, JSON
reporting — all first-class.
One-command migration
Already using cmake-format?
cmakefmt config convert translates your existing
config — no manual rewriting.
Quick Start
Section titled “Quick Start”❯ brew install cmakefmt/cmakefmt/cmakefmt ❯ cargo install cmakefmt-rust ❯ pip install cmakefmt Or download a pre-built binary from GitHub Releases.
Then — just point it at your project. It discovers all CMake files recursively and formats them in parallel:
cmakefmt config init # generate a starter .cmakefmt.yamlcmakefmt --check . # dry-run: just show which files would changecmakefmt . # dry-run: preview formatted output; changed lines shown in bluecmakefmt --diff . # dry-run: view a unified diff of what would change (like `git diff`)cmakefmt --in-place . # apply formatting across the whole projectcmakefmt --staged --check # use in pre-commit hookscmakefmt --path-regex 'src/.*' . # format CMake files only under src/Before and After
Section titled “Before and After”Formatter Demo
Watch rough CMake settle into a stable layout.
The landing-page animation shows the kind of cleanup cmakefmt performs in one pass:
casing becomes consistent, simple lists collapse, and larger calls wrap into a readable structure.
CMAKE_MINIMUM_REQUIRED(VERSION 3.20)
Project(myproject LANGUAGES CXX)
set(SOURCES src/main.cpp
src/utils.cpp
src/parser.cpp)
target_link_libraries(mylib PUBLIC
Boost::filesystem Boost::system fmt::fmt
PRIVATE
spdlog::spdlog)
IF(WIN32)
MESSAGE(STATUS "building on Windows")
ENDIF()
Performance
Section titled “Performance”See Performance for the full methodology and benchmark environment.
Want to try it without installing? Open the Playground →
Where to Go Next
Section titled “Where to Go Next”New to cmakefmt?
Migrating from cmake-format?
Embedding cmakefmt as a library?
Docs track main. For historical docs, check out a release tag in
the repository and build
docs/ locally.