0

I have a project that uses CMake with a top level CMakeLists which references subdirectories each with their own targets and CMakeLists. Each subdirectory includes src, include dirs.

I'm trying to execute Cppcheck on my code base using the following command:

cppcheck --project=compile_commands.json --suppressions-list=suppressions.txt --output-file=cppcheck-results.log --xml --enable=all

My suppressions.txt file contains a bunch of style errors to skip.

The problem is that it doesn't catch any error/issue in local .h files (inside the include directories).

Unless I specify cppcheck to check a specific directory and give the -I flag, then it would. But for the whole project it does not.

Ðаn
  • 10,934
  • 11
  • 59
  • 95
Mo Kanj
  • 107
  • 7
  • Have you tried adding the local.h to your cmake target? Althoug not necessary for building, it might be necessary for the compile_commands.json database. Also do you include local.h witn ""? If you use <> cppcheck might mistake it for a system header – arved Jul 28 '21 at 09:57
  • @arved The header files are not added to add_executable() but rather as traget_include_directories(). Might this be the reason that cppcheck ignores them? Also the hearders are included in the src files with `#include "filename.h"` whereby the path is resolved from CMake. – Mo Kanj Jul 28 '21 at 15:27
  • In include_directories you have the directories. The header files you can optionally add to add_executable – arved Jul 29 '21 at 08:30

0 Answers0