We build with CMake and normal Unix makefiles. There are some static analysis checks, e.g. Cppcheck, we run at every C/C++ file in the project to catch errors at compile time.
I have created a custom target for cppcheck and attached it into "all" target. This checks all the *.c and *.cpp files in the project.
We want to run a check every time a file is changed and recompiled and only on that file. The check should be run automatically and without the user having to add extra commands in CMake. Essentially, the check should be "attached/hooked" to normal CMake commands add_library()
and add_executable()
. Is there any way to do this in CMake?