summaryrefslogtreecommitdiffstats
path: root/Tests/RunCMake/CMP0104
diff options
context:
space:
mode:
authorRaul Tambre <raul@tambre.ee>2020-03-12 11:31:47 (GMT)
committerRaul Tambre <raul@tambre.ee>2020-04-15 14:55:41 (GMT)
commite98588aabad578a9b33aae05e77f6ec5b3ff2e46 (patch)
tree34c2ee6ab9b11721b5287a6a9a2b01afb04a5943 /Tests/RunCMake/CMP0104
parent71a06093795efc55c4ef3575b5c4177d38894870 (diff)
downloadCMake-e98588aabad578a9b33aae05e77f6ec5b3ff2e46.zip
CMake-e98588aabad578a9b33aae05e77f6ec5b3ff2e46.tar.gz
CMake-e98588aabad578a9b33aae05e77f6ec5b3ff2e46.tar.bz2
CUDA: Add CUDA_ARCHITECTURES target property
Simplifies CUDA target architecture handling. Required for Clang support as Clang doesn't automatically select a supported architecture. We detect a supported architecture during compiler identification and set CMAKE_CUDA_ARCHITECTURES to it. Introduces CMP0104 for backwards compatibility with manually setting code generation flags with NVCC. Implements #17963.
Diffstat (limited to 'Tests/RunCMake/CMP0104')
-rw-r--r--Tests/RunCMake/CMP0104/CMP0104-Common.cmake2
-rw-r--r--Tests/RunCMake/CMP0104/CMP0104-NEW.cmake6
-rw-r--r--Tests/RunCMake/CMP0104/CMP0104-OLD.cmake12
-rw-r--r--Tests/RunCMake/CMP0104/CMP0104-WARN-stderr.txt8
-rw-r--r--Tests/RunCMake/CMP0104/CMP0104-WARN.cmake1
-rw-r--r--Tests/RunCMake/CMP0104/CMakeLists.txt3
-rw-r--r--Tests/RunCMake/CMP0104/RunCMakeTest.cmake5
-rw-r--r--Tests/RunCMake/CMP0104/main.cu3
8 files changed, 40 insertions, 0 deletions
diff --git a/Tests/RunCMake/CMP0104/CMP0104-Common.cmake b/Tests/RunCMake/CMP0104/CMP0104-Common.cmake
new file mode 100644
index 0000000..b3568f1
--- /dev/null
+++ b/Tests/RunCMake/CMP0104/CMP0104-Common.cmake
@@ -0,0 +1,2 @@
+enable_language(CUDA)
+add_library(cuda main.cu)
diff --git a/Tests/RunCMake/CMP0104/CMP0104-NEW.cmake b/Tests/RunCMake/CMP0104/CMP0104-NEW.cmake
new file mode 100644
index 0000000..732ab77
--- /dev/null
+++ b/Tests/RunCMake/CMP0104/CMP0104-NEW.cmake
@@ -0,0 +1,6 @@
+cmake_policy(SET CMP0104 NEW)
+include(CMP0104-Common.cmake)
+
+if(NOT CMAKE_CUDA_ARCHITECTURES)
+ message(FATAL_ERROR "CMAKE_CUDA_ARCHITECTURES is empty with CMP0104 enabled.")
+endif()
diff --git a/Tests/RunCMake/CMP0104/CMP0104-OLD.cmake b/Tests/RunCMake/CMP0104/CMP0104-OLD.cmake
new file mode 100644
index 0000000..415eecc
--- /dev/null
+++ b/Tests/RunCMake/CMP0104/CMP0104-OLD.cmake
@@ -0,0 +1,12 @@
+cmake_policy(SET CMP0104 OLD)
+include(CMP0104-Common.cmake)
+
+if(CMAKE_CUDA_COMPILER_ID STREQUAL "NVIDIA")
+ if(CMAKE_CUDA_ARCHITECTURES)
+ message(FATAL_ERROR "CMAKE_CUDA_ARCHITECTURES isn't empty for NVIDIA with CMP0104 OLD.")
+ endif()
+else(NOT CMAKE_CUDA_COMPILER_ID STREQUAL "Unknown")
+ if(NOT CMAKE_CUDA_ARCHITECTURES)
+ message(FATAL_ERROR "CMAKE_CUDA_ARCHITECTURES isn't non-empty for non-NVIDIA with CMP0104 OLD.")
+ endif()
+endif()
diff --git a/Tests/RunCMake/CMP0104/CMP0104-WARN-stderr.txt b/Tests/RunCMake/CMP0104/CMP0104-WARN-stderr.txt
new file mode 100644
index 0000000..2c9b7d7
--- /dev/null
+++ b/Tests/RunCMake/CMP0104/CMP0104-WARN-stderr.txt
@@ -0,0 +1,8 @@
+CMake Warning \(dev\) in CMakeLists.txt:
+ Policy CMP0104 is not set: CMAKE_CUDA_ARCHITECTURES now detected for NVCC,
+ empty CUDA_ARCHITECTURES not allowed. Run "cmake --help-policy CMP0104"
+ for policy details. Use the cmake_policy command to set the policy and
+ suppress this warning.
+
+ CUDA_ARCHITECTURES is empty for target "cuda".
+This warning is for project developers. Use -Wno-dev to suppress it.
diff --git a/Tests/RunCMake/CMP0104/CMP0104-WARN.cmake b/Tests/RunCMake/CMP0104/CMP0104-WARN.cmake
new file mode 100644
index 0000000..841d0a8
--- /dev/null
+++ b/Tests/RunCMake/CMP0104/CMP0104-WARN.cmake
@@ -0,0 +1 @@
+include(CMP0104-Common.cmake)
diff --git a/Tests/RunCMake/CMP0104/CMakeLists.txt b/Tests/RunCMake/CMP0104/CMakeLists.txt
new file mode 100644
index 0000000..2632ffa
--- /dev/null
+++ b/Tests/RunCMake/CMP0104/CMakeLists.txt
@@ -0,0 +1,3 @@
+cmake_minimum_required(VERSION 3.16)
+project(${RunCMake_TEST} NONE)
+include(${RunCMake_TEST}.cmake)
diff --git a/Tests/RunCMake/CMP0104/RunCMakeTest.cmake b/Tests/RunCMake/CMP0104/RunCMakeTest.cmake
new file mode 100644
index 0000000..bc8e1b1
--- /dev/null
+++ b/Tests/RunCMake/CMP0104/RunCMakeTest.cmake
@@ -0,0 +1,5 @@
+include(RunCMake)
+
+run_cmake(CMP0104-OLD)
+run_cmake(CMP0104-NEW)
+run_cmake(CMP0104-WARN)
diff --git a/Tests/RunCMake/CMP0104/main.cu b/Tests/RunCMake/CMP0104/main.cu
new file mode 100644
index 0000000..5047a34
--- /dev/null
+++ b/Tests/RunCMake/CMP0104/main.cu
@@ -0,0 +1,3 @@
+int main()
+{
+}