diff --git a/CMakeLists.txt b/CMakeLists.txt index d1171ccd1eedf57f0567cc2b68bcdb3b41c94115..b918904d255f5bc9d294414412a5d8fdbce23c60 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -68,40 +68,40 @@ add_subdirectory(DDRec) add_subdirectory(DDDetectors) #fg: comment out this section as it seems to conflict with Geant4 10.02.p01 and CLHEP 2.3.1.1 -#if(DD4HEP_USE_GEANT4) -# set ( DD4HEP_USE_CLHEP "OFF" ) -# #--- create a geant4 variables for the thisdd4hep.sh script -# find_package( Geant4 9.6 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 -# -# string(FIND "${Geant4_THIRD_PARTY_INCLUDE_DIRS}" "CLHEP" CLHEP_POS ) -# -# if( (NOT "${CLHEP_POS}" STREQUAL "-1") OR (NOT Geant4_builtin_clhep_FOUND) ) -# 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 ) +if(DD4HEP_USE_GEANT4) + set ( DD4HEP_USE_CLHEP "OFF" ) + #--- create a geant4 variables for the thisdd4hep.sh script + find_package( Geant4 9.6 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 + + string(FIND "${Geant4_THIRD_PARTY_INCLUDE_DIRS}" "CLHEP" CLHEP_POS ) + + if( (NOT "${CLHEP_POS}" STREQUAL "-1") OR (NOT Geant4_builtin_clhep_FOUND) ) + 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 ) -# if( CLHEP_DIR ) #---- use 'canonical' name ----- -# set( CLHEP_ROOT_DIR ${CLHEP_DIR} ) -# endif() -# -# find_package( CLHEP REQUIRED ) -# include_directories( SYSTEM ${CLHEP_INCLUDE_DIRS} ) -# set ( DD4HEP_USE_CLHEP ON ) -# -# get_filename_component(CLHEP_LIBRARY_PATH "${CLHEP_LIBRARIES}" PATH) -# message( STATUS " *** geant4 was build with external CLHEP *** CLHEP_LIBRARY_PATH = ${CLHEP_LIBRARY_PATH}" ) -# else() -# set( GEANT4_USE_CLHEP 0 ) -# endif() -# -# set(Geant4_INCLUDE_DIRS ${Geant4_INCLUDE_DIRS} ${CLHEP_INCLUDE_DIRS}) -# set(Geant4_LIBRARIES ${Geant4_LIBRARIES} ${CLHEP_LIBRARIES}) -#endif() + if( CLHEP_DIR ) #---- use 'canonical' name ----- + set( CLHEP_ROOT_DIR ${CLHEP_DIR} ) + endif() + + find_package( CLHEP REQUIRED ) + include_directories( SYSTEM ${CLHEP_INCLUDE_DIRS} ) + set ( DD4HEP_USE_CLHEP ON ) + + get_filename_component(CLHEP_LIBRARY_PATH "${CLHEP_LIBRARIES}" PATH) + message( STATUS " *** geant4 was build with external CLHEP *** CLHEP_LIBRARY_PATH = ${CLHEP_LIBRARY_PATH}" ) + else() + set( GEANT4_USE_CLHEP 0 ) + endif() + + set(Geant4_INCLUDE_DIRS ${Geant4_INCLUDE_DIRS} ${CLHEP_INCLUDE_DIRS}) + set(Geant4_LIBRARIES ${Geant4_LIBRARIES} ${CLHEP_LIBRARIES}) +endif() #------- now configure DDG4 ------- add_subdirectory(DDG4)