Warning, /acts/Python/Examples/CMakeLists.txt is written in an unsupported language. File is not indexed.
0001 set(_python_dir "${CMAKE_BINARY_DIR}/python")
0002 file(MAKE_DIRECTORY ${_python_dir})
0003 file(MAKE_DIRECTORY ${_python_dir}/acts)
0004
0005 set(_python_install_dir "python/acts/examples")
0006 set(py_files
0007 __init__.py
0008 simulation.py
0009 reconstruction.py
0010 itk.py
0011 odd.py
0012 )
0013
0014 # Macro to add example bindings conditionally
0015 macro(add_examples_binding_if _name _link_libraries _flag _plugin_import)
0016 # Create a lower case name version
0017 string(TOLOWER ${_name} _name_lower)
0018
0019 if(${_flag})
0020 # automatically populate the init file with actually built modules
0021 #list(APPEND _plugins_built "'${_name_lower}'")
0022 # automatically prefix the target name
0023 set(_target "ActsExamplesPythonBindings${_name}")
0024
0025 pybind11_add_module(${_target} src/plugins/${_name}.cpp)
0026
0027 install(TARGETS ${_target} DESTINATION ${_python_install_dir})
0028
0029 set_target_properties(
0030 ${_target}
0031 PROPERTIES INSTALL_RPATH "\$ORIGIN/../../${CMAKE_INSTALL_LIBDIR}"
0032 )
0033 set_target_properties(
0034 ${_target}
0035 PROPERTIES LIBRARY_OUTPUT_DIRECTORY ${_python_dir}/acts/examples
0036 )
0037
0038 target_link_libraries(
0039 ${_target}
0040 PUBLIC Acts::Core Acts::PythonUtilities ${_link_libraries}
0041 )
0042 # Add the dependencies
0043 add_dependencies(ActsPythonBindings ${_target})
0044 endif()
0045
0046 set(EXAMPLE_NAME "${_name}")
0047 set(EXAMPLE_BUILD_FLAG "${_flag}")
0048 set(PLUGIN_IMPORT "")
0049 if(${_plugin_import})
0050 set(PLUGIN_IMPORT "from acts import ${_name_lower}")
0051 endif()
0052
0053 configure_file(
0054 ${CMAKE_CURRENT_SOURCE_DIR}/python/example.py.in
0055 ${_python_dir}/acts/examples/${_name_lower}.py
0056 @ONLY
0057 )
0058 # Augment the file if needed
0059 if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/python/${_name_lower}_aux.py.in")
0060 file(
0061 READ
0062 "${CMAKE_CURRENT_SOURCE_DIR}/python/${_name_lower}_aux.py.in"
0063 _extra_content
0064 )
0065 file(
0066 APPEND
0067 "${_python_dir}/acts/examples/${_name_lower}.py"
0068 "\n${_extra_content}"
0069 )
0070 endif()
0071 # Install the file
0072 install(
0073 FILES ${_python_dir}/acts/examples/${_name_lower}.py
0074 DESTINATION ${_python_install_dir}
0075 )
0076 endmacro()
0077
0078 # Add the examples python binding
0079 pybind11_add_module(ActsExamplesPythonBindings src/ExamplesModuleEntry.cpp)
0080
0081 # The PythonBindings for the examples
0082 target_sources(
0083 ActsExamplesPythonBindings
0084 PRIVATE
0085 src/Framework.cpp
0086 src/ExampleAlgorithms.cpp
0087 src/Generators.cpp
0088 src/AmbiguityResolution.cpp
0089 src/Detector.cpp
0090 src/Digitization.cpp
0091 src/MaterialMapping.cpp
0092 src/Propagation.cpp
0093 src/TrackFinding.cpp
0094 src/TrackFitting.cpp
0095 src/TruthTracking.cpp
0096 src/Vertexing.cpp
0097 src/Input.cpp
0098 src/Output.cpp
0099 src/Obj.cpp
0100 src/Utilities.cpp
0101 )
0102
0103 install(TARGETS ActsExamplesPythonBindings DESTINATION ${_python_install_dir})
0104
0105 set_target_properties(
0106 ActsExamplesPythonBindings
0107 PROPERTIES INSTALL_RPATH "\$ORIGIN/../../${CMAKE_INSTALL_LIBDIR}"
0108 )
0109 set_target_properties(
0110 ActsExamplesPythonBindings
0111 PROPERTIES LIBRARY_OUTPUT_DIRECTORY ${_python_dir}/acts/examples
0112 )
0113
0114 target_link_libraries(
0115 ActsExamplesPythonBindings
0116 PUBLIC
0117 Acts::Core
0118 Acts::ExamplesFramework
0119 Acts::ExamplesFatras
0120 Acts::ExamplesAmbiguityResolution
0121 Acts::ExamplesDetectorsCommon
0122 Acts::ExamplesDetectorGeneric
0123 Acts::ExamplesDetectorTelescope
0124 Acts::ExamplesDigitization
0125 Acts::ExamplesGenerators
0126 Acts::ExamplesMaterialMapping
0127 Acts::ExamplesUtilities
0128 Acts::ExamplesIoCsv
0129 Acts::ExamplesIoObj
0130 Acts::ExamplesPropagation
0131 Acts::ExamplesTrackFinding
0132 Acts::ExamplesTrackFitting
0133 Acts::ExamplesTruthTracking
0134 Acts::ExamplesVertexing
0135 Acts::ExamplesPrinters
0136 Acts::PythonUtilities
0137 )
0138
0139 # Add all plugin related examples bindings conditionally to their build flag
0140 add_examples_binding_if(Alignment "Acts::ExamplesAlignment;Acts::ExamplesDetectorsCommon" ACTS_BUILD_ALIGNMENT FALSE)
0141 add_examples_binding_if(DD4hep Acts::ExamplesDetectorDD4hep ACTS_BUILD_EXAMPLES_DD4HEP TRUE)
0142 add_examples_binding_if(EDM4hep Acts::ExamplesIoEDM4hep ACTS_BUILD_EXAMPLES_EDM4HEP FALSE)
0143 add_examples_binding_if(Geant4
0144 "Acts::ExamplesGeant4;Acts::ExamplesDetectorGeant4"
0145 ACTS_BUILD_EXAMPLES_GEANT4
0146 TRUE
0147 )
0148 add_examples_binding_if(GeoModel
0149 "Acts::PluginGeoModel;Acts::ExamplesITkModuleSplitting;Acts::ExamplesDetectorGeoModel;Acts::ExamplesMuonSpectrometerMockupDetector"
0150 ACTS_BUILD_PLUGIN_GEOMODEL TRUE
0151 )
0152 add_examples_binding_if(Gnn Acts::ExamplesTrackFindingGnn ACTS_BUILD_EXAMPLES_GNN FALSE)
0153 add_examples_binding_if(Hashing "Acts::PluginHashing;Acts::ExamplesTrackFinding" ACTS_BUILD_EXAMPLES_HASHING TRUE)
0154 add_examples_binding_if(Json Acts::ExamplesIoJson ACTS_BUILD_PLUGIN_JSON TRUE)
0155 add_examples_binding_if(Onnx "Acts::ExamplesFrameworkML;Acts::ExamplesTrackFindingML" ACTS_BUILD_PLUGIN_ONNX FALSE)
0156 add_examples_binding_if(Pythia8 Acts::ExamplesGeneratorsPythia8 ACTS_BUILD_EXAMPLES_PYTHIA8 FALSE)
0157 add_examples_binding_if(Root Acts::ExamplesIoRoot ACTS_BUILD_PLUGIN_ROOT TRUE)
0158 add_examples_binding_if(Svg Acts::ExamplesIoSvg ACTS_BUILD_PLUGIN_ACTSVG TRUE)
0159 add_examples_binding_if(TGeo Acts::ExamplesDetectorTGeo ACTS_BUILD_PLUGIN_ROOT TRUE)
0160 add_examples_binding_if(Traccc "Acts::PluginCovfie;Acts::ExamplesTraccc" ACTS_BUILD_PLUGIN_TRACCC FALSE)
0161 add_examples_binding_if(TruthJet Acts::ExamplesJets ACTS_BUILD_PLUGIN_FASTJET FALSE)
0162
0163 # Special case for HepMC3 as it a hard dependency
0164 pybind11_add_module(ActsExamplesPythonBindingsHepMC3 src/plugins/HepMC3.cpp)
0165 install(
0166 TARGETS ActsExamplesPythonBindingsHepMC3 DESTINATION ${_python_install_dir}
0167 )
0168 set_target_properties(
0169 ActsExamplesPythonBindingsHepMC3
0170 PROPERTIES INSTALL_RPATH "\$ORIGIN/../../${CMAKE_INSTALL_LIBDIR}"
0171 )
0172 set_target_properties(
0173 ActsExamplesPythonBindingsHepMC3
0174 PROPERTIES LIBRARY_OUTPUT_DIRECTORY ${_python_dir}/acts/examples
0175 )
0176 target_link_libraries(
0177 ActsExamplesPythonBindingsHepMC3
0178 PUBLIC Acts::Core Acts::PythonUtilities Acts::ExamplesIoHepMC3
0179 )
0180 add_dependencies(ActsPythonBindings ActsExamplesPythonBindingsHepMC3)
0181 list(APPEND py_files hepmc3/__init__.py)
0182 list(APPEND py_files hepmc3/__main__.py)
0183
0184 # Symlink hepmc3_normalize.py to build/bin for development
0185 add_custom_target(
0186 hepmc_normalize_symlink
0187 ALL
0188 COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_BINARY_DIR}/bin
0189 COMMAND
0190 ${CMAKE_COMMAND} -E create_symlink
0191 ${CMAKE_CURRENT_SOURCE_DIR}/python/hepmc_normalize.py
0192 ${CMAKE_BINARY_DIR}/bin/hepmc_normalize.py
0193 COMMENT "Creating symlink for hepmc_normalize.py"
0194 VERBATIM
0195 )
0196 add_dependencies(hepmc_normalize_symlink ActsExamplesIoHepMC3)
0197 install(
0198 PROGRAMS ${CMAKE_CURRENT_SOURCE_DIR}/python/hepmc_normalize.py
0199 DESTINATION ${CMAKE_INSTALL_BINDIR}
0200 RENAME hepmc_normalize.py
0201 )
0202
0203 # Install the additional python files
0204 foreach(f ${py_files})
0205 set(_target ${_python_dir}/acts/examples/${f})
0206 get_filename_component(_dir ${_target} DIRECTORY)
0207 file(MAKE_DIRECTORY ${_dir})
0208
0209 file(
0210 CREATE_LINK ${CMAKE_CURRENT_SOURCE_DIR}/python/${f} ${_target}
0211 SYMBOLIC
0212 )
0213
0214 get_filename_component(_rel ${f} DIRECTORY)
0215 message(
0216 STATUS
0217 "Installing example python file: ${f} to ${_python_install_dir}/${_rel}"
0218 )
0219
0220 install(
0221 FILES ${CMAKE_CURRENT_SOURCE_DIR}/python/${f}
0222 DESTINATION ${_python_install_dir}/${_rel}
0223 )
0224 endforeach()
0225
0226 # Finally copy the python files