FAQ
How is cmakefmt different from cmake-format?
Section titled “How is cmakefmt different from cmake-format?”cmakefmt is a from-scratch rewrite in Rust. It is faster (10–100x on large
codebases), actively maintained, and supports the same config format with
full conversion via cmakefmt config convert. It also includes an LSP server,
JSON Schema for config autocomplete, and a browser playground.
How is cmakefmt different from gersemi?
Section titled “How is cmakefmt different from gersemi?”gersemi is another CMake formatter written in Python. cmakefmt is
significantly faster (native binary), supports legacy cmake-format config
conversion, and has broader editor integration (LSP server, VS Code
extension, pre-commit hook).
Can I use my existing cmake-format config?
Section titled “Can I use my existing cmake-format config?”Yes. Run cmakefmt config convert .cmake-format.yaml to convert it.
Most options are carried forward; lint and encode options are intentionally
excluded because cmakefmt is a formatter, not a linter.
Which config options are not supported?
Section titled “Which config options are not supported?”The [lint] section (cmakefmt is a formatter, not a linter), [encode]
section (UTF-8 is assumed), [parse].vartags / [parse].proptags
(linting-only), and [format].layout_passes (covered by always_wrap and
per-command overrides).
Does cmakefmt change the semantics of my CMake files?
Section titled “Does cmakefmt change the semantics of my CMake files?”No. cmakefmt only changes whitespace, indentation, casing, and comment
layout. It never modifies command names, arguments, or logic.
How do I disable formatting for a section?
Section titled “How do I disable formatting for a section?”Use # cmakefmt: off and # cmakefmt: on barrier comments. The aliases
# cmake-format: off/on and # fmt: off/on also work.
Does cmakefmt support custom commands?
Section titled “Does cmakefmt support custom commands?”Yes. Define command specs in the commands: section of your
.cmakefmt.yaml (or .cmakefmt.toml). See the
custom command specs section of the
config reference for the spec schema and worked examples.
Can I use cmakefmt in CI?
Section titled “Can I use cmakefmt in CI?”Yes. Use cmakefmt --check . (exits non-zero if files need formatting) or
the official GitHub Action
(cmakefmt/cmakefmt-action@v2).
Is there an LSP server?
Section titled “Is there an LSP server?”Yes. Run cmakefmt lsp to start a stdio LSP server that provides
format-on-save and range formatting in any editor with LSP support. See the
editor integration page for setup instructions.
Where can I get help?
Section titled “Where can I get help?”Open an issue on GitHub or start a discussion in GitHub Discussions.
Docs track main. For historical docs, check out a release tag in
the repository and build
docs/ locally.