CMAKE_C_CPPCHECK how to ignore a special file or folder

1.2k Views Asked by At

I am using cppcheck with cmake. Which works as expected but I would like to exclude some files or folders from the check. I tried some different things with --supress and --supress-list andi -i but I did not get any solution right now.

lets say i have this folder structure:

source
test
   unity
   lib
      mylib.c
   source
   CMakeLists.txt

So how can i exclude unity and mylib.c from the check? This is a snippet from the CMakeLists.txt ...

find_program(CMAKE_C_CPPCHECK NAMES cppcheck)
if (CMAKE_C_CPPCHECK)
    message("-- CppCheck found : ${CMAKE_C_CPPCHECK}")
    message("-- current source dir : ${CMAKE_CURRENT_SOURCE_DIR}")
    message("-- source dir : ${CMAKE_SOURCE_DIR}")
    list(
        APPEND CMAKE_C_CPPCHECK 
            "--enable=warning,style,performance,portability,information,missingInclude"
            "--force"    
            "-i${CMAKE_CURRENT_SOURCE_DIR}/unity/"
            "-i${CMAKE_CURRENT_SOURCE_DIR}/lib/mylib.c"
            #"--suppress=*:${CMAKE_CURRENT_SOURCE_DIR}/unity/*" # also tried this for the folder
    )
endif()

So nothing works right now. What am I doing wrong here.

thx

0

There are 0 best solutions below