mirror of
https://github.com/WerWolv/ImHex.git
synced 2026-03-27 23:37:05 -05:00
build: Add support for cppcheck to cmake
This commit is contained in:
@@ -66,6 +66,32 @@ function(addCommonFlag)
|
||||
addObjCFlag(${ARGV0} ${ARGV1})
|
||||
endfunction()
|
||||
|
||||
function(addCppCheck target)
|
||||
if (NOT IMHEX_ENABLE_CPPCHECK)
|
||||
return()
|
||||
endif()
|
||||
|
||||
find_program(cppcheck_exe NAMES cppcheck REQUIRED)
|
||||
if (NOT cppcheck_exe)
|
||||
return()
|
||||
endif()
|
||||
|
||||
set(target_build_dir $<TARGET_FILE_DIR:${target}>)
|
||||
set(cppcheck_opts
|
||||
--enable=all
|
||||
--inline-suppr
|
||||
--quiet
|
||||
--std=c++23
|
||||
--check-level=exhaustive
|
||||
--error-exitcode=10
|
||||
--suppressions-list=${CMAKE_SOURCE_DIR}/dist/cppcheck.supp
|
||||
--checkers-report=${target_build_dir}/cppcheck-report.txt
|
||||
)
|
||||
set_target_properties(${target} PROPERTIES
|
||||
CXX_CPPCHECK "${cppcheck_exe};${cppcheck_opts}"
|
||||
)
|
||||
endfunction()
|
||||
|
||||
set(CMAKE_WARN_DEPRECATED OFF CACHE BOOL "Disable deprecated warnings" FORCE)
|
||||
|
||||
include(FetchContent)
|
||||
|
||||
@@ -56,6 +56,7 @@ macro(add_imhex_plugin)
|
||||
# Enable required compiler flags
|
||||
enableUnityBuild(${IMHEX_PLUGIN_NAME})
|
||||
setupCompilerFlags(${IMHEX_PLUGIN_NAME})
|
||||
addCppCheck(${IMHEX_PLUGIN_NAME})
|
||||
|
||||
# Configure build properties
|
||||
set_target_properties(${IMHEX_PLUGIN_NAME}
|
||||
|
||||
Reference in New Issue
Block a user