summaryrefslogtreecommitdiffstats
path: root/Tests
diff options
context:
space:
mode:
authorRaul Tambre <raul@tambre.ee>2020-10-25 08:23:10 (GMT)
committerBrad King <brad.king@kitware.com>2020-10-27 11:29:01 (GMT)
commitdd77dec18d66a2e20480d9bf2ab06231765720a4 (patch)
tree8eb56d1f89b0d0729a5f7e5b508c61a52a3d4752 /Tests
parente9109dec360043d700ac9cb206b116e6f934a5ec (diff)
downloadCMake-dd77dec18d66a2e20480d9bf2ab06231765720a4.zip
CMake-dd77dec18d66a2e20480d9bf2ab06231765720a4.tar.gz
CMake-dd77dec18d66a2e20480d9bf2ab06231765720a4.tar.bz2
VS: Don't compute CUDA options unless necessary
In the following scenario (with 3.18 policies): 1. A CXX target is created. 2. CUDA language is enabled. CMake 3.18 introduced CMP0104, which requires CUDA_ARCHITECTURES to be set. Because the CXX target was created before CUDA was enabled it wouldn't have it set. The Visual Studio generator would however end up computing CUDA compile options for the CXX target, which would result in a fatal error due to the policy violation. There doesn't seem to be a reason to do this for targets that don't actually use the CUDA language, so we can skip and generate the CXX target just fine. Fixes: #21341
Diffstat (limited to 'Tests')
-rw-r--r--Tests/RunCMake/CMP0104/CMP0104-Common.cmake4
-rw-r--r--Tests/RunCMake/CMP0104/main.cxx3
2 files changed, 7 insertions, 0 deletions
diff --git a/Tests/RunCMake/CMP0104/CMP0104-Common.cmake b/Tests/RunCMake/CMP0104/CMP0104-Common.cmake
index b3568f1..ca4c1aa2 100644
--- a/Tests/RunCMake/CMP0104/CMP0104-Common.cmake
+++ b/Tests/RunCMake/CMP0104/CMP0104-Common.cmake
@@ -1,2 +1,6 @@
+# Make sure CMP0104 isn't issued for CXX targets created prior to enabling CUDA. See #21341.
+enable_language(CXX)
+add_library(cxx main.cxx)
+
enable_language(CUDA)
add_library(cuda main.cu)
diff --git a/Tests/RunCMake/CMP0104/main.cxx b/Tests/RunCMake/CMP0104/main.cxx
new file mode 100644
index 0000000..5047a34
--- /dev/null
+++ b/Tests/RunCMake/CMP0104/main.cxx
@@ -0,0 +1,3 @@
+int main()
+{
+}