Update: Using C++26 with contracts enabled

This commit is contained in:
David Gil de Gómez Pérez
2026-08-12 13:49:04 +03:00
parent 41111dba30
commit 28a315195e
2 changed files with 50 additions and 0 deletions
+42
View File
@@ -0,0 +1,42 @@
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()