From 97961c75d7a9c3c8330ccc184eb8cfd14c90e7a5 Mon Sep 17 00:00:00 2001 From: "Roscoe A. Bartlett" Date: Thu, 29 Sep 2022 11:46:47 -0600 Subject: [PATCH] Change to use find_package(CUDAToolkit) (#10954) NOTE: This requires the matching change to the TriBITS file tribits/core/std_tpls/FindTPLCUDA.cmake. --- cmake/TPLs/FindTPLCUBLAS.cmake | 21 ++++------------ cmake/TPLs/FindTPLCUBLASDependencies.cmake | 2 ++ cmake/TPLs/FindTPLCUSPARSE.cmake | 26 ++++---------------- cmake/TPLs/FindTPLCUSPARSEDependencies.cmake | 2 +- 4 files changed, 13 insertions(+), 38 deletions(-) create mode 100644 cmake/TPLs/FindTPLCUBLASDependencies.cmake diff --git a/cmake/TPLs/FindTPLCUBLAS.cmake b/cmake/TPLs/FindTPLCUBLAS.cmake index 84b2cae78edc..0377a11807e0 100644 --- a/cmake/TPLs/FindTPLCUBLAS.cmake +++ b/cmake/TPLs/FindTPLCUBLAS.cmake @@ -53,19 +53,8 @@ # ************************************************************************ # @HEADER -IF (NOT TPL_ENABLE_CUDA) - MESSAGE(FATAL_ERROR "\nCUBLAS: This TPL requires CUDA") -ELSE() - find_library(CUDA_cublas_LIBRARY - cublas - HINTS ${CUDA_TOOLKIT_ROOT_DIR}/lib - ) - IF(CUDA_cublas_LIBRARY STREQUAL "CUDA_cublas_LIBRARY-NOTFOUND") - MESSAGE(FATAL_ERROR "\nCUBLAS: could not find cublas library.") - ENDIF() - SET(TPL_CUBLAS_LIBRARIES ${CUDA_cublas_LIBRARY}) -ENDIF() - -tribits_tpl_find_include_dirs_and_libraries(CUBLAS REQUIRED_LIBS_NAMES cublas) - -unset(TPL_CUBLAS_LIBRARIES) +tribits_extpkg_create_imported_all_libs_target_and_config_file( CUBLAS + INNER_FIND_PACKAGE_NAME CUDAToolkit + IMPORTED_TARGETS_FOR_ALL_LIBS CUDA::cublas ) +# Above, the CUDA TPL should have already found CUDAToolkit so we just need to +# grab the target from it to form the CUSPARSE::all_libs target. diff --git a/cmake/TPLs/FindTPLCUBLASDependencies.cmake b/cmake/TPLs/FindTPLCUBLASDependencies.cmake new file mode 100644 index 000000000000..29469924c219 --- /dev/null +++ b/cmake/TPLs/FindTPLCUBLASDependencies.cmake @@ -0,0 +1,2 @@ +tribits_extpkg_define_dependencies( CUBLAS + DEPENDENCIES CUDA) diff --git a/cmake/TPLs/FindTPLCUSPARSE.cmake b/cmake/TPLs/FindTPLCUSPARSE.cmake index b6a3859d1ffa..ad66dddec3f5 100644 --- a/cmake/TPLs/FindTPLCUSPARSE.cmake +++ b/cmake/TPLs/FindTPLCUSPARSE.cmake @@ -53,24 +53,8 @@ # ************************************************************************ # @HEADER -# Check for CUDA support - -IF (NOT TPL_ENABLE_CUDA OR CUDA_VERSION VERSION_LESS "4.1") - MESSAGE(FATAL_ERROR "\nCUSPARSE: did not find acceptable version of CUDA libraries (4.1 or greater)") -ELSE() - IF(CMAKE_VERSION VERSION_LESS "2.8.8") - # FindCUDA before CMake 2.8.8 does not find cusparse library; therefore, we must - find_library(CUDA_cusparse_LIBRARY - cusparse - HINTS ${CUDA_TOOLKIT_ROOT_DIR}/lib - ) - IF(CUDA_cusparse_LIBRARY STREQUAL "CUDA_cusparse_LIBRARY-NOTFOUND") - MESSAGE(FATAL_ERROR "\nCUSPARSE: could not find cuspasre library.") - ENDIF() - ENDIF(CMAKE_VERSION VERSION_LESS "2.8.8") - SET(TPL_CUSPARSE_LIBRARIES ${CUDA_cusparse_LIBRARY}) -ENDIF() - -tribits_tpl_find_include_dirs_and_libraries(CUSPARSE REQUIRED_LIBS_NAMES cusparse) - -unset(TPL_CUSPARSE_LIBRARIES) +tribits_extpkg_create_imported_all_libs_target_and_config_file( CUSPARSE + INNER_FIND_PACKAGE_NAME CUDAToolkit + IMPORTED_TARGETS_FOR_ALL_LIBS CUDA::cusparse ) +# Above, the CUDA TPL should have already found CUDAToolkit so we just need to +# grab the target from it to form the CUSPARSE::all_libs target. diff --git a/cmake/TPLs/FindTPLCUSPARSEDependencies.cmake b/cmake/TPLs/FindTPLCUSPARSEDependencies.cmake index 904d7ad4f545..ee0405659567 100644 --- a/cmake/TPLs/FindTPLCUSPARSEDependencies.cmake +++ b/cmake/TPLs/FindTPLCUSPARSEDependencies.cmake @@ -1,2 +1,2 @@ tribits_extpkg_define_dependencies( CUSPARSE - DEPENDENCIES CUBLAS) + DEPENDENCIES CUDA)