I am working on a large codebase consisting of Modern C++, Legacy C++ (30+ years old MFC) and a number of third-party libraries (Boost, RangeV3, Catch2 etc.).
The code is built using CMake and targeted to Windows and Linux (x86 & ARM). For the modern code I am using CppCheck for static analysis. Unfortunately when I build with CppCheck enabled a lot of time is spent running CppCheck over the third-party source (cpp) files, the worst one being Catch2
The thirdparty sources are included via the CMakeFecthContent syntax, e.g.
Include(FetchContent)
FetchContent_Declare(
Catch2
GIT_REPOSITORY https://github.com/catchorg/Catch2.git
GIT_TAG v3.0.1
SYSTEM
)
FetchContent_MakeAvailable(Catch2)
The _deps directory is the location where thirdparty sources are fetched and built and the line --suppress=*:*_deps/*
disables CppCheck for the headers but does not prevent it from running when each thirdparty library is built.
How can I prevent CppCheck from being run over the thirdparty libraries?
Is there something I can add to the CMake section which pulls in the library to disable it? Such as clearing CMAKE_CXX_CPPCHECK before the call to FetchContent_Declare and setting it again after the call FetchContent_MakeAvailable
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I am working on a large codebase consisting of Modern C++, Legacy C++ (30+ years old MFC) and a number of third-party libraries (Boost, RangeV3, Catch2 etc.).
The code is built using CMake and targeted to Windows and Linux (x86 & ARM). For the modern code I am using CppCheck for static analysis. Unfortunately when I build with CppCheck enabled a lot of time is spent running CppCheck over the third-party source (cpp) files, the worst one being Catch2
The thirdparty sources are included via the CMake FecthContent syntax, e.g.
CppCheck is enabled via:
The _deps directory is the location where thirdparty sources are fetched and built and the line
--suppress=*:*_deps/*
How can I prevent CppCheck from being run over the thirdparty libraries?
Is there something I can add to the CMake section which pulls in the library to disable it? Such as clearing
CMAKE_CXX_CPPCHECK
before the call toFetchContent_Declare
and setting it again after the callFetchContent_MakeAvailable
The idea is to use the
-i
flag for file to directory paths to be ignored.