From 379622d5832f2516351f6cc86ee57752dd21c0ec Mon Sep 17 00:00:00 2001
From: Frank Gaede <frank.gaede@desy.de>
Date: Thu, 17 Jul 2014 17:00:11 +0000
Subject: [PATCH]  - changed building of DDSegmentation: now always done as
 inclusive    part of DD4hep, i.e. no external library option    - however
 DDSegementationConfig is created for other packages to      build against it 
 - changed library versioning of DDSegmentation to be in synch w/ DD4hep    (
 versions and so-versions)  - some cleanup of geant4 stuff

---
 CMakeLists.txt                | 25 +++++++++++++++++--------
 DDG4/CMakeLists.txt           |  2 +-
 DDSegmentation/CMakeLists.txt |  8 ++++----
 cmake/DD4hepConfig.cmake.in   |  2 ++
 4 files changed, 24 insertions(+), 13 deletions(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 8152ced1a..277af9e49 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -83,23 +83,23 @@ ENDIF()
 
 #---Packages------------------------------------------------------------------------
 
-#------ allow to use a pre-built DDSegmentation  ----------------------------
-find_package( DDSegmentation QUIET )
-if( NOT DDSegmentation_FOUND ) 
-  add_subdirectory(DDSegmentation)
-endif()
+##------ don't allow to use a pre-built DDSegmentation  ----------------------------
+#find_package( DDSegmentation QUIET )
+#if( NOT DDSegmentation_FOUND ) 
+#  add_subdirectory(DDSegmentation)
+#endif()
 
+add_subdirectory(DDSegmentation)
 add_subdirectory(DDCore)
 add_subdirectory(DDSurfaces)
 add_subdirectory(DDRec)
 add_subdirectory(DDSense)
 
 if(DD4HEP_USE_GEANT4)
-  add_subdirectory(DDG4)
 
   #--- create a geant4 variables for the thisdd4hep.sh script
-  find_package( Geant4 REQUIRED )
-  get_filename_component(Geant4_ROOT "${Geant4_INCLUDE_DIR}/../../" ABSOLUTE)
+  find_package( Geant4 REQUIRED  gdml ui_all vis_all)
+
 
   #----- if geant4 is build with external CLHEP we also need to export this fact
 
@@ -109,6 +109,8 @@ if(DD4HEP_USE_GEANT4)
 
     set( GEANT4_USE_CLHEP 1 )
 
+    get_filename_component(Geant4_ROOT "${Geant4_INCLUDE_DIR}/../../" ABSOLUTE)
+
     #---- use FindCLHEP shipped with geant4 -----------
     set(CMAKE_MODULE_PATH  ${CMAKE_MODULE_PATH}  ${Geant4_ROOT}/cmake/Modules ) 
     
@@ -125,6 +127,13 @@ if(DD4HEP_USE_GEANT4)
     set( GEANT4_USE_CLHEP 0 )
   endif()
 
+  set(Geant4_INCLUDE_DIRS ${Geant4_INCLUDE_DIRS} ${CLHEP_INCLUDE_DIRS})
+  set(Geant4_LIBRARIES ${Geant4_LIBRARIES} ${CLHEP_LIBRARIES})
+
+
+#------- now configure DDG4 -------
+  add_subdirectory(DDG4)
+
 endif()
 
 
diff --git a/DDG4/CMakeLists.txt b/DDG4/CMakeLists.txt
index d3ca3f778..f8d5e4aef 100644
--- a/DDG4/CMakeLists.txt
+++ b/DDG4/CMakeLists.txt
@@ -1,6 +1,6 @@
 #---Find Geant4-------------------------------------------------------------------
 
-find_package(Geant4 REQUIRED gdml ui_all vis_all)
+#find_package(Geant4 REQUIRED gdml ui_all vis_all)
 #if(NOT Geant4_clhep_FOUND)
 #  find_package(CLHEP REQUIRED)
 #  set(Geant4_INCLUDE_DIRS ${Geant4_INCLUDE_DIRS} ${CLHEP_INCLUDE_DIRS})
diff --git a/DDSegmentation/CMakeLists.txt b/DDSegmentation/CMakeLists.txt
index 1a7977356..0ed335ca1 100644
--- a/DDSegmentation/CMakeLists.txt
+++ b/DDSegmentation/CMakeLists.txt
@@ -1,11 +1,11 @@
 cmake_minimum_required(VERSION 2.8.3 FATAL_ERROR)
 project(DDSegmentation)
- 
+ #fg: version number must be the same as DD4hep !!
 set(DDSegmentation_MAJOR_VERSION 0)
-set(DDSegmentation_MINOR_VERSION 1)
+set(DDSegmentation_MINOR_VERSION 6)
 set(DDSegmentation_PATCH_VERSION 0)
-set(DDSegmentation_VERSION ${DDSegmentation_MAJOR_VERSION}.${DDSegmentation_MINOR_VERSION}.${DDSegmentation_PATCH_VERSION})
-set(DDSegmentation_SOVERSION "${DDSegmentation_MAJOR_VERSION}.${DDSegmentation_MINOR_VERSION}.${DDSegmentation_PATCH_VERSION}" )
+set(DDSegmentation_VERSION "${DDSegmentation_MAJOR_VERSION}.${DDSegmentation_MINOR_VERSION}" )
+set(DDSegmentation_SOVERSION "${DDSegmentation_MAJOR_VERSION}.${DDSegmentation_MINOR_VERSION}")
 
 #------------- set the default installation directory to be the source directory
 
diff --git a/cmake/DD4hepConfig.cmake.in b/cmake/DD4hepConfig.cmake.in
index 03cd342e0..558c7fc15 100644
--- a/cmake/DD4hepConfig.cmake.in
+++ b/cmake/DD4hepConfig.cmake.in
@@ -53,6 +53,8 @@ if(@DD4HEP_USE_GEANT4@)
     set(GEANT4_USE_CLHEP  1 ) 
   endif()
 
+  set( Geant4_DIR @Geant4_DIR@)
+
 else()
   CHECK_PACKAGE_LIBS( DD4hep DD4hepCore DDSegmentation DD4hepRec DD4hepPlugins ) 
 endif()
-- 
GitLab