mirror of
https://github.com/Kitware/CMake.git
synced 2025-10-16 22:37:30 +08:00
CUDA/Clang: Prefer NVCC's default architecture for each CUDA Toolkit version
This makes the default CUDA architecture consistent across compilers,
and makes it more likely that the resulting binary will run on the
user's hardware.
This also makes hardware requirements for CI builds more consistent.
See commit 4f2178c4a8
(ci: add tags to tie CUDA jobs to runners with
hardware supporting them, 2025-04-21).
This commit is contained in:
@@ -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")
|
||||
|
Reference in New Issue
Block a user