From e4aa0b04fadf805b537079fb8a266666a141f78f Mon Sep 17 00:00:00 2001 From: "Addisu Z. Taddese" Date: Wed, 1 Sep 2021 15:13:09 -0500 Subject: [PATCH] Fix include directory flags for codecheck (#186) The include directories of cppcheck need individual -I flags ahead of each directory. Signed-off-by: Addisu Z. Taddese --- cmake/IgnCodeCheck.cmake | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/cmake/IgnCodeCheck.cmake b/cmake/IgnCodeCheck.cmake index 636db326..91cd43f6 100644 --- a/cmake/IgnCodeCheck.cmake +++ b/cmake/IgnCodeCheck.cmake @@ -32,9 +32,15 @@ function(ign_setup_target_for_codecheck) message(STATUS "Adding codecheck target") + # Each include directory needs an -I flag + set(CPPCHECK_INCLUDE_DIRS_FLAGS) + foreach(dir ${CPPCHECK_INCLUDE_DIRS}) + list(APPEND CPPCHECK_INCLUDE_DIRS_FLAGS "-I${dir}") + endforeach() + add_custom_target(cppcheck # First cppcheck - COMMAND ${CPPCHECK_PATH} ${CPPCHECK_BASE} ${CPPCHECK_EXTRA} -I ${CPPCHECK_INCLUDE_DIRS} ${CPPCHECK_RULES} `${CPPCHECK_FIND}` + COMMAND ${CPPCHECK_PATH} ${CPPCHECK_BASE} ${CPPCHECK_EXTRA} ${CPPCHECK_INCLUDE_DIRS_FLAGS} ${CPPCHECK_RULES} `${CPPCHECK_FIND}` # Second cppcheck COMMAND ${CPPCHECK_PATH} ${CPPCHECK_BASE} --enable=missingInclude `${CPPCHECK_FIND}`