Skip to main content

cmake-checker is a tool to search for violations to 'modern' cmake rules.

Project description

cmake-checker

cmake-checker is a tool to search for violations to 'modern' cmake rules.

Usage

usage: __main__.py [-h] [--warn-only] [--reporter {console,junit}]
                        [-o OUTPUT_FILE] [--whitelist WHITELIST]
                        PATH [PATH ...]

positional arguments:
  PATH                  Path to the file or directory where the checks should
                        be done

optional arguments:
  -h, --help            show this help message and exit
  --warn-only           Program will return 0 even if violations are found
  --reporter {console,junit}
                        Specify type of reporter to output
  -o OUTPUT_FILE, --output-file OUTPUT_FILE
                        Output results to file with given name
  --whitelist WHITELIST
                        Whitelist file with rules to ignore certain files or
                        dirs (.gitignore style)

What&Why tool warns about

  • file(GLOB ...)

    • CMake will not track the dependencies of a new file on disk correctly. If no CMakeLists.txt file changes when a source is added or removed then the generated build system cannot know when to ask CMake to regenerate.
    • You can't ensure that only files you want are added. Globbing may pick up stray files that you do not want.
  • Functions

    • add_compile_options
    • add_compile_definitions
    • link_libraries
    • add_definitions
    • include_directories

    Functions work on directory scope instead of target scope. Every single one of listed functions has equivalent for target scope which should be used.

  • Properties COMPILE_<LANG>_FLAGS

    These properties should be set for a target - not modified globally

  • Closing commands with clauses

    • endif
    • endfunction
    • endmacro
    • endforeach

    Example:

    macro(foo ...)
    ...
    endmacro(foo)
    
  • Set/unset including

    • ENV
    • CACHE
  • ../.. in target_sources function

  • Set/unset PARENT_SCOPE outside of function declaration

Possibility to disable check

If you need to disable for any specific reasons checks you can do it using:

# cmake-check disable
...
# cmake-check enable

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

cmake_checker-0.1.0.tar.gz (5.7 kB view details)

Uploaded Source

Built Distribution

cmake_checker-0.1.0-py2.py3-none-any.whl (8.2 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file cmake_checker-0.1.0.tar.gz.

File metadata

  • Download URL: cmake_checker-0.1.0.tar.gz
  • Upload date:
  • Size: 5.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.9.1 setuptools/41.0.0 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.5.2

File hashes

Hashes for cmake_checker-0.1.0.tar.gz
Algorithm Hash digest
SHA256 1e4cc791570d0d61127373746cc729c48b7aa79a52adde6b6386404c1b5bdff9
MD5 13dc0760c5f4811e158af09b34eec1d1
BLAKE2b-256 381c538f0cb368f31c8bbf03e4a96505e0ff176b0c192e4c45ba2374c67822e2

See more details on using hashes here.

File details

Details for the file cmake_checker-0.1.0-py2.py3-none-any.whl.

File metadata

  • Download URL: cmake_checker-0.1.0-py2.py3-none-any.whl
  • Upload date:
  • Size: 8.2 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.9.1 setuptools/41.0.0 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.5.2

File hashes

Hashes for cmake_checker-0.1.0-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 fd410883e7ab9db292d16b980ea8d246e94060b66465ecf0457dc08640e14bb0
MD5 e2354d823b6c9c1b8468c9d0542b2da8
BLAKE2b-256 4a9f19083ea29af620936a10083e2a77152ce3f6a8185bbef0a5975d955ab3e4

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page