1
0
mirror of https://github.com/Kitware/CMake.git synced 2025-10-14 02:08:27 +08:00

FindCUDAToolkit: Don't keep searching when CUDAToolkit_ROOT is set

Don't continue to search other locations for CUDA if the user
has specified a location and we fail to find it.
This commit is contained in:
Robert Maynard
2025-09-10 11:01:43 -04:00
committed by Brad King
parent 9126ed5162
commit a345c0e193

View File

@@ -910,10 +910,18 @@ else()
# Try user provided path
if(NOT CUDAToolkit_ROOT_DIR AND DEFINED CUDAToolkit_ROOT)
_CUDAToolkit_find_root_dir(SEARCH_PATHS "${CUDAToolkit_ROOT}" FIND_FLAGS PATH_SUFFIXES bin NO_DEFAULT_PATH)
if(NOT CUDAToolkit_ROOT_DIR)
# If the user specified CUDAToolkit_ROOT but the toolkit could not be found, this is an error.
_CUDAToolkit_find_failure_message(VARIABLE)
endif()
endif()
if(NOT CUDAToolkit_ROOT_DIR AND DEFINED ENV{CUDAToolkit_ROOT})
_CUDAToolkit_find_root_dir(SEARCH_PATHS "$ENV{CUDAToolkit_ROOT}" FIND_FLAGS PATH_SUFFIXES bin NO_DEFAULT_PATH)
if(NOT CUDAToolkit_ROOT_DIR)
# If the user specified ENV{CUDAToolkit_ROOT} but the toolkit could not be found, this is an error.
_CUDAToolkit_find_failure_message(ENV)
endif()
endif()
# Try users PATH, and CUDA_PATH env variable
@@ -921,13 +929,6 @@ else()
_CUDAToolkit_find_root_dir(FIND_FLAGS PATHS ENV CUDA_PATH PATH_SUFFIXES bin)
endif()
# If the user specified CUDAToolkit_ROOT but the toolkit could not be found, this is an error.
if(NOT CUDAToolkit_ROOT_DIR AND DEFINED CUDAToolkit_ROOT)
_CUDAToolkit_find_failure_message(VARIABLE)
elseif(NOT CUDAToolkit_ROOT_DIR AND DEFINED ENV{CUDAToolkit_ROOT})
_CUDAToolkit_find_failure_message(ENV)
endif()
# Try guessing where CUDA is installed
if(NOT CUDAToolkit_ROOT_DIR)
_CUDAToolkit_guess_root_dir()