Skip to content

Commit b8d61db

Browse files
committed
Add cppcheck + cppcheck cmake target
1 parent 8db30a7 commit b8d61db

File tree

2 files changed

+23
-0
lines changed

2 files changed

+23
-0
lines changed

CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,3 +60,4 @@ include(tools/ClangFormat)
6060

6161
# === Linting ===
6262
include(tools/ClangTidy)
63+
include(tools/Cppcheck)

cmake/tools/Cppcheck.cmake

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
find_program(CPPCHECK_EXE NAMES cppcheck)
2+
3+
if(CPPCHECK_EXE)
4+
file(GLOB_RECURSE CPPCHECK_SOURCE_FILES
5+
"${CMAKE_SOURCE_DIR}/src/*.cpp"
6+
"${CMAKE_SOURCE_DIR}/src/**/*.cpp"
7+
"${CMAKE_SOURCE_DIR}/include/**/*.hpp"
8+
)
9+
10+
add_custom_target(cppcheck
11+
COMMAND ${CPPCHECK_EXE}
12+
--enable=all
13+
--inconclusive
14+
--quiet
15+
${CPPCHECK_SOURCE_FILES}
16+
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
17+
COMMENT "Running cppcheck analysis"
18+
VERBATIM
19+
)
20+
else()
21+
message(STATUS "⚠️ cppcheck not found — 'cppcheck' target will not be available.")
22+
endif()

0 commit comments

Comments
 (0)