CUDA: Generate better error message when detecting nvcc

Issue: #23322, #23323
This commit is contained in:
Robert Maynard
2022-03-21 10:21:31 -04:00
parent c8a3c54444
commit 4040173ed3

View File

@@ -260,11 +260,11 @@ if(NOT CMAKE_CUDA_COMPILER_ID_RUN)
set(nvcc_test_flags "--keep --keep-dir tmp")
if(CMAKE_CUDA_HOST_COMPILER)
string(APPEND nvcc_test_flags " -ccbin=\"${CMAKE_CUDA_HOST_COMPILER}\"")
# If the user has specified a host compiler we should fail instead of trying without.
# Succeeding detection without may result in confusing errors later on, see #21076.
set(CMAKE_CUDA_COMPILER_ID_REQUIRE_SUCCESS ON)
endif()
# If we have extracted the vendor as NVIDIA we should require detection to
# work. If we don't, users will get confusing errors later about failure
# to detect a default value for CMAKE_CUDA_ARCHITECTURES
set(CMAKE_CUDA_COMPILER_ID_REQUIRE_SUCCESS ON)
elseif(CMAKE_CUDA_COMPILER_ID STREQUAL "Clang")
set(clang_test_flags "--cuda-path=\"${CMAKE_CUDA_COMPILER_LIBRARY_ROOT}\"")
if(CMAKE_CROSSCOMPILING)