Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SPQR/SPQR_CUDA: Automatically check for dependencies when importing target #449

Merged
merged 1 commit into from
Oct 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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