Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Migration From cmake-format

Switching to cmakefmt is designed to be straightforward. The goal is easy adoption, not a risky big-bang rewrite — roll out incrementally, compare output at each step, and flip the switch once you are satisfied.

  1. start with --check in CI on a small target directory
  2. generate a starter config with --dump-config (YAML by default, toml available explicitly if needed)
  3. if you already have a cmake-format config file, convert it automatically with --convert-legacy-config
  4. compare output on a representative corpus
  5. switch pre-commit and CI once the output looks good

CLI Mapping

cmake-format intentcmakefmt equivalent
format file to stdoutcmakefmt FILE
in-place formatcmakefmt -i FILE
CI checkcmakefmt --check PATH
recursive target filteringcmakefmt --path-regex REGEX PATH
convert old config filecmakefmt --convert-legacy-config OLD.py > .cmakefmt.toml
disable formatting regionssupports both cmake-format and cmakefmt spellings

Compatibility Notes

  • the goal is easy adoption, not output identity
  • the built-in command registry is audited through CMake 4.3.1
  • --config is still accepted as an alias for --config-file
  • --path-regex replaces the older --file-regex
  • any unsupported compatibility should be treated as a bug, not silently assumed

Operational Advice

Roll out with snapshots or branch-local diffs first. Formatter migrations become painful when the first exposure is a large repository-wide rewrite without comparison data. Start small, build confidence, then go wide.