check-cmake
A simple linter for CMake.
Installation
check-cmake requires Python 3.9 or higher.
pip3 install check-cmake
Usage
check-cmake is a command-line application
usage: check-cmake [-h] [-v] [--version] [--recurse | --no-recurse] [--limit LIMIT] [root]
CMake checker for C and C++ projects.
positional arguments:
root path to the project root (default: .)
options:
-h, --help show this help message and exit
-v, --verbose enable verbose output
--version print the version and exit
--recurse, --no-recurse
recurse into subfolders (default: True)
--limit LIMIT maximum errors to emit (default: 0)
v0.5.3 - github.com/marzer/check-cmake
Exit codes
| Value | Meaning |
|---|---|
| 0 | No issues were found |
| 1 | Issues were found |
| 2 | The arguments were invalid |
| 255 | A fatal error occurred (-1 on Windows) |
Example output
error: /my_lib/CMakeLists.txt:29:9: language standard level should be set on a per-target basis using target_compile_features()
Context:
29 | set_target_properties(
30 | my_lib
31 | PROPERTIES
32 | CXX_STANDARD 14
33 | CXX_STANDARD_REQUIRED ON
34 | CXX_EXTENSIONS OFF
35 | )
Replace with:
target_compile_features(): https://cmake.org/cmake/help/latest/command/target_compile_features.html
More information:
CMAKE_CXX_KNOWN_FEATURES: https://cmake.org/cmake/help/latest/prop_gbl/CMAKE_CXX_KNOWN_FEATURES.html
CMAKE_C_KNOWN_FEATURES: https://cmake.org/cmake/help/latest/prop_gbl/CMAKE_C_KNOWN_FEATURES.html
found 1 error in 1 file.
Suppressing checks
Checks can be suppressed using comment-based 'pragmas' at the end of the source line:
set_target_properties(
my_lib
PROPERTIES
CXX_STANDARD 14 # nocheck
CXX_STANDARD_REQUIRED ON
CXX_EXTENSIONS OFF
)
For compatibility with other tools, any of the following will also work:
# nolint
# check-cmake ignore
# lint-cmake ignore
# cmake-check ignore
# cmake-lint ignore
# check-cmake disable
# lint-cmake disable
# cmake-check disable
# cmake-lint disable
# check-cmake: ignore
# lint-cmake: ignore
# cmake-check: ignore
# cmake-lint: ignore
# check-cmake: disable
# lint-cmake: disable
# cmake-check: disable
# cmake-lint: disable
Contributing
See CONTRIBUTING.md.
Changelog
v0.6.0 - 2026-10-15
- fixed
--limitstopping only the current directory, so later directories still reported issues - fixed output order varying with the file system's directory order
- fixed the
Threads::Threadsexample printing a literal\n - fixed the
ExternalProject_Add()example printing${{CMAKE_CXX_COMPILER}} - fixed context snippets not highlighting an issue at the very end of the snippet
- fixed
--helpshowing the--recursedefault twice on older Python versions - raised the minimum Python version to 3.9
v0.5.3 - 2025-08-07
- Fixed
# nochecknot working in some rare circumstances
v0.5.2 - 2025-01-04
- Fixed internal
Path.relative_to()error when used inside a virtual environment
v0.5.1 - 2024-10-15
- Fixed false positive for incorrect use of
SYSTEMintarget_include_directories()in some cases
v0.5.0 - 2024-03-25
- Added check for
add_library()with implicit type (STATIC,SHARED, et cetera)
v0.4.0 - 2024-01-17
- Fixed line numbers sometimes being wrong in context snippets
- Added check for incorrectly-placed
SYSTEMintarget_include_directories() - Added check for extraneous space in
ExternalProject_Add()CMAKE_ARGS
v0.3.0 - 2024-01-13
- Fixed
#nocheck
v0.2.0 - 2024-01-11
- Added pragmas for ignoring checks on a line
- Added check for
cmake_minimum_required()whenproject()is present - Fixed minor formatting issues
v0.1.0 - 2024-01-10
- First public release 🎉
Metadata
Release files for check-cmake 0.6.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| check_cmake-0.6.0.tar.gz | 25.0 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| check_cmake-0.6.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 42.6 kB
Release files / check_cmake-0.6.0.tar.gz
| Download URL | check_cmake-0.6.0.tar.gz |
|---|---|
| Size | 25.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
a5004349dad38141f22132bc98a95c821c6fecd1b7f8f3e9f8f17ef36c7fbf75
|
|
BLAKE2b-256 checksum How to use checksums |
377c81e79b988f52690d2fab7a003ee0e6525780aa8dfe3c7f76c6c6d64ca5b8
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 15, 2026.
Transparency logRelease files / check_cmake-0.6.0-py3-none-any.whl
| Download URL | check_cmake-0.6.0-py3-none-any.whl |
|---|---|
| Size | 17.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
f813bdaa58969558a81bb6efda5ac594105bab85d3a02540fa01d042596c3566
|
|
BLAKE2b-256 checksum How to use checksums |
59e01a718724f891e071539b099633767c1062ae60817a56b8ab2c9498a6046d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 15, 2026.
Transparency log