From efa0517759cb7bd8b4440fdc2b92d344024a095f Mon Sep 17 00:00:00 2001
From: Markus Frank <Markus.Frank@cern.ch>
Date: Fri, 15 Nov 2019 15:45:03 +0100
Subject: [PATCH] Fix cmake bugs introduced to build examples with Geant4
 builtin CLHEP

---
 examples/CMakeLists.txt       |  2 +-
 examples/DDCMS/CMakeLists.txt | 13 +++++--------
 2 files changed, 6 insertions(+), 9 deletions(-)

diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt
index 0e45a37b9..940b0e41b 100644
--- a/examples/CMakeLists.txt
+++ b/examples/CMakeLists.txt
@@ -41,7 +41,7 @@ dd4hep_configure_output()
 SET(DD4HEP_EXAMPLES "AlignDet CLICSiD ClientTests Conditions DDCMS DDCodex DDDB DDDigi DDG4 DDG4_MySensDet LHeD OpticalSurfaces Persistency SimpleDetector"
   CACHE STRING "List of DD4hep Examples to build")
 SEPARATE_ARGUMENTS(DD4HEP_EXAMPLES)
-MESSAGE(STATUS "Will be building these examples: ${DD4HEP_BUILD_EXAMPLES}")
+MESSAGE(STATUS "Will be building these examples: ${DD4HEP_EXAMPLES}")
 
 FOREACH(DDExample IN LISTS DD4HEP_EXAMPLES)
   dd4hep_print("|> Building ${DDExample}")
diff --git a/examples/DDCMS/CMakeLists.txt b/examples/DDCMS/CMakeLists.txt
index 0f61b7ad8..5bb65f9db 100644
--- a/examples/DDCMS/CMakeLists.txt
+++ b/examples/DDCMS/CMakeLists.txt
@@ -22,20 +22,17 @@ IF(NOT TARGET DD4hep::DDCore)
 ENDIF()
 
 dd4hep_set_compiler_flags()
+#
 #==========================================================================
-set (Geant4_builtin_clhep_FOUND ON)
-# Configure Geant4
+# Configure Geant4 to if we have a builtin CLHEP
 if(DD4HEP_USE_GEANT4)
   find_package( Geant4 REQUIRED )
-  if(NOT Geant4_builtin_clhep_FOUND)
-    SET(DD4HEP_USE_CLHEP TRUE)
-  else()
+  if(Geant4_builtin_clhep_FOUND)
     include_directories(${Geant4_INCLUDE_DIRS})
+    DD4HEP_SETUP_GEANT4_TARGETS()
   endif()
-  dd4hep_print("|++> Setup Geant4 targets.")
-  DD4HEP_SETUP_GEANT4_TARGETS()
 endif()
-
+#
 # CLHEP dependent stuff
 if(NOT TARGET CLHEP::CLHEP)
   # ensure we only look for CLHEP once
-- 
GitLab