From 378093bb73438b38a10a59a0f07476ad8b93a71a Mon Sep 17 00:00:00 2001
From: Andre Sailer <andre.philippe.sailer@cern.ch>
Date: Wed, 23 Jul 2014 14:30:07 +0000
Subject: [PATCH] Rearange find_package calls

Move find_package xercesc to dd4hep_xml_setup, so all the xml treatment is in one place
Move find_package boost and lcio to main cmakelists, so they are done once and not repeated
Move include geant4_use_file to main cmakelists, so all of the geant4 treatment is in one place
---
 CMakeLists.txt               | 15 +++++++++++++--
 cmake/DD4hep_XML_setup.cmake |  1 +
 2 files changed, 14 insertions(+), 2 deletions(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 9e8929ff5..ef6e9ba96 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -57,8 +57,18 @@ include( DD4hepMacros )
 
 find_package(ROOT REQUIRED)
 
-if(DD4HEP_USE_XERCESC)
-  find_package(XercesC REQUIRED)
+##checks for xercesc or not and sets up the include_directories
+include(DD4hep_XML_setup)
+
+if(DD4HEP_USE_BOOST)
+  find_package( Boost REQUIRED ) 
+  include_directories( SYSTEM ${Boost_INCLUDE_DIRS} )
+  add_definitions( -DDD4HEP_USE_BOOST )
+endif()
+
+if(DD4HEP_USE_LCIO)
+  find_package( LCIO REQUIRED )
+  include_directories( SYSTEM ${LCIO_INCLUDE_DIRS} )
 endif()
 
 #---Testing-------------------------------------------------------------------------
@@ -101,6 +111,7 @@ if(DD4HEP_USE_GEANT4)
   #--- create a geant4 variables for the thisdd4hep.sh script
   find_package( Geant4 REQUIRED  gdml ui_all vis_all)
 
+  include(${Geant4_USE_FILE})   # this also takes care of geant 4 definitions and include dirs
 
   #----- if geant4 is build with external CLHEP we also need to export this fact
 
diff --git a/cmake/DD4hep_XML_setup.cmake b/cmake/DD4hep_XML_setup.cmake
index e59b7df30..f8106a7c6 100644
--- a/cmake/DD4hep_XML_setup.cmake
+++ b/cmake/DD4hep_XML_setup.cmake
@@ -1,4 +1,5 @@
 if(DD4HEP_USE_XERCESC)
+  find_package( XercesC REQUIRED )
   add_definitions(-DDD4HEP_USE_XERCESC)
   include_directories(SYSTEM ${XERCESC_INCLUDE_DIRS})
   set(XML_LIBRARIES ${XERCESC_LIBRARIES})
-- 
GitLab