Merge topic 'clang-cuda-default-arch' into release-4.0

47ddbc9ded CUDA/Clang: Prefer NVCC's default architecture for each CUDA Toolkit version

Acked-by: Kitware Robot <kwrobot@kitware.com>
Reviewed-by: Raul Tambre <raul@tambre.ee>
Merge-request: !10698
This commit is contained in:
Brad King
2025-04-23 12:56:51 +00:00
committed by Kitware Robot

View File

@@ -112,9 +112,14 @@ if(NOT CMAKE_CUDA_COMPILER_ID_RUN)
cmake_cuda_architectures_validate(CUDA)
if(CMAKE_CUDA_COMPILER_ID STREQUAL "Clang")
# Clang doesn't automatically select an architecture supported by the SDK.
# Try in reverse order of deprecation with the most recent at front (i.e. the most likely to work for new setups).
foreach(arch "52" "30" "20")
# Clang does not automatically select an architecture supported by the SDK.
# Prefer NVCC's default for each SDK version, and fall back to older archs.
set(archs "")
if(NOT CMAKE_CUDA_COMPILER_TOOLKIT_VERSION VERSION_LESS 11.0)
list(APPEND archs 52)
endif()
list(APPEND archs 30 20)
foreach(arch IN LISTS archs)
list(APPEND CMAKE_CUDA_COMPILER_ID_TEST_FLAGS_FIRST "${clang_test_flags} --cuda-gpu-arch=sm_${arch}")
endforeach()
elseif(CMAKE_CUDA_COMPILER_ID STREQUAL "NVIDIA")