From f4853ac7ee07ff2946e095a90ff80f5a90b30913 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Markus=20M=C3=BCtzel?= Date: Wed, 13 Sep 2023 10:33:59 +0200 Subject: [PATCH] Automatically look for CUDA targets when importing GraphBLAS --- .../CUDA/Config/GraphBLAS_CUDAConfig.cmake.in | 3 +++ GraphBLAS/Config/GraphBLASConfig.cmake.in | 16 ++++++++++++++++ 2 files changed, 19 insertions(+) diff --git a/GraphBLAS/CUDA/Config/GraphBLAS_CUDAConfig.cmake.in b/GraphBLAS/CUDA/Config/GraphBLAS_CUDAConfig.cmake.in index a3a24151f..459f2361f 100644 --- a/GraphBLAS/CUDA/Config/GraphBLAS_CUDAConfig.cmake.in +++ b/GraphBLAS/CUDA/Config/GraphBLAS_CUDAConfig.cmake.in @@ -35,6 +35,9 @@ set ( GRAPHBLAS_CUDA_VERSION_MINOR @GraphBLAS_VERSION_MINOR@ ) set ( GRAPHBLAS_CUDA_VERSION_PATCH @GraphBLAS_VERSION_SUB@ ) set ( GRAPHBLAS_CUDA_VERSION "@GraphBLAS_VERSION_MAJOR@.@GraphBLAS_VERSION_MINOR@.@GraphBLAS_VERSION_SUB@" ) +# Look for NVIDIA CUDA toolkit +find_package ( CUDAToolkit @CUDAToolkit_VERSION_MAJOR@ REQUIRED ) + include ( ${CMAKE_CURRENT_LIST_DIR}/GraphBLAS_CUDATargets.cmake ) # The following is only for backward compatibility with FindGraphBLAS_CUDA. diff --git a/GraphBLAS/Config/GraphBLASConfig.cmake.in b/GraphBLAS/Config/GraphBLASConfig.cmake.in index 0f9241834..47e820b25 100644 --- a/GraphBLAS/Config/GraphBLASConfig.cmake.in +++ b/GraphBLAS/Config/GraphBLASConfig.cmake.in @@ -35,6 +35,22 @@ set ( GRAPHBLAS_VERSION_MINOR @GraphBLAS_VERSION_MINOR@ ) set ( GRAPHBLAS_VERSION_PATCH @GraphBLAS_VERSION_SUB@ ) set ( GRAPHBLAS_VERSION "@GraphBLAS_VERSION_MAJOR@.@GraphBLAS_VERSION_MINOR@.@GraphBLAS_VERSION_SUB@" ) +if ( @SUITESPARSE_CUDA@ ) + # Look for imported targets of additional dependency if GraphBLAS was built with CUDA + + if ( @SUITESPARSE_IN_BUILD_TREE@ ) + # First check in a common build tree + find_package ( GraphBLAS_CUDA @GraphBLAS_VERSION_MAJOR@.@GraphBLAS_VERSION_MINOR@.@GraphBLAS_VERSION_SUB@ + PATHS ${CMAKE_SOURCE_DIR}/../GraphBLAS/build/CUDA NO_DEFAULT_PATH ) + # Then, check in the currently active CMAKE_MODULE_PATH + if ( NOT TARGET SuiteSparse::GraphBLAS_CUDA ) + find_package ( GraphBLAS_CUDA @GraphBLAS_VERSION_MAJOR@.@GraphBLAS_VERSION_MINOR@.@GraphBLAS_VERSION_SUB@ REQUIRED ) + endif ( ) + else ( ) + find_package ( GraphBLAS_CUDA @GraphBLAS_VERSION_MAJOR@.@GraphBLAS_VERSION_MINOR@.@GraphBLAS_VERSION_SUB@ REQUIRED ) + endif ( ) +endif ( ) + include ( ${CMAKE_CURRENT_LIST_DIR}/GraphBLASTargets.cmake ) # The following is only for backward compatibility with FindGraphBLAS.