check-cmake


Namecheck-cmake JSON
Version 0.5.3 PyPI version JSON
download
home_pageNone
SummaryA simple linter for CMake.
upload_time2025-08-07 15:24:00
maintainerNone
docs_urlNone
authorNone
requires_python>=3.8
licenseMIT
keywords c++ cmake
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # 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:

```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
```

# Changelog

## v0.5.3

- Fixed `# nocheck` not 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 `SYSTEM` in `target_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 `SYSTEM` in `target_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()` when `project()` is present
- Fixed minor formatting issues

## v0.1.0

- First public release 🎉️

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "check-cmake",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.8",
    "maintainer_email": null,
    "keywords": "c++, cmake",
    "author": null,
    "author_email": "Mark Gillard <mark.gillard@outlook.com.au>",
    "download_url": "https://files.pythonhosted.org/packages/6b/b5/1cee1d895706c087e3d9e40827ba77d65b62fea8192bffec206935a4c102/check_cmake-0.5.3.tar.gz",
    "platform": null,
    "description": "# check-cmake\n\nA simple linter for CMake.\n\n## Installation\n\n`check-cmake` requires Python 3.8 or higher.\n\n```\npip3 install check-cmake\n```\n\n## Usage\n\n`check-cmake` is a command-line application\n\n```\nusage: check-cmake [-h] [-v] [--version] [--recurse | --no-recurse] [--limit LIMIT] [root]\n\nCMake checker for C and C++ projects.\n\npositional arguments:\n  root                  path to the project root (default: .)\n\noptions:\n  -h, --help            show this help message and exit\n  -v, --verbose         enable verbose output\n  --version             print the version and exit\n  --recurse, --no-recurse\n                        recurse into subfolders (default: True)\n  --limit LIMIT         maximum errors to emit (default: 0)\n\nv0.3.0 - github.com/marzer/check-cmake\n```\n\n## Exit codes\n\n| Value | Meaning                |\n| :---- | :--------------------- |\n| 0     | No issues were found   |\n| 1     | Issues were found      |\n| -1    | A fatal error occurred |\n\n## Example output\n\n```\nerror: /my_lib/CMakeLists.txt:29:9: language standard level should be set on a per-target basis using target_compile_features()\n  Context:\n    29 | set_target_properties(\n    30 |     my_lib\n    31 |     PROPERTIES\n    32 |         CXX_STANDARD 14\n    33 |         CXX_STANDARD_REQUIRED ON\n    34 |         CXX_EXTENSIONS OFF\n    35 | )\n  Replace with:\n    target_compile_features(): https://cmake.org/cmake/help/latest/command/target_compile_features.html\n  More information:\n    CMAKE_CXX_KNOWN_FEATURES: https://cmake.org/cmake/help/latest/prop_gbl/CMAKE_CXX_KNOWN_FEATURES.html\n    CMAKE_C_KNOWN_FEATURES: https://cmake.org/cmake/help/latest/prop_gbl/CMAKE_C_KNOWN_FEATURES.html\n\nfound 1 error in 1 file.\n```\n\n## Suppressing checks\n\nChecks can be suppressed using comment-based 'pragmas' at the end of the source line:\n\n```cmake\nset_target_properties(\n    my_lib\n    PROPERTIES\n        CXX_STANDARD 14 # nocheck\n        CXX_STANDARD_REQUIRED ON\n        CXX_EXTENSIONS OFF\n)\n```\n\nFor compatibility with other tools, any the following will also work:\n\n```cmake\n# nolint\n\n# check-cmake ignore\n# lint-cmake ignore\n# cmake-check ignore\n# cmake-lint ignore\n\n# check-cmake disable\n# lint-cmake disable\n# cmake-check disable\n# cmake-lint disable\n\n# check-cmake: ignore\n# lint-cmake: ignore\n# cmake-check: ignore\n# cmake-lint: ignore\n\n# check-cmake: disable\n# lint-cmake: disable\n# cmake-check: disable\n# cmake-lint: disable\n```\n\n# Changelog\n\n## v0.5.3\n\n- Fixed `# nocheck` not working in some rare circumstances\n\n## v0.5.2\n\n- Fixed internal `Path.relative_to()` error when used inside a virtual environment\n\n## v0.5.1\n\n- Fixed false positive for incorrect use of `SYSTEM` in `target_include_directories()` in some cases\n\n## v0.5.0\n\n- Added check for `add_library()` with implicit type (`STATIC`, `SHARED`, et cetera)\n\n## v0.4.0\n\n- Fixed line numbers sometimes being wrong in context snippets\n- Added check for incorrectly-placed `SYSTEM` in `target_include_directories()`\n- Added check for extraneous space in `ExternalProject_Add()` `CMAKE_ARGS`\n\n## v0.3.0\n\n- Fixed `#nocheck`\n\n## v0.2.0\n\n- Added pragmas for ignoring checks on a line\n- Added check for `cmake_minimum_required()` when `project()` is present\n- Fixed minor formatting issues\n\n## v0.1.0\n\n- First public release \ud83c\udf89&#xFE0F;\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "A simple linter for CMake.",
    "version": "0.5.3",
    "project_urls": {
        "Funding": "https://github.com/sponsors/marzer",
        "Source": "https://github.com/marzer/check-cmake",
        "Tracker": "https://github.com/marzer/check-cmake/issues"
    },
    "split_keywords": [
        "c++",
        " cmake"
    ],
    "urls": [
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "1557251bd01fd708267a6fecedfcb2eff2a9d647029d11639b99f6679310822f",
                "md5": "409c0e1d62d8676cff2f55cc7fed7118",
                "sha256": "f80267add811826ada2012d7d1a28f79717f744cfaea4b5181f3bd1a474f9e82"
            },
            "downloads": -1,
            "filename": "check_cmake-0.5.3-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "409c0e1d62d8676cff2f55cc7fed7118",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.8",
            "size": 17387,
            "upload_time": "2025-08-07T15:23:59",
            "upload_time_iso_8601": "2025-08-07T15:23:59.791648Z",
            "url": "https://files.pythonhosted.org/packages/15/57/251bd01fd708267a6fecedfcb2eff2a9d647029d11639b99f6679310822f/check_cmake-0.5.3-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "6bb51cee1d895706c087e3d9e40827ba77d65b62fea8192bffec206935a4c102",
                "md5": "5f8fa1e5b244aa02e38e3eca81248331",
                "sha256": "5338f56c6e19c015e246479a00fcfda5aef6428ed2e9d64a5684f423c08441a0"
            },
            "downloads": -1,
            "filename": "check_cmake-0.5.3.tar.gz",
            "has_sig": false,
            "md5_digest": "5f8fa1e5b244aa02e38e3eca81248331",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.8",
            "size": 15437,
            "upload_time": "2025-08-07T15:24:00",
            "upload_time_iso_8601": "2025-08-07T15:24:00.816782Z",
            "url": "https://files.pythonhosted.org/packages/6b/b5/1cee1d895706c087e3d9e40827ba77d65b62fea8192bffec206935a4c102/check_cmake-0.5.3.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2025-08-07 15:24:00",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "sponsors",
    "github_project": "marzer",
    "github_not_found": true,
    "lcname": "check-cmake"
}
        
Elapsed time: 0.41397s