summaryrefslogtreecommitdiff
path: root/Modules/FindCUDAToolkit.cmake
diff options
context:
space:
mode:
authorRobert Maynard <robert.maynard@kitware.com>2020-01-24 15:32:35 -0500
committerBrad King <brad.king@kitware.com>2020-01-27 13:42:18 -0500
commit45d21dd5d409134949f091afd74d4ee85c92274f (patch)
tree990012b96eec144a3e9d85d870987b9d451b8da7 /Modules/FindCUDAToolkit.cmake
parente357772f202e2636d7e5f9cc0dd1f926dbe327bc (diff)
downloadcmake-45d21dd5d409134949f091afd74d4ee85c92274f.tar.gz
CUDAToolkit: Use CMAKE_FIND_ROOT_PATH for all sdk lib searches
Diffstat (limited to 'Modules/FindCUDAToolkit.cmake')
-rw-r--r--Modules/FindCUDAToolkit.cmake24
1 files changed, 18 insertions, 6 deletions
diff --git a/Modules/FindCUDAToolkit.cmake b/Modules/FindCUDAToolkit.cmake
index 676da04030..a6523efd48 100644
--- a/Modules/FindCUDAToolkit.cmake
+++ b/Modules/FindCUDAToolkit.cmake
@@ -668,13 +668,23 @@ if(CMAKE_CROSSCOMPILING)
if (EXISTS "${CUDAToolkit_ROOT_DIR}/targets/${CUDAToolkit_TARGET_NAME}")
set(CUDAToolkit_TARGET_DIR "${CUDAToolkit_ROOT_DIR}/targets/${CUDAToolkit_TARGET_NAME}")
# add known CUDA target root path to the set of directories we search for programs, libraries and headers
- list(APPEND CMAKE_FIND_ROOT_PATH "${CUDAToolkit_TARGET_DIR}")
+ list(PREPEND CMAKE_FIND_ROOT_PATH "${CUDAToolkit_TARGET_DIR}")
+
+ # Mark that we need to pop the root search path changes after we have
+ # found all cuda libraries so that searches for our cross-compilation
+ # libraries work when another cuda sdk is in CMAKE_PREFIX_PATH or
+ # PATh
+ set(_CUDAToolkit_Pop_ROOT_PATH True)
endif()
else()
# Not cross compiling
set(CUDAToolkit_TARGET_DIR "${CUDAToolkit_ROOT_DIR}")
# Now that we have the real ROOT_DIR, find components inside it.
list(APPEND CMAKE_PREFIX_PATH ${CUDAToolkit_ROOT_DIR})
+
+ # Mark that we need to pop the prefix path changes after we have
+ # found the cudart library.
+ set(_CUDAToolkit_Pop_Prefix True)
endif()
@@ -693,12 +703,9 @@ if (NOT CUDA_CUDART AND NOT CUDAToolkit_FIND_QUIETLY)
endif()
unset(CUDAToolkit_ROOT_DIR)
-if(CMAKE_CROSSCOMPILING)
- if(CUDAToolkit_TARGET_DIR)
- list(REMOVE_AT CMAKE_FIND_ROOT_PATH -1)
- endif()
-else()
+if(_CUDAToolkit_Pop_Prefix)
list(REMOVE_AT CMAKE_PREFIX_PATH -1)
+ unset(_CUDAToolkit_Pop_Prefix)
endif()
#-----------------------------------------------------------------------------
@@ -819,3 +826,8 @@ if(CUDAToolkit_FOUND)
endif()
endif()
+
+if(_CUDAToolkit_Pop_ROOT_PATH)
+ list(REMOVE_AT CMAKE_FIND_ROOT_PATH 0)
+ unset(_CUDAToolkit_Pop_ROOT_PATH)
+endif()