Lint and Static Analysis Tools

Introduction

Several lint and static analysis tools may be configured within CMake to run as part of a build.

clang-tidy

clang-tidy is a linter and static analyzer based on Clang. It is supported by CMake 3.6 and above.

mkdir build && cd build
cmake -DCMAKE_BUILD_TYPE:STRING=Debug -DUSE_CLANG_TIDY:BOOL=ON ..
cmake --build .

include-what-you-use

include-what-you-use is a tool based on Clang to identify unnecessary and/or missing includes.

mkdir build && cd build
cmake -DCMAKE_BUILD_TYPE:STRING=Debug -DUSE_INCLUDE_WHAT_YOU_USE:BOOL=ON ..
cmake --build .