Skip to content
Snippets Groups Projects

cppcheck: refactor cmake configuration

Merged Frank Winklmeier requested to merge fwinkl/athena:cppcheck2 into main
All threads resolved!
Files
5
# Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
# Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
#
# Additional CMake settings for the build. Used by Projects/.
#
@@ -28,3 +28,40 @@ endif()
# Configure the checker:
set( ATLAS_GCC_CHECKERS_CONFIG ${_config}
CACHE STRING "Configuration file(s) for the GCC checker plugins" FORCE )
# Set up CppCheck.
# We require version > 2.9 to avoid picking up cppcheck installed with EL9.
find_package( Cppcheck 2.11 )
if( CPPCHECK_FOUND )
# Set up the default cppcheck command to use:
set( CMAKE_CPPCHECK_DEFAULT "${CPPCHECK_cppcheck_EXECUTABLE}" "--quiet"
"--enable=warning,portability" "--inline-suppr" "--template=gcc" )
# Allow conditionalizing code on cppcheck:
list( APPEND CMAKE_CPPCHECK_DEFAULT "-D__CPPCHECK__" )
# Ignore externals:
foreach( ignored_path "${LCG_RELEASE_BASE}"
"${TDAQ-COMMON_INCLUDE_DIR}" "${TDAQ_INCLUDE_DIR}"
"${${ATLAS_PROJECT}Externals_INCLUDE_DIR}" )
if( ignored_path )
list( APPEND CMAKE_CPPCHECK_DEFAULT "--suppress=*:${ignored_path}/*" )
endif()
endforeach()
# Athena-specific suppression file:
list( APPEND CMAKE_CPPCHECK_DEFAULT "--suppressions-list=${_baseDir}/cppcheck_suppress.txt" )
# Set the cache variable(s) that CMake uses to decide how to use cppcheck:
set( CMAKE_C_CPPCHECK "${CMAKE_CPPCHECK_DEFAULT}"
CACHE STRING "CppCheck command to use for the C source files" )
set( CMAKE_CXX_CPPCHECK "${CMAKE_CPPCHECK_DEFAULT}"
CACHE STRING "CppCheck command to use for the C++ source files" )
# Let the user know what happened:
if( CMAKE_C_CPPCHECK OR CMAKE_CXX_CPPCHECK )
list( JOIN CMAKE_CPPCHECK_DEFAULT " " _cmd )
message( STATUS "Checking C/C++ files with: ${_cmd}" )
endif()
unset( CMAKE_CPPCHECK_DEFAULT )
endif()
Loading