Warning, /acts/Tests/UnitTests/Plugins/DD4hep/CMakeLists.txt is written in an unsupported language. File is not indexed.
0001 add_library(
0002 ActsTestsDD4hepFactories
0003 SHARED
0004 DD4hepTestsHelper.cpp
0005 LayerFactory.cpp
0006 PrimitivesFactory.cpp
0007 )
0008
0009 add_library(Acts::TestsDD4hepFactories ALIAS ActsTestsDD4hepFactories)
0010
0011 target_include_directories(
0012 ActsTestsDD4hepFactories
0013 PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>
0014 )
0015 target_link_libraries(
0016 ActsTestsDD4hepFactories
0017 PUBLIC Acts::PluginDD4hep DD4hep::DDCore
0018 )
0019
0020 # Not sure why this needs to be set, but dd4hep fails to compile otherwise
0021 set(LIBRARY_OUTPUT_PATH ${CMAKE_CURRENT_BINARY_DIR})
0022 set_target_properties(
0023 ActsTestsDD4hepFactories
0024 PROPERTIES LIBRARY_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
0025 )
0026 dd4hep_set_version(ActsTestsDD4hepFactories MAJOR 1 MINOR 0 PATCH 0)
0027 dd4hep_generate_rootmap(ActsTestsDD4hepFactories)
0028
0029 find_library(dd4hep_core_library DDCore)
0030
0031 if(${CMAKE_VERSION} VERSION_GREATER_EQUAL "3.24.0")
0032 set(factory_path
0033 "$<PATH:GET_PARENT_PATH,$<TARGET_FILE:Acts::TestsDD4hepFactories>>"
0034 )
0035 else()
0036 set(factory_path "${CMAKE_CURRENT_BINARY_DIR}")
0037 endif()
0038
0039 if(NOT "${dd4hep_core_library}" STREQUAL "dd4hep_core_library-NOTFOUND")
0040 cmake_path(GET dd4hep_core_library PARENT_PATH DD4HEP_LIBRARY_PATH)
0041
0042 # Resolve DD4hepINSTALL: prefer the env var (LCG / sourced spack expose the
0043 # canonical location there), fall back to deriving it from the dd4hep
0044 # library path. Either way, the resolved root must contain detector_types.xml.
0045 if(NOT "$ENV{DD4hepINSTALL}" STREQUAL "")
0046 set(DD4HEP_INSTALL "$ENV{DD4hepINSTALL}")
0047 else()
0048 cmake_path(GET DD4HEP_LIBRARY_PATH PARENT_PATH DD4HEP_INSTALL)
0049 endif()
0050
0051 if(NOT EXISTS "${DD4HEP_INSTALL}/DDDetectors/compact/detector_types.xml")
0052 message(
0053 FATAL_ERROR
0054 "DD4hep XML unit tests require detector_types.xml at "
0055 "\${DD4hepINSTALL}/DDDetectors/compact/detector_types.xml, but the "
0056 "file is not present under DD4hepINSTALL='${DD4HEP_INSTALL}'. "
0057 "Set DD4hepINSTALL in the environment to the dd4hep prefix "
0058 "before invoking cmake."
0059 )
0060 endif()
0061
0062 # set test library dependencies
0063 set(unittest_extra_libraries Acts::TestsDD4hepFactories Acts::PluginDD4hep)
0064 set(dd4hep_tests
0065 DD4hepDetectorElement
0066 DD4hepDetectorSurfaceFactory
0067 DD4hepCylindricalDetectorGen3
0068 )
0069 foreach(_test ${dd4hep_tests})
0070 add_unittest(${_test} ${_test}Tests.cpp)
0071 add_dependencies(
0072 ActsUnitTest${_test}
0073 Components_ActsTestsDD4hepFactories
0074 )
0075 if(APPLE)
0076 set_property(
0077 TEST ${_test}
0078 PROPERTY
0079 ENVIRONMENT
0080 "DYLD_LIBRARY_PATH=${DD4HEP_LIBRARY_PATH}:${factory_path}:${ROOT_LIBRARY_DIR}:$ENV{DYLD_LIBRARY_PATH};DD4hepINSTALL=${DD4HEP_INSTALL}"
0081 )
0082 else()
0083 set_property(
0084 TEST ${_test}
0085 PROPERTY
0086 ENVIRONMENT
0087 "LD_LIBRARY_PATH=${DD4HEP_LIBRARY_PATH}:${factory_path}:${ROOT_LIBRARY_DIR}:$ENV{LD_LIBRARY_PATH};DD4hepINSTALL=${DD4HEP_INSTALL}"
0088 )
0089 endif()
0090 endforeach()
0091 else()
0092 message(
0093 WARNING
0094 "DD4hep libraries not found, DD4hep tests will not be built."
0095 )
0096 endif()
0097
0098 set(unittest_extra_libraries Acts::PluginDD4hep)
0099 add_unittest(DD4hepMaterialHelpers DD4hepMaterialHelpersTests.cpp)