Back to home page

EIC code displayed by LXR

 
 

    


Warning, /DD4hep/DDG4/CMakeLists.txt is written in an unsupported language. File is not indexed.

0001 #==========================================================================
0002 #  AIDA Detector description implementation 
0003 #--------------------------------------------------------------------------
0004 # Copyright (C) Organisation europeenne pour la Recherche nucleaire (CERN)
0005 # All rights reserved.
0006 #
0007 # For the licensing terms see $DD4hepINSTALL/LICENSE.
0008 # For the list of contributors see $DD4hepINSTALL/doc/CREDITS.
0009 #
0010 #==========================================================================
0011 SET_PROPERTY(DIRECTORY . PROPERTY PACKAGE_NAME DDG4)
0012 
0013 # configure Geant4
0014 IF(NOT DD4HEP_USE_GEANT4)
0015   dd4hep_print("|++> Not Using geant4, not building DDG4")
0016   RETURN()
0017 ENDIF()
0018 
0019 #---Add Library---------------------------------------------------------------------
0020 file(GLOB DDG4_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/src/*.cpp)
0021 add_library(DDG4 ${DDG4_SOURCES})
0022 add_library(DD4hep::DDG4 ALIAS DDG4)
0023 
0024 target_link_libraries(DDG4
0025   PUBLIC
0026   DD4hep::DDCore
0027   Geant4::Interface
0028   )
0029 #
0030 #Ensure our own includes come before those of the system
0031 target_include_directories(DDG4 BEFORE
0032   PUBLIC
0033   $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include/>
0034   $<INSTALL_INTERFACE:include>
0035 )
0036 
0037 if(NOT Geant4_gdml_FOUND)
0038   dd4hep_print("|++> Geant4 has no GDML library present....do not build corresponding features")
0039   target_compile_definitions(DDG4 PUBLIC -DGEANT4_NO_GDML)
0040 else()
0041   dd4hep_print("|++> Geant4 GDML library present....build G4 GDML components")
0042 endif()
0043 #-----------------------------------------------------------------------------------
0044 dd4hep_add_dictionary( G__DDG4
0045   SOURCES python/DDG4Dict.C
0046   USES    DD4hep::DDCore DD4hep::DDParsers DD4hep::DDG4 Geant4::Interface
0047   )
0048 #---------------------------  Plugin library for the simulation framework  ---------
0049 dd4hep_add_plugin(DDG4Plugins
0050   SOURCES   plugins/*.cpp
0051   GENERATED G__DDG4.cxx
0052   USES      DD4hep::DDG4 DD4hep::DDParsers ${XML_LIBRARIES} ROOT::Core ${CLHEP} 
0053   )
0054 #---------------------------  Plugin library for the simulation framework  ---------
0055 
0056 if(TARGET Python::Python AND TARGET ROOT::ROOTTPython)
0057   dd4hep_print("|++> Python found, creating DDG4Python Dictionary")
0058   dd4hep_add_dictionary(G__DDG4Python
0059     SOURCES src/python/DDG4Python.C
0060     USES    DD4hep::DDCore DD4hep::DDParsers DD4hep::DDG4 ROOT::Core Geant4::Interface
0061     )
0062   dd4hep_add_dictionary(G__DDPython
0063     SOURCES  tpython/DDPython.C
0064     USES     DD4hep::DDCore Python::Python
0065     )
0066   #---------------------------  Specialized python plugins  --------------------------
0067   dd4hep_print("|++> ROOT Has Python, creating DDPython library and plugins")
0068   add_library(DDPython G__DDPython.cxx tpython/DDPython.cpp)
0069   add_library(DD4hep::DDPython ALIAS DDPython)
0070   target_link_libraries(DDPython DD4hep::DDG4 ROOT::Core Python::Python ROOT::ROOTTPython)
0071   IF(${CMAKE_CXX_STANDARD} GREATER 16)
0072     # python header not cxx17 compatible, gives error in clang
0073     target_compile_options(DDPython PUBLIC -Wno-register)
0074   ENDIF()
0075   dd4hep_add_plugin(DDG4Python
0076     SOURCES   src/python/*.cpp
0077     GENERATED G__DDG4Python.cxx
0078     USES      DD4hep::DDG4 DD4hep::DDPython
0079     )
0080   #---Helper to overcome deficiency of the python executable concerning multi-threading
0081   add_executable(pyddg4 pyddg4.cpp)
0082   target_link_libraries(pyddg4 PUBLIC DD4hep::DDPython ROOT::Core ROOT::ROOTTPython)
0083 
0084   # install these libraries
0085   set_target_properties(DDPython DDG4Python PROPERTIES VERSION ${DD4hep_VERSION} SOVERSION ${DD4hep_SOVERSION})
0086   INSTALL(TARGETS DDPython pyddg4 DDG4Python EXPORT DD4hep
0087     LIBRARY DESTINATION lib
0088     RUNTIME DESTINATION bin)
0089 else()
0090   dd4hep_print("|+++++> Python or PyRoot/ROOTTPython not found, not creating DDG4 Python Dictionaries")
0091 endif()
0092 
0093 #---------------------------  Plugin library for the simulation framework  ---------
0094 #---------------------------  LCIO Plugins for new simulation framework  -----------
0095 IF(TARGET LCIO::lcio)
0096   dd4hep_add_plugin(DDG4LCIO
0097     SOURCES lcio/*.cpp
0098     USES    DD4hep::DDG4 LCIO::lcio
0099     )
0100   install(TARGETS DDG4LCIO EXPORT DD4hep LIBRARY DESTINATION lib)
0101   set_target_properties(DDG4LCIO PROPERTIES VERSION ${DD4hep_VERSION} SOVERSION ${DD4hep_SOVERSION})
0102 
0103 ENDIF()
0104 
0105 IF(TARGET EDM4HEP::edm4hep)
0106   dd4hep_add_plugin(DDG4EDM4HEP
0107     SOURCES edm4hep/Geant4Output2EDM4hep.cpp
0108     USES    DD4hep::DDG4 EDM4HEP::edm4hep EDM4HEP::edm4hepDict podio::podio podio::podioDict podio::podioRootIO
0109     )
0110   install(TARGETS DDG4EDM4HEP EXPORT DD4hep LIBRARY DESTINATION lib)
0111   set_target_properties(DDG4EDM4HEP PROPERTIES VERSION ${DD4hep_VERSION} SOVERSION ${DD4hep_SOVERSION})
0112   if(TARGET podio::podioIO)
0113       dd4hep_add_plugin(DDG4EDM4HEPReader
0114         SOURCES edm4hep/EDM4hepFileReader.cpp
0115         USES    DD4hep::DDG4 EDM4HEP::edm4hep EDM4HEP::edm4hepDict podio::podio podio::podioDict podio::podioIO
0116       )
0117       install(TARGETS DDG4EDM4HEPReader EXPORT DD4hep LIBRARY DESTINATION lib)
0118       set_target_properties(DDG4EDM4HEPReader PROPERTIES VERSION ${DD4hep_VERSION} SOVERSION ${DD4hep_SOVERSION})
0119       MESSAGE(STATUS "EDM4hepFileReader enabled")
0120   else()
0121       MESSAGE(STATUS "EDM4hepFileReader requires at least PODIO 1.0, disabled")
0122   endif()
0123 ENDIF()
0124 
0125 IF(DD4HEP_USE_HEPMC3)
0126   set(DDG4HepMC3_INCLUDES $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/hepmc> $<BUILD_INTERFACE:${HEPMC3_INCLUDE_DIR}>)
0127   set(DDG4HepMC3_USES DD4hep::DDG4 Geant4::Interface ${HEPMC3_LIBRARIES})
0128   set(DDG4HepMC3_DEFINITIONS)
0129 
0130   IF(DD4HEP_HEPMC3_COMPRESSION_SUPPORT)
0131     IF(ZLIB_FOUND)
0132       list(APPEND DDG4HepMC3_USES ZLIB::ZLIB)
0133       list(APPEND DDG4HepMC3_DEFINITIONS HEPMC3_USE_COMPRESSION HEPMC3_Z_SUPPORT=1)
0134     ENDIF()
0135     IF(LIBLZMA_FOUND)
0136       list(APPEND DDG4HepMC3_USES LibLZMA::LibLZMA)
0137       list(APPEND DDG4HepMC3_DEFINITIONS HEPMC3_USE_COMPRESSION HEPMC3_LZMA_SUPPORT=1)
0138     ENDIF()
0139     IF(BZIP2_FOUND)
0140       list(APPEND DDG4HepMC3_USES BZip2::BZip2)
0141       list(APPEND DDG4HepMC3_DEFINITIONS HEPMC3_USE_COMPRESSION HEPMC3_BZ2_SUPPORT=1)
0142     ENDIF()
0143   ENDIF()
0144 
0145   dd4hep_add_plugin(DDG4HepMC3
0146     SOURCES hepmc/*.cpp
0147     USES ${DDG4HepMC3_USES}
0148     INCLUDES ${DDG4HepMC3_INCLUDES}
0149     DEFINITIONS ${DDG4HepMC3_DEFINITIONS}
0150     )
0151   install(TARGETS DDG4HepMC3 EXPORT DD4hep LIBRARY DESTINATION lib)
0152   set_target_properties(DDG4HepMC3 PROPERTIES VERSION ${DD4hep_VERSION} SOVERSION ${DD4hep_SOVERSION})
0153   SET(DD4HEP_USE_HEPMC3 ON)
0154 ENDIF()
0155 
0156 #
0157 #---------------------------  DDRec dependent Plugins  -----------------------------
0158 #This does not compile at the moment
0159 # IF(TARGET DDRec)
0160 #   dd4hep_add_plugin(DDG4Reco
0161 #     SOURCES reco/*.cpp
0162 #     USES DDCore DDG4 DDRec
0163 #     )
0164 #   install(TARGETS DDG4Reco EXPORT DD4hep LIBRARY DESTINATION lib)
0165 # ENDIF()
0166 #-----------------------------------------------------------------------------------
0167 if(Geant4_gdml_FOUND)
0168   add_executable(g4gdmlDisplay g4gdmlDisplay.cpp)
0169   target_link_libraries(g4gdmlDisplay DDG4)
0170   install(TARGETS g4gdmlDisplay EXPORT DD4hep RUNTIME DESTINATION bin)
0171 endif()
0172 #
0173 #-----------------------------------------------------------------------------------
0174 add_executable(g4FromXML g4FromXML.cpp)
0175 target_link_libraries(g4FromXML DDG4)
0176 #
0177 #---Package installation procedure(s) ----------------------------------------------
0178 file(GLOB DDG4_python python/*.py python/*.C)
0179 install(FILES ${DDG4_python} DESTINATION ${DD4HEP_PYTHON_INSTALL_DIR})
0180 
0181 get_filename_component(PYTHON_INTERPRETER_BINARY ${Python_EXECUTABLE} NAME)
0182 configure_file(python/DDSim/bin/ddsim.in.py ${CMAKE_BINARY_DIR}/bin/ddsim @ONLY)
0183 install(PROGRAMS ${CMAKE_BINARY_DIR}/bin/ddsim DESTINATION bin)
0184 
0185 install(PROGRAMS python/bin/g4MaterialScan.py DESTINATION bin RENAME g4MaterialScan)
0186 install(PROGRAMS python/bin/g4GeometryScan.py DESTINATION bin RENAME g4GeometryScan)
0187 install(PROGRAMS python/bin/g4GraphicalScan.py DESTINATION bin RENAME g4GraphicalScan)
0188 
0189 # configure and install DD4hepSimulation files
0190 file(GLOB_RECURSE DDSIM_FILES RELATIVE ${CMAKE_CURRENT_LIST_DIR}/python/DDSim/ python/DDSim/*.py)
0191 execute_process(COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_BINARY_DIR}/python/DDSim/Helper)
0192 FOREACH(ddsimFile ${DDSIM_FILES})
0193   dd4hep_debug("Configuring ${ddsimFile}")
0194   # we pass all DDSim files through configure, because it is easier then only configuring only one of them, because we
0195   # need all of them to end up in the same directory to install them from there
0196   configure_file(python/DDSim/${ddsimFile} ${CMAKE_BINARY_DIR}/python/DDSim/${ddsimFile} @ONLY)
0197 ENDFOREACH()
0198 
0199 install(DIRECTORY ${CMAKE_BINARY_DIR}/python/DDSim DESTINATION ${DD4HEP_PYTHON_INSTALL_DIR})
0200 
0201 install(DIRECTORY examples DESTINATION examples/DDG4)
0202 
0203 set_target_properties(DDG4 DDG4Plugins PROPERTIES VERSION ${DD4hep_VERSION} SOVERSION ${DD4hep_SOVERSION})
0204 
0205 install(TARGETS DDG4 DDG4Plugins g4FromXML
0206   EXPORT DD4hep
0207   ARCHIVE DESTINATION lib
0208   LIBRARY DESTINATION lib
0209   RUNTIME DESTINATION bin)
0210 install(DIRECTORY include/DDG4 DESTINATION include)