summaryrefslogtreecommitdiffstats
path: root/Modules
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2020-11-25 13:34:59 (GMT)
committerKitware Robot <kwrobot@kitware.com>2020-11-25 13:35:08 (GMT)
commit37add8763269a8d08a108c640a6e9aa1b666324d (patch)
tree91a878b3b766b28d4827099f70f3a964ef313de9 /Modules
parent64fb825438a2fecb9eab9933d5d1b926bf6f294b (diff)
parent20807a188299b5f070cf145e40539a30761975ff (diff)
downloadCMake-37add8763269a8d08a108c640a6e9aa1b666324d.zip
CMake-37add8763269a8d08a108c640a6e9aa1b666324d.tar.gz
CMake-37add8763269a8d08a108c640a6e9aa1b666324d.tar.bz2
Merge topic 'cuda_detect_vs_codegen' into release-3.19
20807a1882 CUDA: Fix user-set architectures during detection with Visual Studio Acked-by: Kitware Robot <kwrobot@kitware.com> Merge-request: !5531
Diffstat (limited to 'Modules')
-rw-r--r--Modules/CMakeDetermineCompilerId.cmake12
1 files changed, 8 insertions, 4 deletions
diff --git a/Modules/CMakeDetermineCompilerId.cmake b/Modules/CMakeDetermineCompilerId.cmake
index d907926..a982d2c 100644
--- a/Modules/CMakeDetermineCompilerId.cmake
+++ b/Modules/CMakeDetermineCompilerId.cmake
@@ -413,7 +413,14 @@ Id flags: ${testflags} ${CMAKE_${lang}_COMPILER_ID_FLAGS_ALWAYS}
endif()
set(cuda_tools "CUDA ${CMAKE_VS_PLATFORM_TOOLSET_CUDA}")
set(id_compile "CudaCompile")
- set(id_ItemDefinitionGroup_entry "<CudaCompile><AdditionalOptions>%(AdditionalOptions)-v</AdditionalOptions></CudaCompile>")
+ 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()
+ 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)
set(id_CudaToolkitCustomDir "<CudaToolkitCustomDir>${CMAKE_VS_PLATFORM_TOOLSET_CUDA_CUSTOM_DIR}nvcc</CudaToolkitCustomDir>")
@@ -423,9 +430,6 @@ Id flags: ${testflags} ${CMAKE_${lang}_COMPILER_ID_FLAGS_ALWAYS}
string(CONCAT id_Import_props [[<Import Project="$(VCTargetsPath)\BuildCustomizations\]] "${cuda_tools}" [[.props" />]])
string(CONCAT id_Import_targets [[<Import Project="$(VCTargetsPath)\BuildCustomizations\]] "${cuda_tools}" [[.targets" />]])
endif()
- if(CMAKE_VS_PLATFORM_NAME STREQUAL x64)
- set(id_ItemDefinitionGroup_entry "<CudaCompile><TargetMachinePlatform>64</TargetMachinePlatform><AdditionalOptions>%(AdditionalOptions)-v</AdditionalOptions></CudaCompile>")
- endif()
if(CMAKE_CUDA_FLAGS MATCHES "(^| )-cudart +shared( |$)")
set(id_Link_AdditionalDependencies "<AdditionalDependencies>cudart.lib</AdditionalDependencies>")
else()