-
Notifications
You must be signed in to change notification settings - Fork 103
/
Copy pathCMakeLists.txt
210 lines (190 loc) · 8.61 KB
/
CMakeLists.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
#==========================================================================
# AIDA Detector description implementation
#--------------------------------------------------------------------------
# Copyright (C) Organisation europeenne pour la Recherche nucleaire (CERN)
# All rights reserved.
#
# For the licensing terms see $DD4hepINSTALL/LICENSE.
# For the list of contributors see $DD4hepINSTALL/doc/CREDITS.
#
#==========================================================================
SET_PROPERTY(DIRECTORY . PROPERTY PACKAGE_NAME DDG4)
# configure Geant4
IF(NOT DD4HEP_USE_GEANT4)
dd4hep_print("|++> Not Using geant4, not building DDG4")
RETURN()
ENDIF()
#---Add Library---------------------------------------------------------------------
file(GLOB DDG4_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/src/*.cpp)
add_library(DDG4 ${DDG4_SOURCES})
add_library(DD4hep::DDG4 ALIAS DDG4)
target_link_libraries(DDG4
PUBLIC
DD4hep::DDCore
Geant4::Interface
)
#
#Ensure our own includes come before those of the system
target_include_directories(DDG4 BEFORE
PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include/>
$<INSTALL_INTERFACE:include>
)
if(NOT Geant4_gdml_FOUND)
dd4hep_print("|++> Geant4 has no GDML library present....do not build corresponding features")
target_compile_definitions(DDG4 PUBLIC -DGEANT4_NO_GDML)
else()
dd4hep_print("|++> Geant4 GDML library present....build G4 GDML components")
endif()
#-----------------------------------------------------------------------------------
dd4hep_add_dictionary( G__DDG4
SOURCES python/DDG4Dict.C
USES DD4hep::DDCore DD4hep::DDParsers DD4hep::DDG4 Geant4::Interface
)
#--------------------------- Plugin library for the simulation framework ---------
dd4hep_add_plugin(DDG4Plugins
SOURCES plugins/*.cpp
GENERATED G__DDG4.cxx
USES DD4hep::DDG4 DD4hep::DDParsers ${XML_LIBRARIES} ROOT::Core ${CLHEP}
)
#--------------------------- Plugin library for the simulation framework ---------
if(TARGET Python::Python AND TARGET ROOT::ROOTTPython)
dd4hep_print("|++> Python found, creating DDG4Python Dictionary")
dd4hep_add_dictionary(G__DDG4Python
SOURCES src/python/DDG4Python.C
USES DD4hep::DDCore DD4hep::DDParsers DD4hep::DDG4 ROOT::Core Geant4::Interface
)
dd4hep_add_dictionary(G__DDPython
SOURCES tpython/DDPython.C
USES DD4hep::DDCore Python::Python
)
#--------------------------- Specialized python plugins --------------------------
dd4hep_print("|++> ROOT Has Python, creating DDPython library and plugins")
add_library(DDPython G__DDPython.cxx tpython/DDPython.cpp)
add_library(DD4hep::DDPython ALIAS DDPython)
target_link_libraries(DDPython DD4hep::DDG4 ROOT::Core Python::Python ROOT::ROOTTPython)
IF(${CMAKE_CXX_STANDARD} GREATER 16)
# python header not cxx17 compatible, gives error in clang
target_compile_options(DDPython PUBLIC -Wno-register)
ENDIF()
dd4hep_add_plugin(DDG4Python
SOURCES src/python/*.cpp
GENERATED G__DDG4Python.cxx
USES DD4hep::DDG4 DD4hep::DDPython
)
#---Helper to overcome deficiency of the python executable concerning multi-threading
add_executable(pyddg4 pyddg4.cpp)
target_link_libraries(pyddg4 PUBLIC DD4hep::DDPython ROOT::Core ROOT::ROOTTPython)
# install these libraries
set_target_properties(DDPython DDG4Python PROPERTIES VERSION ${DD4hep_VERSION} SOVERSION ${DD4hep_SOVERSION})
INSTALL(TARGETS DDPython pyddg4 DDG4Python EXPORT DD4hep
LIBRARY DESTINATION lib
RUNTIME DESTINATION bin)
else()
dd4hep_print("|+++++> Python or PyRoot/ROOTTPython not found, not creating DDG4 Python Dictionaries")
endif()
#--------------------------- Plugin library for the simulation framework ---------
#--------------------------- LCIO Plugins for new simulation framework -----------
IF(TARGET LCIO::lcio)
dd4hep_add_plugin(DDG4LCIO
SOURCES lcio/*.cpp
USES DD4hep::DDG4 LCIO::lcio
)
install(TARGETS DDG4LCIO EXPORT DD4hep LIBRARY DESTINATION lib)
set_target_properties(DDG4LCIO PROPERTIES VERSION ${DD4hep_VERSION} SOVERSION ${DD4hep_SOVERSION})
ENDIF()
IF(TARGET EDM4HEP::edm4hep)
dd4hep_add_plugin(DDG4EDM4HEP
SOURCES edm4hep/Geant4Output2EDM4hep.cpp
USES DD4hep::DDG4 EDM4HEP::edm4hep EDM4HEP::edm4hepDict podio::podio podio::podioDict podio::podioRootIO
)
install(TARGETS DDG4EDM4HEP EXPORT DD4hep LIBRARY DESTINATION lib)
set_target_properties(DDG4EDM4HEP PROPERTIES VERSION ${DD4hep_VERSION} SOVERSION ${DD4hep_SOVERSION})
if(TARGET podio::podioIO)
dd4hep_add_plugin(DDG4EDM4HEPReader
SOURCES edm4hep/EDM4hepFileReader.cpp
USES DD4hep::DDG4 EDM4HEP::edm4hep EDM4HEP::edm4hepDict podio::podio podio::podioDict podio::podioIO
)
install(TARGETS DDG4EDM4HEPReader EXPORT DD4hep LIBRARY DESTINATION lib)
set_target_properties(DDG4EDM4HEPReader PROPERTIES VERSION ${DD4hep_VERSION} SOVERSION ${DD4hep_SOVERSION})
MESSAGE(STATUS "EDM4hepFileReader enabled")
else()
MESSAGE(STATUS "EDM4hepFileReader requires at least PODIO 1.0, disabled")
endif()
ENDIF()
IF(DD4HEP_USE_HEPMC3)
set(DDG4HepMC3_INCLUDES $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/hepmc> $<BUILD_INTERFACE:${HEPMC3_INCLUDE_DIR}>)
set(DDG4HepMC3_USES DD4hep::DDG4 Geant4::Interface ${HEPMC3_LIBRARIES})
set(DDG4HepMC3_DEFINITIONS)
IF(DD4HEP_HEPMC3_COMPRESSION_SUPPORT)
IF(ZLIB_FOUND)
list(APPEND DDG4HepMC3_USES ZLIB::ZLIB)
list(APPEND DDG4HepMC3_DEFINITIONS HEPMC3_USE_COMPRESSION HEPMC3_Z_SUPPORT=1)
ENDIF()
IF(LIBLZMA_FOUND)
list(APPEND DDG4HepMC3_USES LibLZMA::LibLZMA)
list(APPEND DDG4HepMC3_DEFINITIONS HEPMC3_USE_COMPRESSION HEPMC3_LZMA_SUPPORT=1)
ENDIF()
IF(BZIP2_FOUND)
list(APPEND DDG4HepMC3_USES BZip2::BZip2)
list(APPEND DDG4HepMC3_DEFINITIONS HEPMC3_USE_COMPRESSION HEPMC3_BZ2_SUPPORT=1)
ENDIF()
ENDIF()
dd4hep_add_plugin(DDG4HepMC3
SOURCES hepmc/*.cpp
USES ${DDG4HepMC3_USES}
INCLUDES ${DDG4HepMC3_INCLUDES}
DEFINITIONS ${DDG4HepMC3_DEFINITIONS}
)
install(TARGETS DDG4HepMC3 EXPORT DD4hep LIBRARY DESTINATION lib)
set_target_properties(DDG4HepMC3 PROPERTIES VERSION ${DD4hep_VERSION} SOVERSION ${DD4hep_SOVERSION})
SET(DD4HEP_USE_HEPMC3 ON)
ENDIF()
#
#--------------------------- DDRec dependent Plugins -----------------------------
#This does not compile at the moment
# IF(TARGET DDRec)
# dd4hep_add_plugin(DDG4Reco
# SOURCES reco/*.cpp
# USES DDCore DDG4 DDRec
# )
# install(TARGETS DDG4Reco EXPORT DD4hep LIBRARY DESTINATION lib)
# ENDIF()
#-----------------------------------------------------------------------------------
if(Geant4_gdml_FOUND)
add_executable(g4gdmlDisplay g4gdmlDisplay.cpp)
target_link_libraries(g4gdmlDisplay DDG4)
install(TARGETS g4gdmlDisplay EXPORT DD4hep RUNTIME DESTINATION bin)
endif()
#
#-----------------------------------------------------------------------------------
add_executable(g4FromXML g4FromXML.cpp)
target_link_libraries(g4FromXML DDG4)
#
#---Package installation procedure(s) ----------------------------------------------
file(GLOB DDG4_python python/*.py python/*.C)
install(FILES ${DDG4_python} DESTINATION ${DD4HEP_PYTHON_INSTALL_DIR})
get_filename_component(PYTHON_INTERPRETER_BINARY ${Python_EXECUTABLE} NAME)
configure_file(python/DDSim/bin/ddsim.in.py ${CMAKE_BINARY_DIR}/bin/ddsim @ONLY)
install(PROGRAMS ${CMAKE_BINARY_DIR}/bin/ddsim DESTINATION bin)
install(PROGRAMS python/bin/g4MaterialScan.py DESTINATION bin RENAME g4MaterialScan)
install(PROGRAMS python/bin/g4GeometryScan.py DESTINATION bin RENAME g4GeometryScan)
install(PROGRAMS python/bin/g4GraphicalScan.py DESTINATION bin RENAME g4GraphicalScan)
# configure and install DD4hepSimulation files
file(GLOB_RECURSE DDSIM_FILES RELATIVE ${CMAKE_CURRENT_LIST_DIR}/python/DDSim/ python/DDSim/*.py)
execute_process(COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_BINARY_DIR}/python/DDSim/Helper)
FOREACH(ddsimFile ${DDSIM_FILES})
dd4hep_debug("Configuring ${ddsimFile}")
# we pass all DDSim files through configure, because it is easier then only configuring only one of them, because we
# need all of them to end up in the same directory to install them from there
configure_file(python/DDSim/${ddsimFile} ${CMAKE_BINARY_DIR}/python/DDSim/${ddsimFile} @ONLY)
ENDFOREACH()
install(DIRECTORY ${CMAKE_BINARY_DIR}/python/DDSim DESTINATION ${DD4HEP_PYTHON_INSTALL_DIR})
install(DIRECTORY examples DESTINATION examples/DDG4)
set_target_properties(DDG4 DDG4Plugins PROPERTIES VERSION ${DD4hep_VERSION} SOVERSION ${DD4hep_SOVERSION})
install(TARGETS DDG4 DDG4Plugins g4FromXML
EXPORT DD4hep
ARCHIVE DESTINATION lib
LIBRARY DESTINATION lib
RUNTIME DESTINATION bin)
install(DIRECTORY include/DDG4 DESTINATION include)