check-cmake
A simple linter for CMake.
Installation
check-cmake requires Python 3.8 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.3.0 - github.com/marzer/check-cmake
Exit codes
| Value | Meaning |
|---|---|
| 0 | No issues were found |
| 1 | Issues were found |
| -1 | A fatal error occurred |
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 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
Changelog
v0.5.3
- Fixed
# nochecknot working in some rare circumstances
v0.5.2
- Fixed internal
Path.relative_to()error when used inside a virtual environment
v0.5.1
- Fixed false positive for incorrect use of
SYSTEMintarget_include_directories()in some cases
v0.5.0
- Added check for
add_library()with implicit type (STATIC,SHARED, et cetera)
v0.4.0
- 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
- Fixed
#nocheck
v0.2.0
- Added pragmas for ignoring checks on a line
- Added check for
cmake_minimum_required()whenproject()is present - Fixed minor formatting issues
v0.1.0
- First public release 🎉️
Metadata
Release files for check-cmake 0.5.3
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.5.3.tar.gz | 15.4 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| check_cmake-0.5.3-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 32.8 kB
Release files / check_cmake-0.5.3.tar.gz
| Download URL | check_cmake-0.5.3.tar.gz |
|---|---|
| Size | 15.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
5338f56c6e19c015e246479a00fcfda5aef6428ed2e9d64a5684f423c08441a0
|
|
BLAKE2b-256 checksum How to use checksums |
6bb51cee1d895706c087e3d9e40827ba77d65b62fea8192bffec206935a4c102
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.12.3
|
Release files / check_cmake-0.5.3-py3-none-any.whl
| Download URL | check_cmake-0.5.3-py3-none-any.whl |
|---|---|
| Size | 17.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
f80267add811826ada2012d7d1a28f79717f744cfaea4b5181f3bd1a474f9e82
|
|
BLAKE2b-256 checksum How to use checksums |
1557251bd01fd708267a6fecedfcb2eff2a9d647029d11639b99f6679310822f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.12.3
|