I want to create a CMake 3.15+ check
target which will run cppcheck using the native CMake CXX_CPPCHECK
target property. I've set up the binary paths correctly, I also have an ANALYSIS_SOURCES
variable with the list of source files I want to run through. However, I don't understand how to create a target which would depend on ${ANALYSIS_SOURCES}
. My make check
doesn't do any work even though I see:
Built target cppcheck-analysis
Built target check
I've tried the following setup:
cmake_minimum_required(VERSION 3.15)
project(check_target)
add_custom_target(check)
set_target_properties(
check PROPERTIES
CXX_STANDARD 17
CXX_STANDARD_REQUIRED ON
COMPILE_FLAGS "${WARNING_FLAGS}"
)
set(ANALYSIS_SOURCES src/Main.cpp)
add_custom_target(cppcheck-analysis DEPENDS ${ANALYSIS_SOURCES})
set_target_properties(
cppcheck-analysis PROPERTIES
CXX_CPPCHECK "/usr/bin/cppcheck"
)
add_dependencies(check cppcheck-analysis)
I suspect I'm using the cppcheck-analysis
DEPENDS argument incorrectly. What would be the right approach?