I have a CMakefile that defines cppcheck as described in Cppcheck support in CMake works great, but I want to be able to compile my code over and over again and not run cppcheck until I think I am close to done, and then run cppcheck prior to commit.
cppcheck is too slow to have as part of my edit/compile/test/debug cycle.
What is the best practice for this? I am thinking something like define a variable and generate files, and build and build and build. e.g.
In CMakeLists.txt
if(CPPCHECK STREQUAL "yes")
set(CMAKE_CXX_CPPCHECK "cppcheck")
endif()
While writing code
cmake3 -G "Unix Makefiles" ..
cmake3 --build .
cmake3 --build .
Then before committing code
cmake3 -G "Unix Makefiles" -DCPPCHECK=yes ..
cmake3 --build .
Is there a better way?