summaryrefslogtreecommitdiffstats
path: root/Modules
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2020-06-08 11:53:19 (GMT)
committerKitware Robot <kwrobot@kitware.com>2020-06-08 11:53:26 (GMT)
commit83256834203055d97f710a1cab3327100833b6ab (patch)
treec19228075650b82af2f5fc6e95f5b95809d73119 /Modules
parent01069f9a107eba9765541640c65c72cc3bc27620 (diff)
parent4eaf1ef4257de10ad8711df77510ceda93f6ccff (diff)
downloadCMake-83256834203055d97f710a1cab3327100833b6ab.zip
CMake-83256834203055d97f710a1cab3327100833b6ab.tar.gz
CMake-83256834203055d97f710a1cab3327100833b6ab.tar.bz2
Merge topic 'cuda_user_architectures_specifiers' into release-3.18
4eaf1ef425 CUDA: Fix checking working architectures with specifiers Acked-by: Kitware Robot <kwrobot@kitware.com> Merge-request: !4856
Diffstat (limited to 'Modules')
-rw-r--r--Modules/CMakeDetermineCUDACompiler.cmake12
1 files changed, 10 insertions, 2 deletions
diff --git a/Modules/CMakeDetermineCUDACompiler.cmake b/Modules/CMakeDetermineCUDACompiler.cmake
index 1601e83..5ae3908 100644
--- a/Modules/CMakeDetermineCUDACompiler.cmake
+++ b/Modules/CMakeDetermineCUDACompiler.cmake
@@ -89,6 +89,7 @@ if(NOT CMAKE_CUDA_COMPILER_ID_RUN)
string(REGEX MATCH "[0-9]+" arch_name "${arch}")
string(APPEND clang_archs " --cuda-gpu-arch=sm_${arch_name}")
string(APPEND nvcc_archs " -gencode=arch=compute_${arch_name},code=sm_${arch_name}")
+ list(APPEND tested_architectures "${arch_name}")
endforeach()
list(APPEND CMAKE_CUDA_COMPILER_ID_TEST_FLAGS_FIRST "${clang_archs}")
@@ -349,6 +350,8 @@ if(CMAKE_CUDA_COMPILER_ID STREQUAL "NVIDIA")
endif()
endif()
+# If the user didn't set the architectures, then set them to a default.
+# If the user did, then make sure those architectures worked.
if(DEFINED detected_architecture)
set(CMAKE_CUDA_ARCHITECTURES "${detected_architecture}" CACHE STRING "CUDA architectures")
@@ -357,10 +360,15 @@ if(DEFINED detected_architecture)
endif()
elseif(architectures)
# Sort since order mustn't matter.
- list(SORT CMAKE_CUDA_ARCHITECTURES)
list(SORT architectures)
+ list(SORT tested_architectures)
- if(NOT "${architectures}" STREQUAL "${CMAKE_CUDA_ARCHITECTURES}")
+ # We don't distinguish real/virtual architectures during testing.
+ # For "70-real;70-virtual" we detect "70" as working and tested_architectures is "70;70".
+ # Thus we need to remove duplicates before checking if they're equal.
+ list(REMOVE_DUPLICATES tested_architectures)
+
+ if(NOT "${architectures}" STREQUAL "${tested_architectures}")
message(FATAL_ERROR
"The CMAKE_CUDA_ARCHITECTURES:\n"
" ${CMAKE_CUDA_ARCHITECTURES}\n"