check-cmake


Namecheck-cmake JSON
Version 0.5.0 PyPI version JSON
download
home_pageNone
SummaryA simple linter for CMake.
upload_time2024-03-25 08:12:10
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           |
| `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.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.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/f9/8c/184fc1a643952ef1745618cc0dcac4efe44ec914f330b85efed8659e901d/check_cmake-0.5.0.tar.gz",
    "platform": null,
    "description": "# check-cmake\r\n\r\nA simple linter for CMake.\r\n\r\n## Installation\r\n\r\n`check-cmake` requires Python 3.8 or higher.\r\n\r\n```\r\npip3 install check-cmake\r\n```\r\n\r\n## Usage\r\n\r\n`check-cmake` is a command-line application\r\n\r\n```\r\nusage: check-cmake [-h] [-v] [--version] [--recurse | --no-recurse] [--limit LIMIT] [root]\r\n\r\nCMake checker for C and C++ projects.\r\n\r\npositional arguments:\r\n  root                  path to the project root (default: .)\r\n\r\noptions:\r\n  -h, --help            show this help message and exit\r\n  -v, --verbose         enable verbose output\r\n  --version             print the version and exit\r\n  --recurse, --no-recurse\r\n                        recurse into subfolders (default: True)\r\n  --limit LIMIT         maximum errors to emit (default: 0)\r\n\r\nv0.3.0 - github.com/marzer/check_cmake\r\n```\r\n\r\n## Exit codes\r\n\r\n| Value                                | Meaning                        |\r\n| :----------------------------------- | :----------------------------- |\r\n| 0                                    | No issues were found           |\r\n| `N`, where `N` is a positive integer | `N` issues were found in total |\r\n| -1                                   | A fatal error occurred         |\r\n\r\n## Example output\r\n\r\n```\r\nerror: /my_lib/CMakeLists.txt:29:9: language standard level should be set on a per-target basis using target_compile_features()\r\n  Context:\r\n    29 | set_target_properties(\r\n    30 |     my_lib\r\n    31 |     PROPERTIES\r\n    32 |         CXX_STANDARD 14\r\n    33 |         CXX_STANDARD_REQUIRED ON\r\n    34 |         CXX_EXTENSIONS OFF\r\n    35 | )\r\n  Replace with:\r\n    target_compile_features(): https://cmake.org/cmake/help/latest/command/target_compile_features.html\r\n  More information:\r\n    CMAKE_CXX_KNOWN_FEATURES: https://cmake.org/cmake/help/latest/prop_gbl/CMAKE_CXX_KNOWN_FEATURES.html\r\n    CMAKE_C_KNOWN_FEATURES: https://cmake.org/cmake/help/latest/prop_gbl/CMAKE_C_KNOWN_FEATURES.html\r\n\r\nfound 1 error in 1 file.\r\n```\r\n\r\n## Suppressing checks\r\n\r\nChecks can be suppressed using comment-based 'pragmas' at the end of the source line:\r\n\r\n```cmake\r\nset_target_properties(\r\n    my_lib\r\n    PROPERTIES\r\n        CXX_STANDARD 14 # nocheck\r\n        CXX_STANDARD_REQUIRED ON\r\n        CXX_EXTENSIONS OFF\r\n)\r\n```\r\n\r\nFor compatibility with other tools, any the following will also work:\r\n\r\n```cmake\r\n# nolint\r\n\r\n# check-cmake ignore\r\n# lint-cmake ignore\r\n# cmake-check ignore\r\n# cmake-lint ignore\r\n\r\n# check-cmake disable\r\n# lint-cmake disable\r\n# cmake-check disable\r\n# cmake-lint disable\r\n\r\n# check-cmake: ignore\r\n# lint-cmake: ignore\r\n# cmake-check: ignore\r\n# cmake-lint: ignore\r\n\r\n# check-cmake: disable\r\n# lint-cmake: disable\r\n# cmake-check: disable\r\n# cmake-lint: disable\r\n```\r\n\r\n# Changelog\r\n\r\n## v0.5.0\r\n\r\n-   Added check for `add_library()` with implicit type (`STATIC`, `SHARED`, et cetera)\r\n\r\n## v0.4.0\r\n\r\n-   Fixed line numbers sometimes being wrong in context snippets\r\n-   Added check for incorrectly-placed `SYSTEM` in `target_include_directories()`\r\n-   Added check for extraneous space in `ExternalProject_Add()` `CMAKE_ARGS`\r\n\r\n## v0.3.0\r\n\r\n-   Fixed `#nocheck`\r\n\r\n## v0.2.0\r\n\r\n-   Added pragmas for ignoring checks on a line\r\n-   Added check for `cmake_minimum_required()` when `project()` is present\r\n-   Fixed minor formatting issues\r\n\r\n## v0.1.0\r\n\r\n-   First public release \ud83c\udf89&#xFE0F;\r\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "A simple linter for CMake.",
    "version": "0.5.0",
    "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": "",
            "digests": {
                "blake2b_256": "ecbdd175f1f698c2e0fb8014207a4848a9e9711c2337f0513ba10bf2859f271e",
                "md5": "811e588a131c6f371e0483c21872fa87",
                "sha256": "e665a06c1a68bff44eba619006fe97fdcfb8a7f6ddc423a48204a339ab8478bc"
            },
            "downloads": -1,
            "filename": "check_cmake-0.5.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "811e588a131c6f371e0483c21872fa87",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.8",
            "size": 17155,
            "upload_time": "2024-03-25T08:12:09",
            "upload_time_iso_8601": "2024-03-25T08:12:09.133105Z",
            "url": "https://files.pythonhosted.org/packages/ec/bd/d175f1f698c2e0fb8014207a4848a9e9711c2337f0513ba10bf2859f271e/check_cmake-0.5.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "f98c184fc1a643952ef1745618cc0dcac4efe44ec914f330b85efed8659e901d",
                "md5": "0294e081c34410d3aeb63767471202cd",
                "sha256": "798089db8f378b32287feeaa8d54e04790cbc1b8be8bcfe6eb60ba3f7a9cf479"
            },
            "downloads": -1,
            "filename": "check_cmake-0.5.0.tar.gz",
            "has_sig": false,
            "md5_digest": "0294e081c34410d3aeb63767471202cd",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.8",
            "size": 15446,
            "upload_time": "2024-03-25T08:12:10",
            "upload_time_iso_8601": "2024-03-25T08:12:10.855815Z",
            "url": "https://files.pythonhosted.org/packages/f9/8c/184fc1a643952ef1745618cc0dcac4efe44ec914f330b85efed8659e901d/check_cmake-0.5.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-03-25 08:12:10",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "sponsors",
    "github_project": "marzer",
    "github_not_found": true,
    "lcname": "check-cmake"
}
        
Elapsed time: 0.26080s