diff options
author | Brad King <brad.king@kitware.com> | 2022-03-03 16:47:53 (GMT) |
---|---|---|
committer | Kitware Robot <kwrobot@kitware.com> | 2022-03-03 16:48:01 (GMT) |
commit | 0e27bb9356c443d29510baea84a92f32053ea514 (patch) | |
tree | 23f9bee0b74b901482b067453f6dff905527cfb6 /Modules | |
parent | 71323635aa0c3febcfd225c52e7680dd5d233d08 (diff) | |
parent | dae3ad08fa1fe3078bf2fd3e949a078ca24e5636 (diff) | |
download | CMake-0e27bb9356c443d29510baea84a92f32053ea514.zip CMake-0e27bb9356c443d29510baea84a92f32053ea514.tar.gz CMake-0e27bb9356c443d29510baea84a92f32053ea514.tar.bz2 |
Merge topic 'cuda-arch-all'
dae3ad08fa Tests: Add cases for CMAKE_CUDA_ARCHITECTURES={all,all-major}
5c1f5357b0 VS: Fix CUDA compiler id with CMAKE_CUDA_ARCHITECTURES={all,all-major}
Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !7035
Diffstat (limited to 'Modules')
-rw-r--r-- | Modules/CMakeDetermineCUDACompiler.cmake | 4 | ||||
-rw-r--r-- | Modules/CMakeDetermineCompilerId.cmake | 10 |
2 files changed, 9 insertions, 5 deletions
diff --git a/Modules/CMakeDetermineCUDACompiler.cmake b/Modules/CMakeDetermineCUDACompiler.cmake index f491c79..8c01ea4 100644 --- a/Modules/CMakeDetermineCUDACompiler.cmake +++ b/Modules/CMakeDetermineCUDACompiler.cmake @@ -280,7 +280,9 @@ if(NOT CMAKE_CUDA_COMPILER_ID_RUN) if(CMAKE_CUDA_COMPILER_ID STREQUAL "NVIDIA" AND CMAKE_CUDA_COMPILER_TOOLKIT_VERSION VERSION_GREATER_EQUAL 11.5) string(APPEND nvcc_test_flags " -arch=${CMAKE_CUDA_ARCHITECTURES}") set(architectures_tested "${CMAKE_CUDA_ARCHITECTURES}") - elseif(NOT CMAKE_GENERATOR MATCHES "Visual Studio") + elseif(CMAKE_GENERATOR MATCHES "Visual Studio") + set(architectures_tested "${CMAKE_CUDA_ARCHITECTURES}") + else() if(CMAKE_CUDA_ARCHITECTURES STREQUAL "all") set(architectures_test ${CMAKE_CUDA_ARCHITECTURES_ALL}) elseif(CMAKE_CUDA_ARCHITECTURES STREQUAL "all-major") diff --git a/Modules/CMakeDetermineCompilerId.cmake b/Modules/CMakeDetermineCompilerId.cmake index 3ea146c..e0aa483 100644 --- a/Modules/CMakeDetermineCompilerId.cmake +++ b/Modules/CMakeDetermineCompilerId.cmake @@ -495,10 +495,12 @@ Id flags: ${testflags} ${CMAKE_${lang}_COMPILER_ID_FLAGS_ALWAYS} if(CMAKE_VS_PLATFORM_NAME STREQUAL x64) set(cuda_target "<TargetMachinePlatform>64</TargetMachinePlatform>") endif() - foreach(arch ${CMAKE_CUDA_ARCHITECTURES}) - string(REGEX MATCH "[0-9]+" arch_name "${arch}") - string(APPEND cuda_codegen "compute_${arch_name},sm_${arch_name};") - endforeach() + if(NOT CMAKE_CUDA_ARCHITECTURES MATCHES "^(all|all-major)$") + foreach(arch ${CMAKE_CUDA_ARCHITECTURES}) + string(REGEX MATCH "[0-9]+" arch_name "${arch}") + string(APPEND cuda_codegen "compute_${arch_name},sm_${arch_name};") + endforeach() + endif() set(id_ItemDefinitionGroup_entry "<CudaCompile>${cuda_target}<AdditionalOptions>%(AdditionalOptions)-v</AdditionalOptions><CodeGeneration>${cuda_codegen}</CodeGeneration></CudaCompile>") set(id_PostBuildEvent_Command [[echo CMAKE_CUDA_COMPILER=$(CudaToolkitBinDir)\nvcc.exe]]) if(CMAKE_VS_PLATFORM_TOOLSET_CUDA_CUSTOM_DIR) |