From f121e8eec711402953747e86721a22d6ae5ae2e2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Markus=20M=C3=BCtzel?= Date: Wed, 30 Aug 2023 13:38:43 +0200 Subject: [PATCH] CHOLMOD: Don't look for CHOLMOD_CUDA in common source tree when installed Create two slightly different CHOLMODConfig.cmake files. One that is used in a common build tree before CHOLMOD was installed. And a slightly different one that is installed. The second one doesn't attempt to look for CHOLMOD_CUDA in the build folder of a common source tree. --- CHOLMOD/CMakeLists.txt | 11 ++++++++++- CHOLMOD/Config/CHOLMODConfig.cmake.in | 14 +++++++++----- 2 files changed, 19 insertions(+), 6 deletions(-) diff --git a/CHOLMOD/CMakeLists.txt b/CHOLMOD/CMakeLists.txt index 45d623fa0..789c33892 100644 --- a/CHOLMOD/CMakeLists.txt +++ b/CHOLMOD/CMakeLists.txt @@ -510,9 +510,18 @@ install ( EXPORT CHOLMODTargets NAMESPACE SuiteSparse:: DESTINATION ${SUITESPARSE_LIBDIR}/cmake/CHOLMOD ) +# generate config file to be used in common build tree +set ( SUITESPARSE_IN_BUILD_TREE on ) configure_package_config_file ( Config/CHOLMODConfig.cmake.in ${CMAKE_CURRENT_BINARY_DIR}/CHOLMODConfig.cmake + INSTALL_DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/CHOLMODConfig.cmake ) + +# generate config file to be installed +set ( SUITESPARSE_IN_BUILD_TREE off ) +configure_package_config_file ( + Config/CHOLMODConfig.cmake.in + ${CMAKE_CURRENT_BINARY_DIR}/target/CHOLMODConfig.cmake INSTALL_DESTINATION ${SUITESPARSE_LIBDIR}/cmake/CHOLMOD ) write_basic_package_version_file ( @@ -520,7 +529,7 @@ write_basic_package_version_file ( COMPATIBILITY SameMajorVersion ) install ( FILES - ${CMAKE_CURRENT_BINARY_DIR}/CHOLMODConfig.cmake + ${CMAKE_CURRENT_BINARY_DIR}/target/CHOLMODConfig.cmake ${CMAKE_CURRENT_BINARY_DIR}/CHOLMODConfigVersion.cmake DESTINATION ${SUITESPARSE_LIBDIR}/cmake/CHOLMOD ) diff --git a/CHOLMOD/Config/CHOLMODConfig.cmake.in b/CHOLMOD/Config/CHOLMODConfig.cmake.in index 7fb7a84a5..ac747fddb 100644 --- a/CHOLMOD/Config/CHOLMODConfig.cmake.in +++ b/CHOLMOD/Config/CHOLMODConfig.cmake.in @@ -37,11 +37,15 @@ set ( CHOLMOD_VERSION "@CHOLMOD_VERSION_MAJOR@.@CHOLMOD_VERSION_MINOR@.@CHOLMOD_ if ( @SUITESPARSE_CUDA@ ) # Look for imported targets of additional dependency if CHOLMOD was built with CUDA - # First check in a common build tree - find_package ( CHOLMOD_CUDA @CHOLMOD_VERSION_MAJOR@.@CHOLMOD_VERSION_MINOR@.@CHOLMOD_VERSION_SUB@ - PATHS ${CMAKE_SOURCE_DIR}/../CHOLMOD/build NO_DEFAULT_PATH ) - # Then, check in the currently active CMAKE_MODULE_PATH - if ( NOT TARGET SuiteSparse::CHOLMOD_CUDA ) + if ( @SUITESPARSE_IN_BUILD_TREE@ ) + # First check in a common build tree + find_package ( CHOLMOD_CUDA @CHOLMOD_VERSION_MAJOR@.@CHOLMOD_VERSION_MINOR@.@CHOLMOD_VERSION_SUB@ + PATHS ${CMAKE_SOURCE_DIR}/../CHOLMOD/build NO_DEFAULT_PATH ) + # Then, check in the currently active CMAKE_MODULE_PATH + if ( NOT TARGET SuiteSparse::CHOLMOD_CUDA ) + find_package ( CHOLMOD_CUDA @CHOLMOD_VERSION_MAJOR@.@CHOLMOD_VERSION_MINOR@.@CHOLMOD_VERSION_SUB@ REQUIRED ) + endif ( ) + else ( ) find_package ( CHOLMOD_CUDA @CHOLMOD_VERSION_MAJOR@.@CHOLMOD_VERSION_MINOR@.@CHOLMOD_VERSION_SUB@ REQUIRED ) endif ( ) endif ( )