CUDA: Fix tests with CUDAARCHS set

With CUDAARCHS there's the possibility of tests being run with multiple
architectures or having CMAKE_CUDA_ARCHITECTURES set with NVCC despite CMP0104
being OLD.
Fix a few tests to work properly in such cases.
This commit is contained in:
Raul Tambre 2020-11-27 17:18:29 +02:00
parent c4ae9384ff
commit c57541d874
3 changed files with 8 additions and 1 deletions

View File

@ -8,6 +8,7 @@ if(CMAKE_CUDA_COMPILER_ID STREQUAL "NVIDIA")
target_compile_options(CudaOnlyCompileFlags PRIVATE
-gencode arch=compute_50,code=compute_50
)
set_property(TARGET CudaOnlyCompileFlags PROPERTY CUDA_ARCHITECTURES)
else()
set_property(TARGET CudaOnlyCompileFlags PROPERTY CUDA_ARCHITECTURES 50-real)
endif()

View File

@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.8)
cmake_minimum_required(VERSION 3.19)
project (ExportPTX CUDA)
#Goal for this example:
@ -6,6 +6,10 @@ project (ExportPTX CUDA)
# How to reference PTX files for custom commands
# How to install PTX files
# PTX can be compiled only for a single virtual architecture at a time
list(SUBLIST CMAKE_CUDA_ARCHITECTURES 0 1 CMAKE_CUDA_ARCHITECTURES)
string(APPEND CMAKE_CUDA_ARCHITECTURES "-virtual")
add_library(CudaPTX OBJECT kernelA.cu kernelB.cu)
set_property(TARGET CudaPTX PROPERTY CUDA_PTX_COMPILATION ON)

View File

@ -1,3 +1,5 @@
set(ENV{CUDAARCHS})
cmake_policy(SET CMP0104 OLD)
include(CMP0104-Common.cmake)