[nvptx-arch] Remove `find_package(CUDA)` as it has been deprecated.
authorJoseph Huber <jhuber6@vols.utk.edu>
Wed, 25 Jan 2023 19:24:34 +0000 (13:24 -0600)
committerJoseph Huber <jhuber6@vols.utk.edu>
Wed, 25 Jan 2023 19:58:00 +0000 (13:58 -0600)
Since D137724 and the LLVM 17 release we have updated to CMake version
3.20. This means we can use `find_package(CUDAToolkit)` instead as the
legacy module is deprecated.

Reviewed By: tianshilei1992

Differential Revision: https://reviews.llvm.org/D142570

clang/tools/nvptx-arch/CMakeLists.txt

index 9b31cdd..95c25dc 100644 (file)
@@ -9,18 +9,11 @@
 set(LLVM_LINK_COMPONENTS Support)
 add_clang_tool(nvptx-arch NVPTXArch.cpp)
 
-# TODO: This is deprecated. Since CMake 3.17 we can use FindCUDAToolkit instead.
-find_package(CUDA QUIET)
-find_library(cuda-library NAMES cuda PATHS /lib64)
-if (NOT cuda-library AND CUDA_FOUND)
-  get_filename_component(CUDA_LIBDIR "${CUDA_cudart_static_LIBRARY}" DIRECTORY)
-  find_library(cuda-library NAMES cuda HINTS "${CUDA_LIBDIR}/stubs")
-endif()
+find_package(CUDAToolkit QUIET)
 
 # If we found the CUDA library directly we just dynamically link against it.
-if (CUDA_FOUND AND cuda-library)
-  target_include_directories(nvptx-arch PRIVATE ${CUDA_INCLUDE_DIRS})
-  target_link_libraries(nvptx-arch PRIVATE ${cuda-library})
+if (CUDAToolkit_FOUND)
+  target_link_libraries(nvptx-arch PRIVATE CUDA::cuda_driver)
 else()
   target_compile_definitions(nvptx-arch PRIVATE "DYNAMIC_CUDA")
 endif()