summaryrefslogtreecommitdiffstats
path: root/Source/cmVisualStudioGeneratorOptions.cxx
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2022-05-13 15:33:58 (GMT)
committerBrad King <brad.king@kitware.com>2022-05-13 15:34:51 (GMT)
commit9fe41ecf36bc29f900ca0f9b81ca39d65d10296f (patch)
treeb29e711a79cfb06b04368d22441c9c0e0c6db786 /Source/cmVisualStudioGeneratorOptions.cxx
parent2019bf509268e336f4f68ddf0c05dce49dc289c6 (diff)
downloadCMake-9fe41ecf36bc29f900ca0f9b81ca39d65d10296f.zip
CMake-9fe41ecf36bc29f900ca0f9b81ca39d65d10296f.tar.gz
CMake-9fe41ecf36bc29f900ca0f9b81ca39d65d10296f.tar.bz2
VS: Fix CUDA CodeGeneration field for CMAKE_CUDA_ARCHITECTURES=OFF
If we add no CUDA architecture flags, write an empty `CodeGeneration` field to tell the CUDA Toolkit's VS integration not to add its default flags. We already use this approach for `CMAKE_CUDA_ARCHITECTURES=all` so that the `-arch=all` flag can be added via `AdditionalOptions`. Fixes: #23490
Diffstat (limited to 'Source/cmVisualStudioGeneratorOptions.cxx')
-rw-r--r--Source/cmVisualStudioGeneratorOptions.cxx9
1 files changed, 5 insertions, 4 deletions
diff --git a/Source/cmVisualStudioGeneratorOptions.cxx b/Source/cmVisualStudioGeneratorOptions.cxx
index 9045a4d..0b27dfb 100644
--- a/Source/cmVisualStudioGeneratorOptions.cxx
+++ b/Source/cmVisualStudioGeneratorOptions.cxx
@@ -171,14 +171,15 @@ void cmVisualStudioGeneratorOptions::FixCudaCodeGeneration()
code.clear();
}
- if (arch.empty() && gencode.empty()) {
- return;
- }
-
// Create a CodeGeneration field with [arch],[code] syntax in each entry.
// CUDA will convert it to `-gencode=arch=[arch],code="[code],[arch]"`.
FlagValue& result = this->FlagMap["CodeGeneration"];
+ // If there are no flags, leave the CodeGeneration field empty.
+ if (arch.empty() && gencode.empty()) {
+ return;
+ }
+
// First entries for the -arch=<arch> [-code=<code>,...] pair.
if (!arch.empty()) {
std::string arch_name = arch[0];