Registry / devops / cmakelang

cmakelang

JSON →
library0.6.13pypypiunverified

The `cmakelang` project provides Quality Assurance (QA) and other language tools for CMake. It includes command-line tools like `cmake-annotate` for generating HTML, `cmake-format` for source code formatting, `cmake-lint` for checking common issues, and `ctest-to` for parsing CTest output. The project, currently at version 0.6.13, is actively maintained with a regular release cadence. While the PyPI package is now `cmakelang`, the GitHub repository is still named `cmake_format`.

pip install cmakelang
INSTALL
IMPORT
SIG · CMAKELANG
C
cmakelang
devopspythonv0.6.13
Install
Import
Disk
Pass rate
0/ 10
Env Coverage0 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v? · pip install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.915 runs
build_error
glibc
py 3.103.915 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

cmake-format (command-line tool)
Run `cmake-format <file>` from your shell.
from cmakelang.format import Formatter
The `cmakelang` library primarily exposes its functionality via command-line tools like `cmake-format` and `cmake-lint`, rather than a public Python API for direct programmatic import into application code. Direct imports from submodules are generally not considered part of the public API.

This quickstart demonstrates how to use `cmake-format` to automatically reformat a CMakeLists.txt file. It creates a sample file, formats it in-place, and then prints the before and after content. This highlights the primary command-line interface of the `cmakelang` tools.

import os cmake_content_before = ''' cmake_minimum_required(VERSION 3.0) project(MyProject) set(SOURCES main.cpp anotherfile.cpp thirdfile.cpp) add_executable(MyProject ${SOURCES}) ''' cmake_file_path = "CMakeLists.txt" with open(cmake_file_path, "w") as f: f.write(cmake_content_before) print("--- CMakeLists.txt (Before Formatting) ---") print(cmake_content_before) # Run cmake-format in-place print("\nRunning cmake-format...") # For quickstart, using os.system for simplicity, in production consider subprocess.run exit_code = os.system(f"cmake-format -i {cmake_file_path}") if exit_code == 0: with open(cmake_file_path, "r") as f: cmake_content_after = f.read() print("\n--- CMakeLists.txt (After Formatting) ---") print(cmake_content_after) print("\nFormatting successful!") else: print(f"\nError: cmake-format exited with code {exit_code}") # Clean up os.remove(cmake_file_path)
cmake-format --version
Debug
Known issues
breakingThe project's Python package name officially changed from `cmake-format` to `cmakelang` around version 0.6.12/0.6.13. The old `cmake-format` PyPI package is now a transitional, empty package that depends on `cmakelang`.
fix
Update your installation commands from `pip install cmake-format` to `pip install cmakelang`. Existing `cmake-format` installs will pull in `cmakelang` as a dependency, but direct usage of `cmakelang` is recommended.
affects: 0.6.12+
breakingConfiguration file datastructures were overhauled in v0.5.0. While legacy configuration files (without sections) are still supported, they may be deprecated in the future, and default formatting for some commands (e.g., `set()`) changed due to parser logic updates.
fix
Review your configuration files and consider updating them to the new structure. You can generate a default configuration in your preferred format using `cmake-format --dump-config [yaml|json|python]` as a starting point.
affects: 0.5.0+
gotchaOptional features like YAML configuration file support (`pyyaml`) or HTML annotation (`jinja2`) require additional, non-default dependencies.
fix
Install with feature flags (e.g., `pip install cmakelang[YAML]` or `pip install cmakelang[html-gen]`) or manually install the required Python packages (`pip install pyyaml` / `pip install jinja2`).
affects: All
gotcha`cmake-format` relies on user-provided specifications in its configuration file to correctly understand and format custom CMake commands (macros/functions). Without these, formatting of custom commands may be suboptimal or incorrect.
fix
Add detailed specifications for your custom commands to your `cmakelang` configuration file (e.g., in `additional_commands` section) to guide the formatter and linter.
affects: All
gotchaWhen running `cmake-format --dump-config`, the tool will attempt to load any automatically detected configuration files in the current or parent directories. If these files are corrupt or un-parsable, `dump-config` may fail.
fix
If `cmake-format --dump-config` fails, try executing it from a clean directory (e.g., `/` or `/tmp`) to ensure no corrupt local configuration files interfere.
affects: All
deprecatedThe GitHub repository is still named `cmake_format`, even though the PyPI package and project name are `cmakelang`. The documentation indicates the repository may be moved in the future.
fix
Be aware that external references (e.g., `git clone` URLs) might still use `cmake_format`, and these may change if the repository is officially renamed.
affects: All
Upgrade
Version history
0.6.13latest on PyPI · released Aug 19, 2020
Audit
Dependencies
pyyamloptionalRequired for reading YAML-formatted configuration files.
jinja2optionalRequired for generating HTML annotations with cmake-annotate.
argcompleteoptionalOptional dependency for shell command completion.
Agent activity
18 hits · last 30 days
node
12
OpenAI (training)
2
Resources
cmakelang — pip install cmakelang · libregistry