diff options
-rw-r--r-- | Modules/CMakeDetermineCompilerId.cmake | 12 |
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() |