From 886d57faf9a6736cf8a4829599cdb1210efb094e Mon Sep 17 00:00:00 2001 From: tmadlener Date: Tue, 3 Sep 2024 11:30:38 +0200 Subject: [PATCH] Configure the cmake config for downstream consumption - Make sure all required dependencies are also detected in downstream users - Add some legacy variables --- CMakeLists.txt | 6 ++---- cmake/k4FWCoreConfig.cmake | 11 ----------- cmake/k4FWCoreConfig.cmake.in | 34 ++++++++++++++++++++++++++++++++ cmake/k4FWCoreCreateConfig.cmake | 6 ++++++ 4 files changed, 42 insertions(+), 15 deletions(-) delete mode 100644 cmake/k4FWCoreConfig.cmake create mode 100644 cmake/k4FWCoreConfig.cmake.in create mode 100644 cmake/k4FWCoreCreateConfig.cmake diff --git a/CMakeLists.txt b/CMakeLists.txt index 08401d48..866abe63 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -95,14 +95,12 @@ if(ENABLE_CPACK) include(cmake/${PROJECT_NAME}CPack.cmake) endif() - - - install(EXPORT ${PROJECT_NAME}Targets NAMESPACE ${PROJECT_NAME}:: FILE "${PROJECT_NAME}Targets.cmake" DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}/" ) -gaudi_install(CMAKE cmake/${PROJECT_NAME}Config.cmake) +include(cmake/k4FWCoreCreateConfig.cmake) +gaudi_install(CMAKE ${PROJECT_BINARY_DIR}/k4FWCoreConfig.cmake) diff --git a/cmake/k4FWCoreConfig.cmake b/cmake/k4FWCoreConfig.cmake deleted file mode 100644 index 50a30cc7..00000000 --- a/cmake/k4FWCoreConfig.cmake +++ /dev/null @@ -1,11 +0,0 @@ - -include(CMakeFindDependencyMacro) -find_dependency(podio REQUIRED) -find_dependency(Gaudi REQUIRED) - -# - Include the targets file to create the imported targets that a client can -# link to (libraries) or execute (programs) -include("${CMAKE_CURRENT_LIST_DIR}/k4FWCoreTargets.cmake") - -get_property(TEST_K4FWCORE_LIBRARY TARGET k4FWCore::k4FWCore PROPERTY LOCATION) -find_package_handle_standard_args(k4FWCore DEFAULT_MSG CMAKE_CURRENT_LIST_FILE TEST_K4FWCORE_LIBRARY) diff --git a/cmake/k4FWCoreConfig.cmake.in b/cmake/k4FWCoreConfig.cmake.in new file mode 100644 index 00000000..3478680f --- /dev/null +++ b/cmake/k4FWCoreConfig.cmake.in @@ -0,0 +1,34 @@ +############################################################################### +# k4FWCore CMake Config +# +# Exported Targets +# - k4FWCore::k4FWCore The core library containing the PodioDataSvc +# and the KeepDropSwitch +# - k4FWCore::k4FWCorePlugins The plugin library for the core plugins +# provided by k4FWCore. Includes all major +# services for I/O and as well as some utility +# algorithms +# - k4FWCore::k4Interface The (header-only) target containing all +# interface definitions +# +############################################################################### +@PACKAGE_INIT@ + +set_and_check(k4FWCore_INCLUDE_DIR "@PACKAGE_CMAKE_INSTALL_INCLUDEDIR@") +set_and_check(k4FWCore_LIBRARY_DIR "@PACKAGE_CMAKE_INSTALL_LIBDIR@") + +include(CMakeFindDependencyMacro) +find_dependency(podio @podio_VERSION@) +find_dependency(Gaudi @Gaudi_VERSION@) +find_dependency(EDM4HEP @EDM4HEP_VERSION@) +find_dependency(ROOT @ROOT_VERSION@ COMPONENTS RIO Tree) + +if(NOT TARGET k4FWCore::k4FWCore) + include("${CMAKE_CURRENT_LIST_DIR}/k4FWCoreTargets.cmake") +endif() + +check_required_components(k4FWCore) + +include(FindPackageHandleStandardArgs) +get_property(TEST_K4FWCORE_LIBRARY TARGET k4FWCore::k4FWCore PROPERTY LOCATION) +find_package_handle_standard_args(k4FWCore DEFAULT_MSG CMAKE_CURRENT_LIST_FILE TEST_K4FWCORE_LIBRARY) diff --git a/cmake/k4FWCoreCreateConfig.cmake b/cmake/k4FWCoreCreateConfig.cmake new file mode 100644 index 00000000..a80ae942 --- /dev/null +++ b/cmake/k4FWCoreCreateConfig.cmake @@ -0,0 +1,6 @@ +include(CMakePackageConfigHelpers) + +configure_package_config_file(${PROJECT_SOURCE_DIR}/cmake/k4FWCoreConfig.cmake.in + ${PROJECT_BINARY_DIR}/k4FWCoreConfig.cmake + INSTALL_DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/k4FWCore + PATH_VARS CMAKE_INSTALL_INCLUDEDIR CMAKE_INSTALL_LIBDIR)