summaryrefslogtreecommitdiff
path: root/Modules/FindCUDA.cmake
diff options
context:
space:
mode:
authorJames Bigler <jbigler@nvidia.com>2022-06-14 18:35:12 +0100
committerBrad King <brad.king@kitware.com>2022-06-14 15:48:30 -0400
commita7758394afc2717bb31a47826e62c1ba86a63c41 (patch)
tree24cc3234887494553bcfc5f924741f1dd65dd79f /Modules/FindCUDA.cmake
parentca8a5b05de811d6a95cfa7a33a2985f2b193967f (diff)
downloadcmake-a7758394afc2717bb31a47826e62c1ba86a63c41.tar.gz
FindCUDA: Fix varaible reset with CUDA_TOOLKIT_TARGET_DIR
CUDA_TOOLKIT_TARGET_DIR doesn't always exist in the cache or defined by the user previous to using FindCUDA. In this case it will always reset the variables making it impossible to manually change or set them. This can be fixed by checking to see if the variable is defined before checking against the previously used version stored in CUDA_TOOLKIT_TARGET_DIR_INTERNAL.
Diffstat (limited to 'Modules/FindCUDA.cmake')
-rw-r--r--Modules/FindCUDA.cmake4
1 files changed, 3 insertions, 1 deletions
diff --git a/Modules/FindCUDA.cmake b/Modules/FindCUDA.cmake
index af5f79821d..470111fa69 100644
--- a/Modules/FindCUDA.cmake
+++ b/Modules/FindCUDA.cmake
@@ -799,7 +799,9 @@ if(NOT "${CUDA_TOOLKIT_ROOT_DIR}" STREQUAL "${CUDA_TOOLKIT_ROOT_DIR_INTERNAL}")
unset(CUDA_VERSION CACHE)
endif()
-if(NOT "${CUDA_TOOLKIT_TARGET_DIR}" STREQUAL "${CUDA_TOOLKIT_TARGET_DIR_INTERNAL}")
+# If CUDA_TOOLKIT_TARGET_DIR exists, check if it has changed.
+if(DEFINED CUDA_TOOLKIT_TARGET_DIR
+ AND NOT "${CUDA_TOOLKIT_TARGET_DIR}" STREQUAL "${CUDA_TOOLKIT_TARGET_DIR_INTERNAL}")
cuda_unset_include_and_libraries()
endif()