function(course_add_cppcheck_targets) find_program(CPPCHECK_EXECUTABLE cppcheck) if(NOT CPPCHECK_EXECUTABLE) message(STATUS "cppcheck not found; cppcheck targets will not be available") return() endif() set(_compile_commands "${CMAKE_BINARY_DIR}/compile_commands.json") set(_suppressions "${CMAKE_SOURCE_DIR}/cppcheck/suppressions.txt") add_custom_target( cppcheck_modules COMMAND "${CPPCHECK_EXECUTABLE}" --project=${_compile_commands} --enable=warning,style,performance --std=c++26 --inline-suppr --suppressions-list=${_suppressions} -i${CMAKE_SOURCE_DIR}/support -i${CMAKE_BINARY_DIR}/_deps --quiet WORKING_DIRECTORY "${CMAKE_BINARY_DIR}" COMMENT "Running cppcheck on course modules (build once before running this target)" VERBATIM ) add_custom_target( cppcheck_project COMMAND "${CPPCHECK_EXECUTABLE}" --project=${_compile_commands} --enable=warning,style,performance --std=c++26 --inline-suppr --suppressions-list=${_suppressions} --quiet WORKING_DIRECTORY "${CMAKE_BINARY_DIR}" COMMENT "Running cppcheck on entire project (build once before running this target)" VERBATIM ) endfunction()