Awesome
cmake_check
Cmake_check is a linter for the CMake language. It takes a set of user-defined rules and reports violations for CMakeLists.txt files and CMake modules.
- Quick Start
- Overview
- Download
- Versioning
- Basic Usage
- How it Works
- Limitations
- Features Currently in Development
<a name="Quick_Start"></a>
Quick Start ▲
Step 1: Download cmake_check (several methods, see below).
Step 2: Open a terminal (cmd.exe
on Windows).
Step 3: Invoke cmake_check to check your CMake files or directories.
The executable name differs depending on whether you use the
development source version (cmake_check
), a Windows executable
(cmake_check.exe
) or , a Linux executable
(cmake_check
). On this page, cmake_check
is the generic term
used to refer to any of these.
a file
<pre> prompt> cmake_check -i CMakeLists.txt -v info: Checking CMakeLists.txt CMakeLists(10).txt (66) : warning Whitelist: calls to some_custom_function are not allowed by whitelist info: Checked 1 files info: 0 files are clean info: 1 files have 2 warnings info: 0 files are ignored info: took {"durationMs":28} </pre>a directory
<pre> prompt> cmake_check -i project_folder -v info: Checking files in project_folder project_folder/libFoo/CMakeLists.txt (66) : warning Whitelist: calls to some_custom_function are not allowed by whitelist project_folder/libBar/CMakeLists.txt (50) : warning Whitelist: calls to some_other_custom_function are not allowed by whitelist ... info: Checked 769 files info: 186 files are clean info: 583 files have 1566 warnings info: 0 files are ignored info: took {"durationMs":2270} </pre><a name="Overview"></a>
Overview ▲
Cmake_check is a linter for the CMake language. It takes a set of user-defined rules and reports violations for CMakeLists.txt files and CMake modules. CMake_check is a command line application suitable for continuous integration checks. This is especially useful for large source trees with hundreds of CMake files. Cmake_check can be used to enforce a certain coding style or project/company guidelines. It is written in TypeScript and runs on every platform where node.js is available.
Features are:
- recursive check of all CMake files in a given directory
- allows combination of checks to form custom rules
- a rule may consist of any number of checks
- provides warning output (msbuild format) that can be used by the jenkins warnings plugin
Available checks:
- require commands to exist (or not exist)
- allow white-listed commands only (to limit the use of custom functions)
Planned checks:
- require a specific command order
- constraints on specific command arguments
- constraints on paths (e.g. no ..)
- comment checks
- maximum line length
- indentation checks
<a name="binaries"></a>
Binaries ▲
Each release comes with a set of Linux and Windows binaries.
<a name="npm"></a>
NPM ▲
Install NodeJS (version > 8.11).
npm install -g cmake_check
<a name="Versioning"></a>
Versioning ▲
Cmake_check uses semantic versioning.
<a name="basic_usage"></a>
Basic Usage ▲
The basic use is:
cmake_check -i <input folder or file>
or with custom configuration:
cmake_check -c <config file> -i <input folder or file>
All CMake files in the given input folders are analyzed with the given configuration. All warnings are written to stdout.
For more information and further available options call cmake_check -h
.
<a name="config"></a>
Configuration ▲
The documentation for the cmake_check configuration is available on a separate page.
<a name="How_it_works"></a>
How It Works ▲
Cmake_check uses a parser-generator and a grammar to create a parser of the CMake language. All CMakeLists.txt files from input are parsed to a structured object. All configured checks are executed on that object. Failed checks are printed as warnings.
<a name="Limitations"></a>
Limitations
- the language parser will fail on CMakeLists.txt files that do not conform to the CMake language
- these errors are reported by CMake itself, a successful run of CMake on the input files is a precondition for cmake_check
<a name="in_progress"></a>
Features under development ▲
See the development board for issues that are in work.