gersemi
A formatter to make your CMake code the real treasure
What it is and what it does
gersemi is a standalone CMake code formatter that reads CMake source files and rewrites them according to configurable style rules. It operates as a command-line tool that can check, diff, or in-place reformat CMakeLists.txt files and .cmake modules, with support for parallel processing across multiple files. The formatter respects configuration files (.gersemirc) placed in project directories and allows fine-grained control over line length, indentation style, list expansion behavior, and custom command definitions.
The tool is designed for developers and build system maintainers who want to enforce consistent CMake code style across projects. It integrates into CI/CD pipelines for formatting checks, supports stdin/stdout workflows, and includes caching to speed up repeated runs on unchanged files. Configuration can be stored in version-controlled .gersemirc files or supplied via command-line arguments, making it suitable for team environments.
Use it for:
- Enforce consistent CMake formatting across a multi-module C/C++ project as part of CI/CD.
- Reformat legacy CMakeLists.txt files to a modern style before refactoring.
- Check if CMake code meets team style guidelines in pre-commit hooks.
- Integrate CMake formatting into an IDE or editor workflow via stdin/stdout.
- Configure project-specific formatting rules in .gersemirc and share across team members.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
gersemi is a command-line formatter for CMake code that automatically reformats CMakeLists.txt and .cmake files to a consistent style, with support for custom command definitions and configurable formatting rules.
Yes. gersemi is actively maintained, has no known vulnerabilities, and solves a real problem for CMake-based projects. The medium install friction is acceptable given the pre-built wheels and lightweight dependency. The copyleft license (MPL-2.0) does not restrict your use of the tool itself. Install it if you maintain CMake code and want automated, configurable formatting.
Install
gersemi on PyPI
pip
pip install gersemiuv
uv add gersemipoetry
poetry add gersemiInstalling gersemi
Before you install
Medium install friction due to pre-built wheels for multiple Python versions and architectures, but the single runtime dependency (pyyaml) is lightweight. Maintenance is active with a recent release 24 days ago and consistent commit activity.
License in practice
gersemi is licensed under MPL-2.0 (copyleft). You must disclose source code modifications and distribute under the same license if you modify and redistribute the package, though using it as a tool does not impose restrictions on your CMake projects.
Quickstart
pip install gersemi
# Format a CMake file in-place
gersemi -i CMakeLists.txt
# Check if files need formatting
gersemi -c src/
Requires Python 3.8 or later. pyyaml must be installed (handled automatically by pip).
Verify before relying
- Whether the formatter handles all CMake syntax variants and edge cases reliably in production use.
- Performance characteristics when formatting large CMake projects with many files.
- Compatibility with custom CMake extensions and third-party module ecosystems.
Package facts
| License | MPL-2.0 (copyleft) |
| Python support | supports the current Python release (>=3.8) |
| Install friction | medium — platform-specific wheel |
| Runtime dependencies | 1 — pyyaml |
| Maintenance | actively maintained — 24 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 141,256/month — #11,244 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: gersemi-0.28.0-cp310-cp310-macosx_10_12_x86_64.whl; gersemi-0.28.0-cp310-cp310-macosx_11_0_arm64.whl; gersemi-0.28.0-cp310-cp310-manylinux_2_28_aarch64.whl; gersemi-0.28.0-cp310-cp310-manylinux_2_28_x86_64.whl; gersemi-0.28.0-cp310-cp310-win_amd64.whl; gersemi-0.28.0-cp310-cp310-win_arm64.whl; gersemi-0.28.0-cp311-cp311-macosx_10_12_x86_64.whl; gersemi-0.28.0-cp311-cp311-macosx_11_0_arm64.whl; gersemi-0.28.0-cp311-cp311-manylinux_2_28_aarch64.whl; gersemi-0.28.0-cp311-cp311-manylinux_2_28_x86_64.whl; gersemi-0.28.0-cp311-cp311-win_amd64.whl; gersemi-0.28.0-cp311-cp311-win_arm64.whl; gersemi-0.28.0-cp312-cp312-macosx_10_13_x86_64.whl; gersemi-0.28.0-cp312-cp312-macosx_11_0_arm64.whl; gersemi-0.28.0-cp312-cp312-manylinux_2_28_aarch64.whl; gersemi-0.28.0-cp312-cp312-manylinux_2_28_x86_64.whl; gersemi-0.28.0-cp312-cp312-win_amd64.whl; gersemi-0.28.0-cp312-cp312-win_arm64.whl; gersemi-0.28.0-cp313-cp313-macosx_10_13_x86_64.whl; gersemi-0.28.0-cp313-cp313-macosx_11_0_arm64.whl
Tags
More Python Modules packages
Converts domain names between Unicode and…
permissive · top 100 on PyPI
setuptoolsSetuptools is a Python build backend and…
permissive · top 100 on PyPI
PyYAMLPyYAML parses and emits YAML 1.1 data format,…
permissive · top 100 on PyPI
pydanticPydantic validates Python data structures…
permissive · top 100 on PyPI
annotated-typesProvides reusable metadata objects for use with…
permissive · top 100 on PyPI
typing-inspectionProvides runtime tools to inspect and…
permissive · top 100 on PyPI
cmake-formatFormats, lints, and annotates CMake listfiles,…
copyleft · top 15,000 on PyPI
cmakelintcmakelint parses CMake files and reports style…
permissive · top 15,000 on PyPI
cmakelangProvides command-line tools to format, lint,…
copyleft · top 5,000 on PyPI
reformat-gherkinAutomatically formats Gherkin feature files to…
permissive · top 15,000 on PyPI
mdformatMdformat is a CommonMark-compliant command-line…
permissive · top 5,000 on PyPI
mbakembake formats and lints Makefiles, enforcing…
permissive · top 15,000 on PyPI
beautyshBeautysh automatically formats and beautifies…
permissive · top 15,000 on PyPI
darkerDarker reformats Python source code in Git…
permissive · top 15,000 on PyPI
mdformat-ruffIntegrates ruff code formatting into mdformat…
permissive · top 15,000 on PyPI
ruff-formatProvides Python bindings to Ruff's code…
permissive · top 15,000 on PyPI