summaryrefslogtreecommitdiffstats
path: root/Tests
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2021-11-02 12:54:57 (GMT)
committerKitware Robot <kwrobot@kitware.com>2021-11-02 12:55:13 (GMT)
commit4e84a4763d702590fb06d62540e35a614dcd5133 (patch)
tree7e296b09c62be920fb89e93997743463842e1250 /Tests
parentd273175157efcdcd5d114ee6e79e61e9bb7a26b6 (diff)
parent14d8a2768d8b8c2ba0f341b4bd59a875aaf6c2f4 (diff)
downloadCMake-4e84a4763d702590fb06d62540e35a614dcd5133.zip
CMake-4e84a4763d702590fb06d62540e35a614dcd5133.tar.gz
CMake-4e84a4763d702590fb06d62540e35a614dcd5133.tar.bz2
Merge topic 'support_nvcc_native_flag'
14d8a2768d CUDA: Support nvcc 11.5 new -arch=all|all-major flags Acked-by: Kitware Robot <kwrobot@kitware.com> Reviewed-by: Raul Tambre <raul@tambre.ee> Merge-request: !6652
Diffstat (limited to 'Tests')
-rw-r--r--Tests/CudaOnly/All/CMakeLists.txt44
-rw-r--r--Tests/CudaOnly/All/main.cu3
-rw-r--r--Tests/CudaOnly/CMakeLists.txt2
3 files changed, 49 insertions, 0 deletions
diff --git a/Tests/CudaOnly/All/CMakeLists.txt b/Tests/CudaOnly/All/CMakeLists.txt
new file mode 100644
index 0000000..fe29bb0
--- /dev/null
+++ b/Tests/CudaOnly/All/CMakeLists.txt
@@ -0,0 +1,44 @@
+cmake_minimum_required(VERSION 3.20)
+project(CudaOnlyAll CUDA)
+
+if(CMAKE_CUDA_COMPILER_ID STREQUAL "NVIDIA" AND
+ CMAKE_CUDA_COMPILER_VERSION VERSION_GREATER_EQUAL 11.5.0)
+
+ set(compile_options -Wno-deprecated-gpu-targets)
+ function(verify_output flag output_var)
+ string(REGEX MATCHALL "-arch compute_([0-9]+)" target_archs "${${output_var}}")
+ list(LENGTH target_archs count)
+ if(count LESS 2)
+ message(FATAL_ERROR "${flag} failed to map to multiple architectures")
+ endif()
+ endfunction()
+endif()
+
+if(COMMAND verify_output)
+ set(try_compile_flags -v ${compile_options})
+
+ set(CMAKE_CUDA_ARCHITECTURES all)
+ try_compile(all_archs_compiles
+ ${CMAKE_CURRENT_BINARY_DIR}/try_compile/all_archs_compiles
+ ${CMAKE_CURRENT_SOURCE_DIR}/main.cu
+ COMPILE_DEFINITIONS ${try_compile_flags}
+ OUTPUT_VARIABLE output
+ )
+ verify_output(all output)
+
+ set(CMAKE_CUDA_ARCHITECTURES all-major)
+ try_compile(all_major_archs_compiles
+ ${CMAKE_CURRENT_BINARY_DIR}/try_compile/all_major_archs_compiles
+ ${CMAKE_CURRENT_SOURCE_DIR}/main.cu
+ COMPILE_DEFINITIONS ${try_compile_flags}
+ OUTPUT_VARIABLE output
+ )
+ verify_output(all-major output)
+
+ if(all_archs_compiles AND all_major_archs_compiles)
+ add_executable(CudaOnlyAll main.cu)
+ target_compile_options(CudaOnlyAll PRIVATE ${compile_options})
+ endif()
+else()
+ add_executable(CudaOnlyAll main.cu)
+endif()
diff --git a/Tests/CudaOnly/All/main.cu b/Tests/CudaOnly/All/main.cu
new file mode 100644
index 0000000..5047a34
--- /dev/null
+++ b/Tests/CudaOnly/All/main.cu
@@ -0,0 +1,3 @@
+int main()
+{
+}
diff --git a/Tests/CudaOnly/CMakeLists.txt b/Tests/CudaOnly/CMakeLists.txt
index 65dfebb..cacfb76 100644
--- a/Tests/CudaOnly/CMakeLists.txt
+++ b/Tests/CudaOnly/CMakeLists.txt
@@ -4,8 +4,10 @@ macro (add_cuda_test_macro name)
PROPERTY LABELS "CUDA")
endmacro ()
+add_cuda_test_macro(CudaOnly.All CudaOnlyAll)
add_cuda_test_macro(CudaOnly.Architecture Architecture)
add_cuda_test_macro(CudaOnly.CompileFlags CudaOnlyCompileFlags)
+
add_cuda_test_macro(CudaOnly.EnableStandard CudaOnlyEnableStandard)
add_cuda_test_macro(CudaOnly.ExportPTX CudaOnlyExportPTX)
add_cuda_test_macro(CudaOnly.SharedRuntimePlusToolkit CudaOnlySharedRuntimePlusToolkit)