I am not asking about the various available third-party modules that support Cppcheck in one way or the other.
With CMake 3.10, CMake seems to have gained some official Cppcheck support. See CMAKE_<LANG>_CPPCHECK.
Unfortunately the documentation how to use this variable is a bit sparse. Is there a good example of how Cppcheck is supposed to be used with CMake 3.10 (or later)?
An simple example would be - if you have
cppcheck
in yourPATH
and you are not specifying additional parameters - the following by setting globalCMAKE_<LANG>_CPPCHECK
variable:The files to scan are added automatically to the
cppcheck
command line. So the above example gives the following output (gcc
andcppcheck
on Linux system):You could give
cppcheck
a try in an existing project by simply setting theCMAKE_CXX_CPPCHECK
variable via thecmake
command line:A more "daily life" example would probably for you to include something like the following code snippet in your
CMakeList.txt
:References
<LANG>_CPPCHECK
target property