summaryrefslogtreecommitdiffstats
path: root/Tests/RunCMake
diff options
context:
space:
mode:
authorRaul Tambre <raul@tambre.ee>2021-12-27 18:40:29 (GMT)
committerRaul Tambre <raul@tambre.ee>2022-01-27 20:11:13 (GMT)
commit7a0d0983521cbd16030add2afbb0f7d9e75cce6f (patch)
tree0ec31eaa38525b49c7003c9b3401acf32eecfa5f /Tests/RunCMake
parentd19273bc7b361a54041706c02857993e244d3b50 (diff)
downloadCMake-7a0d0983521cbd16030add2afbb0f7d9e75cce6f.zip
CMake-7a0d0983521cbd16030add2afbb0f7d9e75cce6f.tar.gz
CMake-7a0d0983521cbd16030add2afbb0f7d9e75cce6f.tar.bz2
CUDA: Error on empty/invalid CMAKE_CUDA_ARCHITECTURES set by user
If empty we otherwise treat it the same as unset in most places, but still end up failing eventually with a confusing "Failed to find a working CUDA architecture". This also detects some other basic invalid ones (e.g. "al").
Diffstat (limited to 'Tests/RunCMake')
-rw-r--r--Tests/RunCMake/CMakeLists.txt4
-rw-r--r--Tests/RunCMake/CUDA_architectures/CMakeLists.txt3
-rw-r--r--Tests/RunCMake/CUDA_architectures/RunCMakeTest.cmake4
-rw-r--r--Tests/RunCMake/CUDA_architectures/architectures-empty-result.txt1
-rw-r--r--Tests/RunCMake/CUDA_architectures/architectures-empty-stderr.txt5
-rw-r--r--Tests/RunCMake/CUDA_architectures/architectures-empty.cmake2
-rw-r--r--Tests/RunCMake/CUDA_architectures/architectures-invalid-result.txt1
-rw-r--r--Tests/RunCMake/CUDA_architectures/architectures-invalid-stderr.txt5
-rw-r--r--Tests/RunCMake/CUDA_architectures/architectures-invalid.cmake2
9 files changed, 27 insertions, 0 deletions
diff --git a/Tests/RunCMake/CMakeLists.txt b/Tests/RunCMake/CMakeLists.txt
index 6bea788..6a1c694 100644
--- a/Tests/RunCMake/CMakeLists.txt
+++ b/Tests/RunCMake/CMakeLists.txt
@@ -534,6 +534,10 @@ add_RunCMake_test(no_install_prefix)
add_RunCMake_test(configure_file)
add_RunCMake_test(CTestTimeout -DTIMEOUT=${CTestTestTimeout_TIME})
add_RunCMake_test(CTestTimeoutAfterMatch)
+if(CMake_TEST_CUDA)
+ add_RunCMake_test(CUDA_architectures)
+ set_property(TEST RunCMake.CUDA_architectures APPEND PROPERTY LABELS "CUDA")
+endif()
add_RunCMake_test(DependencyGraph -DCMAKE_Fortran_COMPILER=${CMAKE_Fortran_COMPILER})
# ctresalloc links against CMakeLib and CTestLib, which means it can't be built
diff --git a/Tests/RunCMake/CUDA_architectures/CMakeLists.txt b/Tests/RunCMake/CUDA_architectures/CMakeLists.txt
new file mode 100644
index 0000000..d8200fc
--- /dev/null
+++ b/Tests/RunCMake/CUDA_architectures/CMakeLists.txt
@@ -0,0 +1,3 @@
+cmake_minimum_required(VERSION 3.22)
+project(${RunCMake_TEST} NONE)
+include(${RunCMake_TEST}.cmake)
diff --git a/Tests/RunCMake/CUDA_architectures/RunCMakeTest.cmake b/Tests/RunCMake/CUDA_architectures/RunCMakeTest.cmake
new file mode 100644
index 0000000..cbbf57c
--- /dev/null
+++ b/Tests/RunCMake/CUDA_architectures/RunCMakeTest.cmake
@@ -0,0 +1,4 @@
+include(RunCMake)
+
+run_cmake(architectures-empty)
+run_cmake(architectures-invalid)
diff --git a/Tests/RunCMake/CUDA_architectures/architectures-empty-result.txt b/Tests/RunCMake/CUDA_architectures/architectures-empty-result.txt
new file mode 100644
index 0000000..d00491f
--- /dev/null
+++ b/Tests/RunCMake/CUDA_architectures/architectures-empty-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/CUDA_architectures/architectures-empty-stderr.txt b/Tests/RunCMake/CUDA_architectures/architectures-empty-stderr.txt
new file mode 100644
index 0000000..39640fa
--- /dev/null
+++ b/Tests/RunCMake/CUDA_architectures/architectures-empty-stderr.txt
@@ -0,0 +1,5 @@
+^CMake Error at .*/Modules/CMakeDetermineCUDACompiler\.cmake:[0-9]+ \(message\):
+ CMAKE_CUDA_ARCHITECTURES must be valid if set\.
+Call Stack \(most recent call first\):
+ architectures-empty\.cmake:2 \(enable_language\)
+ CMakeLists\.txt:3 \(include\)
diff --git a/Tests/RunCMake/CUDA_architectures/architectures-empty.cmake b/Tests/RunCMake/CUDA_architectures/architectures-empty.cmake
new file mode 100644
index 0000000..4915248
--- /dev/null
+++ b/Tests/RunCMake/CUDA_architectures/architectures-empty.cmake
@@ -0,0 +1,2 @@
+set(CMAKE_CUDA_ARCHITECTURES "")
+enable_language(CUDA)
diff --git a/Tests/RunCMake/CUDA_architectures/architectures-invalid-result.txt b/Tests/RunCMake/CUDA_architectures/architectures-invalid-result.txt
new file mode 100644
index 0000000..d00491f
--- /dev/null
+++ b/Tests/RunCMake/CUDA_architectures/architectures-invalid-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/CUDA_architectures/architectures-invalid-stderr.txt b/Tests/RunCMake/CUDA_architectures/architectures-invalid-stderr.txt
new file mode 100644
index 0000000..7608730
--- /dev/null
+++ b/Tests/RunCMake/CUDA_architectures/architectures-invalid-stderr.txt
@@ -0,0 +1,5 @@
+^CMake Error at .*/Modules/CMakeDetermineCUDACompiler\.cmake:[0-9]+ \(message\):
+ CMAKE_CUDA_ARCHITECTURES must be valid if set\.
+Call Stack \(most recent call first\):
+ architectures-invalid\.cmake:2 \(enable_language\)
+ CMakeLists\.txt:3 \(include\)$
diff --git a/Tests/RunCMake/CUDA_architectures/architectures-invalid.cmake b/Tests/RunCMake/CUDA_architectures/architectures-invalid.cmake
new file mode 100644
index 0000000..e5c8628
--- /dev/null
+++ b/Tests/RunCMake/CUDA_architectures/architectures-invalid.cmake
@@ -0,0 +1,2 @@
+set(CMAKE_CUDA_ARCHITECTURES "invalid")
+enable_language(CUDA)