Back to home page

sPhenix code displayed by LXR

 
 

    


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(_examples_python_install_dir "${ACTS_PYTHON_INSTALL_DIR}/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 ${_examples_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 ${_examples_python_install_dir}
0075     )
0076 endmacro()
0077 
0078 # Add the examples python binding
0079 pybind11_add_module(ActsExamplesPythonBindings src/ExamplesModuleEntry.cpp)
0080 
0081 add_dependencies(ActsPythonBindings ActsExamplesPythonBindings)
0082 
0083 # The PythonBindings for the examples
0084 target_sources(
0085     ActsExamplesPythonBindings
0086     PRIVATE
0087         src/Framework.cpp
0088         src/ExampleAlgorithms.cpp
0089         src/Generators.cpp
0090         src/AmbiguityResolution.cpp
0091         src/Detector.cpp
0092         src/Digitization.cpp
0093         src/MaterialMapping.cpp
0094         src/Propagation.cpp
0095         src/TrackFinding.cpp
0096         src/TrackFitting.cpp
0097         src/TruthTracking.cpp
0098         src/Vertexing.cpp
0099         src/Input.cpp
0100         src/Output.cpp
0101         src/Obj.cpp
0102         src/Utilities.cpp
0103 )
0104 
0105 install(
0106     TARGETS
0107         ActsExamplesPythonBindings
0108         DESTINATION
0109         ${_examples_python_install_dir}
0110 )
0111 
0112 set_target_properties(
0113     ActsExamplesPythonBindings
0114     PROPERTIES INSTALL_RPATH "\$ORIGIN/../../${CMAKE_INSTALL_LIBDIR}"
0115 )
0116 set_target_properties(
0117     ActsExamplesPythonBindings
0118     PROPERTIES LIBRARY_OUTPUT_DIRECTORY ${_python_dir}/acts/examples
0119 )
0120 
0121 target_link_libraries(
0122     ActsExamplesPythonBindings
0123     PUBLIC
0124         Acts::Core
0125         Acts::ExamplesFramework
0126         Acts::ExamplesFatras
0127         Acts::ExamplesAmbiguityResolution
0128         Acts::ExamplesDetectorsCommon
0129         Acts::ExamplesDetectorGeneric
0130         Acts::ExamplesDetectorTelescope
0131         Acts::ExamplesDigitization
0132         Acts::ExamplesGenerators
0133         Acts::ExamplesMaterialMapping
0134         Acts::ExamplesUtilities
0135         Acts::ExamplesIoCsv
0136         Acts::ExamplesIoObj
0137         Acts::ExamplesPropagation
0138         Acts::ExamplesTrackFinding
0139         Acts::ExamplesTrackFitting
0140         Acts::ExamplesTruthTracking
0141         Acts::ExamplesVertexing
0142         Acts::ExamplesPrinters
0143         Acts::PythonUtilities
0144 )
0145 
0146 # Add all plugin related examples bindings conditionally to their build flag
0147 add_examples_binding_if(Alignment "Acts::ExamplesAlignment;Acts::ExamplesDetectorsCommon" ACTS_BUILD_ALIGNMENT FALSE)
0148 add_examples_binding_if(DD4hep Acts::ExamplesDetectorDD4hep ACTS_BUILD_EXAMPLES_DD4HEP TRUE)
0149 add_examples_binding_if(EDM4hep Acts::ExamplesIoEDM4hep ACTS_BUILD_EXAMPLES_EDM4HEP FALSE)
0150 add_examples_binding_if(Geant4
0151     "Acts::ExamplesGeant4;Acts::ExamplesDetectorGeant4"
0152     ACTS_BUILD_EXAMPLES_GEANT4
0153     TRUE
0154 )
0155 add_examples_binding_if(GeoModel
0156     "Acts::PluginGeoModel;Acts::ExamplesITkModuleSplitting;Acts::ExamplesDetectorGeoModel;Acts::ExamplesMuonSpectrometerMockupDetector"
0157     ACTS_BUILD_PLUGIN_GEOMODEL TRUE
0158 )
0159 add_examples_binding_if(Gnn Acts::ExamplesTrackFindingGnn ACTS_BUILD_EXAMPLES_GNN FALSE)
0160 add_examples_binding_if(Hashing "Acts::PluginHashing;Acts::ExamplesTrackFinding" ACTS_BUILD_EXAMPLES_HASHING TRUE)
0161 add_examples_binding_if(Json Acts::ExamplesIoJson ACTS_BUILD_PLUGIN_JSON TRUE)
0162 add_examples_binding_if(Onnx "Acts::ExamplesFrameworkML;Acts::ExamplesTrackFindingML" ACTS_BUILD_PLUGIN_ONNX FALSE)
0163 add_examples_binding_if(Pythia8 Acts::ExamplesGeneratorsPythia8 ACTS_BUILD_EXAMPLES_PYTHIA8 FALSE)
0164 add_examples_binding_if(Root Acts::ExamplesIoRoot ACTS_BUILD_PLUGIN_ROOT TRUE)
0165 add_examples_binding_if(Svg Acts::ExamplesIoSvg ACTS_BUILD_PLUGIN_ACTSVG TRUE)
0166 add_examples_binding_if(TGeo Acts::ExamplesDetectorTGeo ACTS_BUILD_PLUGIN_ROOT TRUE)
0167 add_examples_binding_if(Traccc "Acts::PluginCovfie;Acts::ExamplesTraccc" ACTS_BUILD_PLUGIN_TRACCC FALSE)
0168 add_examples_binding_if(TruthJet Acts::ExamplesJets ACTS_BUILD_PLUGIN_FASTJET FALSE)
0169 
0170 # Special case for HepMC3 as it a hard dependency
0171 pybind11_add_module(ActsExamplesPythonBindingsHepMC3 src/plugins/HepMC3.cpp)
0172 install(
0173     TARGETS
0174         ActsExamplesPythonBindingsHepMC3
0175         DESTINATION
0176         ${_examples_python_install_dir}
0177 )
0178 set_target_properties(
0179     ActsExamplesPythonBindingsHepMC3
0180     PROPERTIES INSTALL_RPATH "\$ORIGIN/../../${CMAKE_INSTALL_LIBDIR}"
0181 )
0182 set_target_properties(
0183     ActsExamplesPythonBindingsHepMC3
0184     PROPERTIES LIBRARY_OUTPUT_DIRECTORY ${_python_dir}/acts/examples
0185 )
0186 target_link_libraries(
0187     ActsExamplesPythonBindingsHepMC3
0188     PUBLIC Acts::Core Acts::PythonUtilities Acts::ExamplesIoHepMC3
0189 )
0190 add_dependencies(ActsPythonBindings ActsExamplesPythonBindingsHepMC3)
0191 list(APPEND py_files hepmc3/__init__.py)
0192 list(APPEND py_files hepmc3/__main__.py)
0193 
0194 # Symlink hepmc3_normalize.py to build/bin for development
0195 add_custom_target(
0196     hepmc_normalize_symlink
0197     ALL
0198     COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_BINARY_DIR}/bin
0199     COMMAND
0200         ${CMAKE_COMMAND} -E create_symlink
0201         ${CMAKE_CURRENT_SOURCE_DIR}/python/hepmc_normalize.py
0202         ${CMAKE_BINARY_DIR}/bin/hepmc_normalize.py
0203     COMMENT "Creating symlink for hepmc_normalize.py"
0204     VERBATIM
0205 )
0206 add_dependencies(hepmc_normalize_symlink ActsExamplesIoHepMC3)
0207 install(
0208     PROGRAMS ${CMAKE_CURRENT_SOURCE_DIR}/python/hepmc_normalize.py
0209     DESTINATION ${CMAKE_INSTALL_BINDIR}
0210     RENAME hepmc_normalize.py
0211 )
0212 
0213 # Install the additional python files
0214 foreach(f ${py_files})
0215     set(_target ${_python_dir}/acts/examples/${f})
0216     get_filename_component(_dir ${_target} DIRECTORY)
0217     file(MAKE_DIRECTORY ${_dir})
0218 
0219     file(
0220         CREATE_LINK ${CMAKE_CURRENT_SOURCE_DIR}/python/${f} ${_target}
0221         SYMBOLIC
0222     )
0223 
0224     get_filename_component(_rel ${f} DIRECTORY)
0225     message(
0226         STATUS
0227         "Installing example python file: ${f} to ${_examples_python_install_dir}/${_rel}"
0228     )
0229 
0230     install(
0231         FILES ${CMAKE_CURRENT_SOURCE_DIR}/python/${f}
0232         DESTINATION ${_examples_python_install_dir}/${_rel}
0233     )
0234 endforeach()
0235 
0236 # Finally copy the python files