skillfed

gersemi

A formatter to make your CMake code the real treasure

gersemi v0.28.0 141.3K downloads/30d#11,244 on PyPI340
Copyleft license MPL-2.0 Active released

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 gersemi

uv

uv add gersemi

poetry

poetry add gersemi

Installing 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

Development Status :: 5 - Production/StableEnvironment :: ConsoleIntended Audience :: DevelopersOperating System :: OS IndependentProgramming Language :: Python :: 3Programming Language :: Python :: 3.10Programming Language :: Python :: 3.11Programming Language :: Python :: 3.12Programming Language :: Python :: 3.13Programming Language :: Python :: 3.14Programming Language :: Python :: 3.8Programming Language :: Python :: 3.9Topic :: Software Development :: Libraries :: Python ModulesTopic :: Software Development :: Quality Assurance

Tags

cmake code formattercmake style formattercmake lintercmake beautifiercmake code formatting toolcmake syntax formattercmake file formatter
cmakecode-formatterbuild-tools

More Python Modules packages