Skip to content

Commit

Permalink
Merge pull request #449 from mmuetzel/spqr
Browse files Browse the repository at this point in the history
SPQR/SPQR_CUDA: Automatically check for dependencies when importing target
  • Loading branch information
DrTimothyAldenDavis authored Oct 20, 2023
2 parents 84693e6 + 2848e4f commit 46fc0fb
Show file tree
Hide file tree
Showing 4 changed files with 69 additions and 2 deletions.
4 changes: 2 additions & 2 deletions SPQR/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -264,14 +264,14 @@ install ( EXPORT SPQRTargets
DESTINATION ${SUITESPARSE_LIBDIR}/cmake/SPQR )

# generate config file to be used in common build tree
set ( SUITESPARSE_IN_BUILD_TREE on )
set ( SUITESPARSE_IN_BUILD_TREE ON )
configure_package_config_file (
Config/SPQRConfig.cmake.in
${CMAKE_CURRENT_BINARY_DIR}/SPQRConfig.cmake
INSTALL_DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/SPQRConfig.cmake )

# generate config file to be installed
set ( SUITESPARSE_IN_BUILD_TREE off )
set ( SUITESPARSE_IN_BUILD_TREE OFF )
configure_package_config_file (
Config/SPQRConfig.cmake.in
${CMAKE_CURRENT_BINARY_DIR}/target/SPQRConfig.cmake
Expand Down
36 changes: 36 additions & 0 deletions SPQR/Config/SPQRConfig.cmake.in
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,44 @@ set ( SPQR_VERSION "@SPQR_VERSION_MAJOR@.@SPQR_VERSION_MINOR@.@SPQR_VERSION_SUB@

# Check for dependent targets
include ( CMakeFindDependencyMacro )

set ( _dependencies_found ON )

# Look for SuiteSparse_config and CHOLMOD targets
if ( @SUITESPARSE_IN_BUILD_TREE@ )
if ( NOT TARGET SuiteSparse::SuiteSparseConfig )
# First check in a common build tree
find_dependency ( SuiteSparse_config @SUITESPARSE_CONFIG_VERSION_MAJOR@.@SUITESPARSE_CONFIG_VERSION_MINOR@
PATHS ${CMAKE_SOURCE_DIR}/../SuiteSparse_config/build NO_DEFAULT_PATH )
# Then, check in the currently active CMAKE_MODULE_PATH
if ( NOT SuiteSparse_config_FOUND )
find_dependency ( SuiteSparse_config @SUITESPARSE_CONFIG_VERSION_MAJOR@.@SUITESPARSE_CONFIG_VERSION_MINOR@ )
endif ( )
endif ( )

if ( NOT TARGET SuiteSparse::CHOLMOD )
# First check in a common build tree
find_dependency ( CHOLMOD @CHOLMOD_VERSION_MAJOR@.@CHOLMOD_VERSION_MINOR@
PATHS ${CMAKE_SOURCE_DIR}/../CHOLMOD/build NO_DEFAULT_PATH )
# Then, check in the currently active CMAKE_MODULE_PATH
if ( NOT CHOLMOD_FOUND )
find_dependency ( CHOLMOD @CHOLMOD_VERSION_MAJOR@.@CHOLMOD_VERSION_MINOR@ )
endif ( )
endif ( )

else ( )
if ( NOT TARGET SuiteSparse::SuiteSparseConfig )
find_dependency ( SuiteSparse_config @SUITESPARSE_CONFIG_VERSION_MAJOR@.@SUITESPARSE_CONFIG_VERSION_MINOR@ )
endif ( )
if ( NOT TARGET SuiteSparse::CHOLMOD )
find_dependency ( CHOLMOD @CHOLMOD_VERSION_MAJOR@.@CHOLMOD_VERSION_MINOR@ )
endif ( )
endif ( )

if ( NOT SuiteSparse_config_FOUND OR NOT CHOLMOD_FOUND )
set ( _dependencies_found OFF )
endif ( )

if ( @SUITESPARSE_CUDA@ )
# Look for imported targets of additional dependency if SPQR was built with CUDA

Expand Down
22 changes: 22 additions & 0 deletions SPQR/Config/SPQR_CUDAConfig.cmake.in
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,28 @@ set ( SPQR_CUDA_VERSION "@SPQR_VERSION_MAJOR@.@SPQR_VERSION_MINOR@.@SPQR_VERSION
include ( CMakeFindDependencyMacro )
set ( _dependencies_found ON )

# Look for CHOLMOD target
if ( @SUITESPARSE_IN_BUILD_TREE@ )
if ( NOT TARGET SuiteSparse::CHOLMOD )
# First check in a common build tree
find_dependency ( CHOLMOD @CHOLMOD_VERSION_MAJOR@.@CHOLMOD_VERSION_MINOR@
PATHS ${CMAKE_SOURCE_DIR}/../CHOLMOD/build NO_DEFAULT_PATH )
# Then, check in the currently active CMAKE_MODULE_PATH
if ( NOT CHOLMOD_FOUND )
find_dependency ( CHOLMOD @CHOLMOD_VERSION_MAJOR@.@CHOLMOD_VERSION_MINOR@ )
endif ( )
endif ( )

else ( )
if ( NOT TARGET SuiteSparse::CHOLMOD )
find_dependency ( CHOLMOD @CHOLMOD_VERSION_MAJOR@.@CHOLMOD_VERSION_MINOR@ )
endif ( )
endif ( )

if ( NOT CHOLMOD_FOUND )
set ( _dependencies_found OFF )
endif ( )

# Look for NVIDIA CUDA toolkit
if ( NOT CUDAToolkit_FOUND )
find_dependency ( CUDAToolkit @CUDAToolkit_VERSION_MAJOR@ )
Expand Down
9 changes: 9 additions & 0 deletions SPQR/SPQRGPU/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -127,9 +127,18 @@ install ( EXPORT SPQR_CUDATargets
NAMESPACE SuiteSparse::
DESTINATION ${SUITESPARSE_LIBDIR}/cmake/SPQR_CUDA )

# generate config file to be used in common build tree
set ( SUITESPARSE_IN_BUILD_TREE ON )
configure_package_config_file (
../Config/SPQR_CUDAConfig.cmake.in
${CMAKE_CURRENT_BINARY_DIR}/../SPQR_CUDAConfig.cmake
INSTALL_DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/../SPQR_CUDAConfig.cmake )

# generate config file to be installed
set ( SUITESPARSE_IN_BUILD_TREE OFF )
configure_package_config_file (
../Config/SPQR_CUDAConfig.cmake.in
${CMAKE_CURRENT_BINARY_DIR}/../target/SPQR_CUDAConfig.cmake
INSTALL_DESTINATION ${SUITESPARSE_LIBDIR}/cmake/SPQR_CUDA )

write_basic_package_version_file (
Expand Down

0 comments on commit 46fc0fb

Please sign in to comment.