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 #-----------------------------------------------------------------------------------
0049 # Note:
0050 # This is only an example how to add customizable G4 physics constructors.
0051 # You only need a compiled dictionary. Other specializations unless required
0052 # by multiple people should be kept in user space.
0053 #
0054 dd4hep_add_dictionary( G__DDG4Physics
0055 SOURCES python/DDG4PhysicsDict.C
0056 USES DD4hep::DDCore DD4hep::DDParsers DD4hep::DDG4 Geant4::Interface
0057 )
0058 #--------------------------- Plugin library for the simulation framework ---------
0059 dd4hep_add_plugin(DDG4Plugins
0060 SOURCES plugins/*.cpp
0061 GENERATED G__DDG4.cxx G__DDG4Physics.cxx
0062 USES DD4hep::DDG4 DD4hep::DDParsers ${XML_LIBRARIES} ROOT::Core ${CLHEP}
0063 )
0064 #--------------------------- Plugin library for the simulation framework ---------
0065
0066 if(TARGET Python::Python AND TARGET ROOT::ROOTTPython)
0067 dd4hep_print("|++> Python found, creating DDG4Python Dictionary")
0068 dd4hep_add_dictionary(G__DDG4Python
0069 SOURCES src/python/DDG4Python.C
0070 USES DD4hep::DDCore DD4hep::DDParsers DD4hep::DDG4 ROOT::Core Geant4::Interface
0071 )
0072 dd4hep_add_dictionary(G__DDPython
0073 SOURCES tpython/DDPython.C
0074 USES DD4hep::DDCore Python::Python
0075 )
0076 #--------------------------- Specialized python plugins --------------------------
0077 dd4hep_print("|++> ROOT Has Python, creating DDPython library and plugins")
0078 add_library(DDPython G__DDPython.cxx tpython/DDPython.cpp)
0079 add_library(DD4hep::DDPython ALIAS DDPython)
0080 target_link_libraries(DDPython DD4hep::DDG4 ROOT::Core Python::Python ROOT::ROOTTPython)
0081 # python header not cxx17 compatible, gives error in clang
0082 target_compile_options(DDPython PUBLIC -Wno-register)
0083 dd4hep_add_plugin(DDG4Python
0084 SOURCES src/python/*.cpp
0085 GENERATED G__DDG4Python.cxx
0086 USES DD4hep::DDG4 DD4hep::DDPython
0087 )
0088 #---Helper to overcome deficiency of the python executable concerning multi-threading
0089 add_executable(pyddg4 pyddg4.cpp)
0090 target_link_libraries(pyddg4 PUBLIC DD4hep::DDPython ROOT::Core ROOT::ROOTTPython)
0091
0092 # install these libraries
0093 set_target_properties(DDPython DDG4Python PROPERTIES VERSION ${DD4hep_VERSION} SOVERSION ${DD4hep_SOVERSION})
0094 INSTALL(TARGETS DDPython pyddg4 DDG4Python EXPORT DD4hep
0095 LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
0096 RUNTIME DESTINATION bin)
0097 else()
0098 dd4hep_print("|+++++> Python or PyRoot/ROOTTPython not found, not creating DDG4 Python Dictionaries")
0099 endif()
0100
0101 #--------------------------- Plugin library for the simulation framework ---------
0102 #--------------------------- LCIO Plugins for new simulation framework -----------
0103 IF(TARGET LCIO::lcio)
0104 dd4hep_add_plugin(DDG4LCIO
0105 SOURCES lcio/*.cpp
0106 USES DD4hep::DDG4 LCIO::lcio
0107 )
0108 set_target_properties(DDG4LCIO PROPERTIES VERSION ${DD4hep_VERSION} SOVERSION ${DD4hep_SOVERSION})
0109
0110 ENDIF()
0111
0112 IF(TARGET EDM4HEP::edm4hep)
0113 if(podio_VERSION VERSION_GREATER_EQUAL "1.0.0")
0114 set(DDG4_PODIO_IO_TARGET podio::podioIO)
0115 else()
0116 set(DDG4_PODIO_IO_TARGET podio::podioRootIO)
0117 endif()
0118 dd4hep_add_plugin(DDG4EDM4HEP
0119 SOURCES edm4hep/Geant4Output2EDM4hep.cpp
0120 USES DD4hep::DDG4 EDM4HEP::edm4hep EDM4HEP::edm4hepDict podio::podio podio::podioDict ${DDG4_PODIO_IO_TARGET}
0121 )
0122 set_target_properties(DDG4EDM4HEP PROPERTIES VERSION ${DD4hep_VERSION} SOVERSION ${DD4hep_SOVERSION})
0123 if(TARGET podio::podioIO)
0124 dd4hep_add_plugin(DDG4EDM4HEPReader
0125 SOURCES edm4hep/EDM4hepFileReader.cpp
0126 USES DD4hep::DDG4 EDM4HEP::edm4hep EDM4HEP::edm4hepDict podio::podio podio::podioDict podio::podioIO
0127 )
0128 set_target_properties(DDG4EDM4HEPReader PROPERTIES VERSION ${DD4hep_VERSION} SOVERSION ${DD4hep_SOVERSION})
0129 MESSAGE(STATUS "EDM4hepFileReader enabled")
0130 else()
0131 MESSAGE(STATUS "EDM4hepFileReader requires at least PODIO 1.0, disabled")
0132 endif()
0133 ENDIF()
0134
0135 IF(DD4HEP_USE_HEPMC3)
0136 set(DDG4HepMC3_INCLUDES $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/hepmc> $<BUILD_INTERFACE:${HEPMC3_INCLUDE_DIR}>)
0137 set(DDG4HepMC3_USES DD4hep::DDG4 Geant4::Interface ${HEPMC3_LIBRARIES})
0138 set(DDG4HepMC3_DEFINITIONS)
0139
0140 IF(DD4HEP_HEPMC3_COMPRESSION_SUPPORT)
0141 IF(ZLIB_FOUND)
0142 list(APPEND DDG4HepMC3_USES ZLIB::ZLIB)
0143 list(APPEND DDG4HepMC3_DEFINITIONS HEPMC3_USE_COMPRESSION HEPMC3_Z_SUPPORT=1)
0144 ENDIF()
0145 IF(LIBLZMA_FOUND)
0146 list(APPEND DDG4HepMC3_USES LibLZMA::LibLZMA)
0147 list(APPEND DDG4HepMC3_DEFINITIONS HEPMC3_USE_COMPRESSION HEPMC3_LZMA_SUPPORT=1)
0148 ENDIF()
0149 IF(BZIP2_FOUND)
0150 list(APPEND DDG4HepMC3_USES BZip2::BZip2)
0151 list(APPEND DDG4HepMC3_DEFINITIONS HEPMC3_USE_COMPRESSION HEPMC3_BZ2_SUPPORT=1)
0152 ENDIF()
0153 ENDIF()
0154
0155 dd4hep_add_plugin(DDG4HepMC3
0156 SOURCES hepmc/*.cpp
0157 USES ${DDG4HepMC3_USES}
0158 INCLUDES ${DDG4HepMC3_INCLUDES}
0159 DEFINITIONS ${DDG4HepMC3_DEFINITIONS}
0160 )
0161 install(TARGETS DDG4HepMC3 EXPORT DD4hep LIBRARY DESTINATION lib)
0162 set_target_properties(DDG4HepMC3 PROPERTIES VERSION ${DD4hep_VERSION} SOVERSION ${DD4hep_SOVERSION})
0163 SET(DD4HEP_USE_HEPMC3 ON)
0164 ENDIF()
0165
0166 #
0167 #--------------------------- DDRec dependent Plugins -----------------------------
0168 #This does not compile at the moment
0169 # IF(TARGET DDRec)
0170 # dd4hep_add_plugin(DDG4Reco
0171 # SOURCES reco/*.cpp
0172 # USES DDCore DDG4 DDRec
0173 # )
0174 # install(TARGETS DDG4Reco EXPORT DD4hep LIBRARY DESTINATION lib)
0175 # ENDIF()
0176 #-----------------------------------------------------------------------------------
0177 if(Geant4_gdml_FOUND)
0178 add_executable(g4gdmlDisplay g4gdmlDisplay.cpp)
0179 target_link_libraries(g4gdmlDisplay DDG4)
0180 install(TARGETS g4gdmlDisplay EXPORT DD4hep RUNTIME DESTINATION bin)
0181 endif()
0182 #
0183 #-----------------------------------------------------------------------------------
0184 add_executable(g4FromXML g4FromXML.cpp)
0185 target_link_libraries(g4FromXML DDG4)
0186 #
0187 #---Package installation procedure(s) ----------------------------------------------
0188 file(GLOB DDG4_python python/*.py python/*.C)
0189 install(FILES ${DDG4_python} DESTINATION ${DD4HEP_PYTHON_INSTALL_DIR})
0190
0191 get_filename_component(PYTHON_INTERPRETER_BINARY ${Python_EXECUTABLE} NAME)
0192 configure_file(python/DDSim/bin/ddsim.in.py ${CMAKE_BINARY_DIR}/bin/ddsim @ONLY)
0193 install(PROGRAMS ${CMAKE_BINARY_DIR}/bin/ddsim DESTINATION bin)
0194
0195 install(PROGRAMS python/bin/g4MaterialScan.py DESTINATION bin RENAME g4MaterialScan)
0196 install(PROGRAMS python/bin/g4GeometryScan.py DESTINATION bin RENAME g4GeometryScan)
0197 install(PROGRAMS python/bin/g4GraphicalScan.py DESTINATION bin RENAME g4GraphicalScan)
0198
0199 # configure and install DD4hepSimulation files
0200 file(GLOB_RECURSE DDSIM_FILES RELATIVE ${CMAKE_CURRENT_LIST_DIR}/python/DDSim/ python/DDSim/*.py)
0201 execute_process(COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_BINARY_DIR}/python/DDSim/Helper)
0202 FOREACH(ddsimFile ${DDSIM_FILES})
0203 dd4hep_debug("Configuring ${ddsimFile}")
0204 # we pass all DDSim files through configure, because it is easier then only configuring only one of them, because we
0205 # need all of them to end up in the same directory to install them from there
0206 configure_file(python/DDSim/${ddsimFile} ${CMAKE_BINARY_DIR}/python/DDSim/${ddsimFile} @ONLY)
0207 ENDFOREACH()
0208
0209 install(DIRECTORY ${CMAKE_BINARY_DIR}/python/DDSim DESTINATION ${DD4HEP_PYTHON_INSTALL_DIR})
0210
0211 install(DIRECTORY examples DESTINATION examples/DDG4)
0212
0213 set_target_properties(DDG4 DDG4Plugins PROPERTIES VERSION ${DD4hep_VERSION} SOVERSION ${DD4hep_SOVERSION})
0214
0215 install(TARGETS DDG4 g4FromXML
0216 EXPORT DD4hep
0217 ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
0218 LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
0219 RUNTIME DESTINATION bin)
0220 install(DIRECTORY include/DDG4 DESTINATION include)