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/*.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
0113 ENDIF()
0114
0115 IF(DD4HEP_USE_HEPMC3)
0116 set(DDG4HepMC3_INCLUDES $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/hepmc> $<BUILD_INTERFACE:${HEPMC3_INCLUDE_DIR}>)
0117 set(DDG4HepMC3_USES DD4hep::DDG4 Geant4::Interface ${HEPMC3_LIBRARIES})
0118 set(DDG4HepMC3_DEFINITIONS)
0119
0120 IF(DD4HEP_HEPMC3_COMPRESSION_SUPPORT)
0121 IF(ZLIB_FOUND)
0122 list(APPEND DDG4HepMC3_USES ZLIB::ZLIB)
0123 list(APPEND DDG4HepMC3_DEFINITIONS HEPMC3_USE_COMPRESSION HEPMC3_Z_SUPPORT=1)
0124 ENDIF()
0125 IF(LIBLZMA_FOUND)
0126 list(APPEND DDG4HepMC3_USES LibLZMA::LibLZMA)
0127 list(APPEND DDG4HepMC3_DEFINITIONS HEPMC3_USE_COMPRESSION HEPMC3_LZMA_SUPPORT=1)
0128 ENDIF()
0129 IF(BZIP2_FOUND)
0130 list(APPEND DDG4HepMC3_USES BZip2::BZip2)
0131 list(APPEND DDG4HepMC3_DEFINITIONS HEPMC3_USE_COMPRESSION HEPMC3_BZ2_SUPPORT=1)
0132 ENDIF()
0133 ENDIF()
0134
0135 dd4hep_add_plugin(DDG4HepMC3
0136 SOURCES hepmc/*.cpp
0137 USES ${DDG4HepMC3_USES}
0138 INCLUDES ${DDG4HepMC3_INCLUDES}
0139 DEFINITIONS ${DDG4HepMC3_DEFINITIONS}
0140 )
0141 install(TARGETS DDG4HepMC3 EXPORT DD4hep LIBRARY DESTINATION lib)
0142 set_target_properties(DDG4HepMC3 PROPERTIES VERSION ${DD4hep_VERSION} SOVERSION ${DD4hep_SOVERSION})
0143 SET(DD4HEP_USE_HEPMC3 ON)
0144 ENDIF()
0145
0146 #
0147 #--------------------------- DDRec dependent Plugins -----------------------------
0148 #This does not compile at the moment
0149 # IF(TARGET DDRec)
0150 # dd4hep_add_plugin(DDG4Reco
0151 # SOURCES reco/*.cpp
0152 # USES DDCore DDG4 DDRec
0153 # )
0154 # install(TARGETS DDG4Reco EXPORT DD4hep LIBRARY DESTINATION lib)
0155 # ENDIF()
0156 #-----------------------------------------------------------------------------------
0157 if(Geant4_gdml_FOUND)
0158 add_executable(g4gdmlDisplay g4gdmlDisplay.cpp)
0159 target_link_libraries(g4gdmlDisplay DDG4)
0160 install(TARGETS g4gdmlDisplay EXPORT DD4hep RUNTIME DESTINATION bin)
0161 endif()
0162 #
0163 #-----------------------------------------------------------------------------------
0164 add_executable(g4FromXML g4FromXML.cpp)
0165 target_link_libraries(g4FromXML DDG4)
0166 #
0167 #---Package installation procedure(s) ----------------------------------------------
0168 file(GLOB DDG4_python python/*.py python/*.C)
0169 install(FILES ${DDG4_python} DESTINATION ${DD4HEP_PYTHON_INSTALL_DIR})
0170
0171 get_filename_component(PYTHON_INTERPRETER_BINARY ${Python_EXECUTABLE} NAME)
0172 configure_file(python/DDSim/bin/ddsim.in.py ${CMAKE_BINARY_DIR}/bin/ddsim @ONLY)
0173 install(PROGRAMS ${CMAKE_BINARY_DIR}/bin/ddsim DESTINATION bin)
0174
0175 install(PROGRAMS python/bin/g4MaterialScan.py DESTINATION bin RENAME g4MaterialScan)
0176 install(PROGRAMS python/bin/g4GeometryScan.py DESTINATION bin RENAME g4GeometryScan)
0177
0178 # configure and install DD4hepSimulation files
0179 file(GLOB_RECURSE DDSIM_FILES RELATIVE ${CMAKE_CURRENT_LIST_DIR}/python/DDSim/ python/DDSim/*.py)
0180 execute_process(COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_BINARY_DIR}/python/DDSim/Helper)
0181 FOREACH(ddsimFile ${DDSIM_FILES})
0182 dd4hep_debug("Configuring ${ddsimFile}")
0183 # we pass all DDSim files through configure, because it is easier then only configuring only one of them, because we
0184 # need all of them to end up in the same directory to install them from there
0185 configure_file(python/DDSim/${ddsimFile} ${CMAKE_BINARY_DIR}/python/DDSim/${ddsimFile} @ONLY)
0186 ENDFOREACH()
0187
0188 install(DIRECTORY ${CMAKE_BINARY_DIR}/python/DDSim DESTINATION ${DD4HEP_PYTHON_INSTALL_DIR})
0189
0190 install(DIRECTORY examples DESTINATION examples/DDG4)
0191
0192 set_target_properties(DDG4 DDG4Plugins PROPERTIES VERSION ${DD4hep_VERSION} SOVERSION ${DD4hep_SOVERSION})
0193
0194 install(TARGETS DDG4 DDG4Plugins g4FromXML
0195 EXPORT DD4hep
0196 ARCHIVE DESTINATION lib
0197 LIBRARY DESTINATION lib
0198 RUNTIME DESTINATION bin)
0199 install(DIRECTORY include/DDG4 DESTINATION include)