From 0aaaf584eb1c49de2f1066008de019985e8b5009 Mon Sep 17 00:00:00 2001
From: Frank Winklmeier <frank.winklmeier@cern.ch>
Date: Mon, 17 Feb 2025 09:47:20 +0100
Subject: [PATCH] Projects: move CPPCHECK option to Athena project

`ATLAS_USE_CPPCHECK` was set in CxxUtils to `ON` but this should not be
done for projects where we do not have cppcheck available. Move the
setting to `Athena` and ensure it is propagated to downstream (i.e.
`WorkDir`) projects.

Closes ATLINFR-5672.
---
 Control/CxxUtils/cmake/CxxUtilsSettingsConfig.cmake | 5 +----
 Projects/Athena/CMakeLists.txt                      | 3 +++
 Projects/Athena/cmake/PreConfig.cmake.in            | 3 +++
 3 files changed, 7 insertions(+), 4 deletions(-)

diff --git a/Control/CxxUtils/cmake/CxxUtilsSettingsConfig.cmake b/Control/CxxUtils/cmake/CxxUtilsSettingsConfig.cmake
index 26d6f74c11c7..5052f2e56724 100644
--- a/Control/CxxUtils/cmake/CxxUtilsSettingsConfig.cmake
+++ b/Control/CxxUtils/cmake/CxxUtilsSettingsConfig.cmake
@@ -1,4 +1,4 @@
-# Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
+# Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
 #
 # Additional CMake settings for the build. Used by Projects/.
 #
@@ -29,9 +29,6 @@ endif()
 set( ATLAS_GCC_CHECKERS_CONFIG ${_config}
    CACHE STRING "Configuration file(s) for the GCC checker plugins" FORCE )
 
-# CppCheck options:
-option( ATLAS_USE_CPPCHECK "Use CppCheck in the build" ON )
-
 # User-defined cppcheck command line options:
 set( ATLAS_CPPCHECK_OPTIONS "--enable=warning,portability,performance"
    CACHE STRING "cppcheck user-defined command line options" )
diff --git a/Projects/Athena/CMakeLists.txt b/Projects/Athena/CMakeLists.txt
index 7bac95d52165..ab1dd37ee0d9 100644
--- a/Projects/Athena/CMakeLists.txt
+++ b/Projects/Athena/CMakeLists.txt
@@ -79,6 +79,9 @@ set( CxxUtilsSettings_DIR
    "${CMAKE_SOURCE_DIR}/../../Control/CxxUtils/cmake" )
 find_package( CxxUtilsSettings )
 
+# Enable CppCheck:
+option( ATLAS_USE_CPPCHECK "Use CppCheck in the build" ON )
+
 # Decide whether to enable LTO for AtlasGeant4 and its OBJECT libs
 include( CheckIPOSupported )
 check_ipo_supported( RESULT ATLAS_IPO_CHECK_RESULT )
diff --git a/Projects/Athena/cmake/PreConfig.cmake.in b/Projects/Athena/cmake/PreConfig.cmake.in
index c2eeb3e4b495..a444a03ba6ba 100644
--- a/Projects/Athena/cmake/PreConfig.cmake.in
+++ b/Projects/Athena/cmake/PreConfig.cmake.in
@@ -29,6 +29,9 @@ set( ATLAS_FLAKE8 @ATLAS_FLAKE8@
 set( ATLAS_PYTHON_CHECKER @ATLAS_PYTHON_CHECKER@
    CACHE STRING "Python checker command to run during Python module compilation" )
 
+# CppCheck
+option( ATLAS_USE_CPPCHECK "Use CppCheck in the build" @ATLAS_USE_CPPCHECK@ )
+
 # Decide whether to enable LTO for AtlasGeant4 and its OBJECT libs
 set( ATLAS_GEANT4_USE_LTO @ATLAS_GEANT4_USE_LTO@ CACHE BOOL
    "Use link-time-optimization in building AtlasGeant4" )
-- 
GitLab