Skip to content

Commit 606459e

Browse files
CMake: Use FindCUDAToolkit and enable_language(CUDA) instead of FindCUDA
Fixes warning: CMake Warning (dev) at CMakeLists.txt:696 (find_package): Policy CMP0146 is not set: The FindCUDA module is removed. Run "cmake --help-policy CMP0146" for policy details. Use the cmake_policy command to set the policy and suppress this warning.
1 parent 6ccdd70 commit 606459e

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

CMakeLists.txt

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -693,8 +693,15 @@ if(CUDA)
693693
configure_file(${file} include/ COPYONLY)
694694
endforeach()
695695

696-
find_package(CUDA REQUIRED)
697-
set(CUDA_DIR ${CUDA_TOOLKIT_ROOT_DIR})
696+
if(CMAKE_VERSION VERSION_GREATER 3.17 OR CMAKE_VERSION VERSION_EQUAL 3.17)
697+
find_package(CUDAToolkit REQUIRED)
698+
set(CMAKE_CUDA_COMPILER "${CUDAToolkit_NVCC_EXECUTABLE}")
699+
enable_language(CUDA)
700+
set(CUDA_DIR "${CUDAToolkit_TARGET_DIR}")
701+
else()
702+
find_package(CUDA REQUIRED)
703+
set(CUDA_DIR "${CUDA_TOOLKIT_ROOT_DIR}")
704+
endif()
698705
add_library(cudahybridapi ${hybridAPI-cxx-sources})
699706
endif()
700707

0 commit comments

Comments
 (0)