From afa3cca4ddf92a1409e56319f61bf2bf990c61d0 Mon Sep 17 00:00:00 2001 From: Frederik Date: Thu, 18 Jul 2024 10:46:38 +0200 Subject: [PATCH] Added guards in actsconfig to prevent traccc circular dependency --- cmake/ActsConfig.cmake.in | 196 +++++++++++++++++++------------------- 1 file changed, 100 insertions(+), 96 deletions(-) diff --git a/cmake/ActsConfig.cmake.in b/cmake/ActsConfig.cmake.in index dee5d9f87b4f..6ca2e108889c 100644 --- a/cmake/ActsConfig.cmake.in +++ b/cmake/ActsConfig.cmake.in @@ -11,115 +11,119 @@ # - Acts_COMMIT_HASH # - Acts_COMMIT_HASH_SHORT -@PACKAGE_INIT@ +if (NOT TARGET Acts) + @PACKAGE_INIT@ -set(Acts_COMPONENTS @_components@) -set(Acts_COMMIT_HASH "@_acts_commit_hash@") -set(Acts_COMMIT_HASH_SHORT "@_acts_commit_hash_short@") + set(Acts_COMPONENTS @_components@) + set(Acts_COMMIT_HASH "@_acts_commit_hash@") + set(Acts_COMMIT_HASH_SHORT "@_acts_commit_hash_short@") -# print version and components information -if(NOT Acts_FIND_QUIETLY) - message(STATUS "found Acts version ${Acts_VERSION} commit ${Acts_COMMIT_HASH_SHORT}") -endif() + # print version and components information + if(NOT Acts_FIND_QUIETLY) + message(STATUS "found Acts version ${Acts_VERSION} commit ${Acts_COMMIT_HASH_SHORT}") + endif() -# check that requested components are available -foreach(_component ${Acts_FIND_COMPONENTS}) - # check if this component is available - if(NOT _component IN_LIST Acts_COMPONENTS) - if (${Acts_FIND_REQUIRED_${_component}}) - # not supported, but required -> fail - set(Acts_FOUND False) - set(Acts_NOT_FOUND_MESSAGE "required component '${_component}' not found") - else() - # not supported and optional -> skip - list(REMOVE_ITEM Acts_FIND_COMPONENTS ${_component}) - if(NOT Acts_FIND_QUIETLY) - message(STATUS "optional component '${_component}' not found") + # check that requested components are available + foreach(_component ${Acts_FIND_COMPONENTS}) + # check if this component is available + if(NOT _component IN_LIST Acts_COMPONENTS) + if (${Acts_FIND_REQUIRED_${_component}}) + # not supported, but required -> fail + set(Acts_FOUND False) + set(Acts_NOT_FOUND_MESSAGE "required component '${_component}' not found") + else() + # not supported and optional -> skip + list(REMOVE_ITEM Acts_FIND_COMPONENTS ${_component}) + if(NOT Acts_FIND_QUIETLY) + message(STATUS "optional component '${_component}' not found") + endif() endif() endif() - endif() -endforeach() + endforeach() -# add this to the current CMAKE_MODULE_PATH to find third party modules -# that not provide a XXXConfig.cmake or XXX-config.cmake file -list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_LIST_DIR}/Modules) + # add this to the current CMAKE_MODULE_PATH to find third party modules + # that not provide a XXXConfig.cmake or XXX-config.cmake file + list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_LIST_DIR}/Modules) -# find external dependencies that are needed to link with Acts. since the -# exported Acts targets only store the linked external target names they need -# to be found again. this avoids hard-coded paths and makes the installed -# config/library relocatable. use exact version match where possible to ensure -# the same versions are found that were used at build time. -# `find_dependency` is a wrapper around `find_package` that automatically -# handles QUIET and REQUIRED parameters. -include(CMakeFindDependencyMacro) -if(@ACTS_USE_SYSTEM_BOOST@) - find_dependency(Boost @Boost_VERSION_STRING@ CONFIG EXACT) -endif() -if(@ACTS_USE_SYSTEM_EIGEN3@) - find_dependency(Eigen3 @Eigen3_VERSION@ CONFIG EXACT) -endif() -if(PluginDD4hep IN_LIST Acts_COMPONENTS) - find_dependency(DD4hep @DD4hep_VERSION@ CONFIG EXACT) -endif() -if(PluginJson IN_LIST Acts_COMPONENTS) - find_dependency(nlohmann_json @nlohmann_json_VERSION@ CONFIG EXACT) -endif() -if(PluginTGeo IN_LIST Acts_COMPONENTS) - find_dependency(ROOT @ROOT_VERSION@ CONFIG EXACT) -endif() -if(PluginActSVG IN_LIST Acts_COMPONENTS) - find_dependency(actsvg @actsvg_VERSION@ CONFIG EXACT) -endif() -if(PluginEDM4hep IN_LIST Acts_COMPONENTS) - find_dependency(EDM4HEP @EDM4HEP_VERSION@ CONFIG EXACT) -endif() -if(PluginPodio IN_LIST Acts_COMPONENTS) - find_dependency(podio @podio_VERSION@ CONFIG EXACT) -endif() -if(PluginGeoModel IN_LIST Acts_COMPONENTS) - find_dependency(GeoModelCore @GeoModel_VERSION@ CONFIG EXACT) - find_dependency(GeoModelIO @GeoModel_VERSION@ CONFIG EXACT) -endif() + # find external dependencies that are needed to link with Acts. since the + # exported Acts targets only store the linked external target names they need + # to be found again. this avoids hard-coded paths and makes the installed + # config/library relocatable. use exact version match where possible to ensure + # the same versions are found that were used at build time. + # `find_dependency` is a wrapper around `find_package` that automatically + # handles QUIET and REQUIRED parameters. + include(CMakeFindDependencyMacro) + if(@ACTS_USE_SYSTEM_BOOST@) + find_dependency(Boost @Boost_VERSION_STRING@ CONFIG EXACT) + endif() + if(@ACTS_USE_SYSTEM_EIGEN3@) + find_dependency(Eigen3 @Eigen3_VERSION@ CONFIG EXACT) + endif() + if(PluginDD4hep IN_LIST Acts_COMPONENTS) + find_dependency(DD4hep @DD4hep_VERSION@ CONFIG EXACT) + endif() + if(PluginJson IN_LIST Acts_COMPONENTS) + find_dependency(nlohmann_json @nlohmann_json_VERSION@ CONFIG EXACT) + endif() + if(PluginTGeo IN_LIST Acts_COMPONENTS) + find_dependency(ROOT @ROOT_VERSION@ CONFIG EXACT) + endif() + if(PluginActSVG IN_LIST Acts_COMPONENTS) + find_dependency(actsvg @actsvg_VERSION@ CONFIG EXACT) + endif() + if(PluginEDM4hep IN_LIST Acts_COMPONENTS) + find_dependency(EDM4HEP @EDM4HEP_VERSION@ CONFIG EXACT) + endif() + if(PluginPodio IN_LIST Acts_COMPONENTS) + find_dependency(podio @podio_VERSION@ CONFIG EXACT) + endif() + if(PluginGeoModel IN_LIST Acts_COMPONENTS) + find_dependency(GeoModelCore @GeoModel_VERSION@ CONFIG EXACT) + find_dependency(GeoModelIO @GeoModel_VERSION@ CONFIG EXACT) + endif() -if (PluginCovfie IN_LIST Acts_COMPONENTS) - find_dependency(covfie @covfie_VERSION@ CONFIG EXACT) -endif() + if (PluginCovfie IN_LIST Acts_COMPONENTS) + find_dependency(covfie @covfie_VERSION@ CONFIG EXACT) + endif() -if(PluginDetray IN_LIST Acts_COMPONENTS OR PluginTraccc IN_LIST Acts_COMPONENTS) - find_dependency(vecmem @vecmem_VERSION@ CONFIG EXACT) - find_dependency(algebra-plugins @algebra-plugins_VERSION@ CONFIG EXACT) - find_dependency(detray @detray_VERSION@ CONFIG EXACT) -endif() + if(PluginDetray IN_LIST Acts_COMPONENTS OR PluginTraccc IN_LIST Acts_COMPONENTS) + find_dependency(vecmem @vecmem_VERSION@ CONFIG EXACT) + find_dependency(algebra-plugins @algebra-plugins_VERSION@ CONFIG EXACT) + find_dependency(detray @detray_VERSION@ CONFIG EXACT) + endif() -if(PluginTraccc IN_LIST Acts_COMPONENTS) - find_dependency(traccc @traccc_VERSION@ CONFIG EXACT) -endif() + if(PluginTraccc IN_LIST Acts_COMPONENTS) + if (NOT TARGET traccc) + find_dependency(traccc @traccc_VERSION@ CONFIG EXACT) + endif() + endif() -# dependencies that we have built ourselves but cannot be -# straightforwardly handed to cmake -if(NOT @ACTS_USE_SYSTEM_BOOST@) - add_library(Boost::boost INTERFACE IMPORTED GLOBAL) - target_include_directories(Boost::boost INTERFACE "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_INCLUDEDIR}") -endif() -if(NOT @ACTS_USE_SYSTEM_EIGEN3@) - add_library(Eigen3::Eigen INTERFACE IMPORTED GLOBAL) - target_include_directories(Eigen3::Eigen INTERFACE "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_INCLUDEDIR}") -endif() + # dependencies that we have built ourselves but cannot be + # straightforwardly handed to cmake + if(NOT @ACTS_USE_SYSTEM_BOOST@) + add_library(Boost::boost INTERFACE IMPORTED GLOBAL) + target_include_directories(Boost::boost INTERFACE "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_INCLUDEDIR}") + endif() + if(NOT @ACTS_USE_SYSTEM_EIGEN3@) + add_library(Eigen3::Eigen INTERFACE IMPORTED GLOBAL) + target_include_directories(Eigen3::Eigen INTERFACE "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_INCLUDEDIR}") + endif() -if(PluginPodio IN_LIST Acts_COMPONENTS) - include(${CMAKE_CURRENT_LIST_DIR}/ActsPodioEdmTargets.cmake) -endif() + if(PluginPodio IN_LIST Acts_COMPONENTS) + include(${CMAKE_CURRENT_LIST_DIR}/ActsPodioEdmTargets.cmake) + endif() -# load **all** available components. we can not just include the requested -# components since there can be interdependencies between them. -if(NOT Acts_FIND_QUIETLY) - message(STATUS "loading components:") -endif() -foreach(_component ${Acts_COMPONENTS}) + # load **all** available components. we can not just include the requested + # components since there can be interdependencies between them. if(NOT Acts_FIND_QUIETLY) - message(STATUS " ${_component}") + message(STATUS "loading components:") endif() - # include the targets file to create the imported targets for the user - include(${CMAKE_CURRENT_LIST_DIR}/Acts${_component}Targets.cmake) -endforeach() + foreach(_component ${Acts_COMPONENTS}) + if(NOT Acts_FIND_QUIETLY) + message(STATUS " ${_component}") + endif() + # include the targets file to create the imported targets for the user + include(${CMAKE_CURRENT_LIST_DIR}/Acts${_component}Targets.cmake) + endforeach() +endif() \ No newline at end of file