diff options
author | Rodolfo Lima <rlima@nvidia.com> | 2020-01-28 15:26:47 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2020-01-28 19:21:24 (GMT) |
commit | b452e2bd6a95c211a836ca6ff0265547cec28ebd (patch) | |
tree | 3b2a20a5f24e7c2a7e1c4bcca7236315cae8375f /Modules/FindCUDAToolkit.cmake | |
parent | 2e4a948fb821612d8317f7fe4a33792af73472d1 (diff) | |
download | CMake-b452e2bd6a95c211a836ca6ff0265547cec28ebd.zip CMake-b452e2bd6a95c211a836ca6ff0265547cec28ebd.tar.gz CMake-b452e2bd6a95c211a836ca6ff0265547cec28ebd.tar.bz2 |
FindCUDAToolkit: Fix CUDA::* target guard logic
Issue: #20282
Diffstat (limited to 'Modules/FindCUDAToolkit.cmake')
-rw-r--r-- | Modules/FindCUDAToolkit.cmake | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/Modules/FindCUDAToolkit.cmake b/Modules/FindCUDAToolkit.cmake index a6523ef..9f4217d 100644 --- a/Modules/FindCUDAToolkit.cmake +++ b/Modules/FindCUDAToolkit.cmake @@ -746,7 +746,7 @@ if(CUDAToolkit_FOUND) PATH_SUFFIXES nvidia/current lib64 lib64/stubs lib/x64 lib lib/stubs ) - if (NOT CUDA::${lib_name} AND CUDA_${lib_name}_LIBRARY) + if (NOT TARGET CUDA::${lib_name} AND CUDA_${lib_name}_LIBRARY) add_library(CUDA::${lib_name} IMPORTED INTERFACE) target_include_directories(CUDA::${lib_name} SYSTEM INTERFACE "${CUDAToolkit_INCLUDE_DIRS}") target_link_libraries(CUDA::${lib_name} INTERFACE "${CUDA_${lib_name}_LIBRARY}") @@ -763,9 +763,11 @@ if(CUDAToolkit_FOUND) endif() endfunction() - add_library(CUDA::toolkit IMPORTED INTERFACE) - target_include_directories(CUDA::toolkit SYSTEM INTERFACE "${CUDAToolkit_INCLUDE_DIRS}") - target_link_directories(CUDA::toolkit INTERFACE "${CUDAToolkit_LIBRARY_DIR}") + if(NOT TARGET CUDA::toolkit) + add_library(CUDA::toolkit IMPORTED INTERFACE) + target_include_directories(CUDA::toolkit SYSTEM INTERFACE "${CUDAToolkit_INCLUDE_DIRS}") + target_link_directories(CUDA::toolkit INTERFACE "${CUDAToolkit_LIBRARY_DIR}") + endif() _CUDAToolkit_find_and_add_import_lib(cuda_driver cuda) |