Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/marzer/check-cmake
A simple linter for CMake.
https://github.com/marzer/check-cmake
Last synced: 30 days ago
JSON representation
A simple linter for CMake.
- Host: GitHub
- URL: https://github.com/marzer/check-cmake
- Owner: marzer
- License: mit
- Created: 2024-01-09T23:55:39.000Z (10 months ago)
- Default Branch: main
- Last Pushed: 2024-09-09T11:25:16.000Z (2 months ago)
- Last Synced: 2024-09-26T11:24:47.266Z (about 2 months ago)
- Language: Python
- Homepage: https://pypi.org/project/check-cmake/
- Size: 43 KB
- Stars: 4
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE.txt
Awesome Lists containing this project
README
# 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 |
| `N`, where `N` is a positive integer | `N` issues were found in total |
| -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.htmlfound 1 error in 1 file.
```## Suppressing checks
Checks can be suppressed using comment-based 'pragmas' at the end of the source line:
```cmake
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:
```cmake
# 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
```