mirror of
https://github.com/Kitware/CMake.git
synced 2025-10-19 02:17:27 +08:00
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
This commit is contained in:
@@ -171,14 +171,15 @@ void cmVisualStudioGeneratorOptions::FixCudaCodeGeneration()
|
|||||||
code.clear();
|
code.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (arch.empty() && gencode.empty()) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Create a CodeGeneration field with [arch],[code] syntax in each entry.
|
// Create a CodeGeneration field with [arch],[code] syntax in each entry.
|
||||||
// CUDA will convert it to `-gencode=arch=[arch],code="[code],[arch]"`.
|
// CUDA will convert it to `-gencode=arch=[arch],code="[code],[arch]"`.
|
||||||
FlagValue& result = this->FlagMap["CodeGeneration"];
|
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.
|
// First entries for the -arch=<arch> [-code=<code>,...] pair.
|
||||||
if (!arch.empty()) {
|
if (!arch.empty()) {
|
||||||
std::string arch_name = arch[0];
|
std::string arch_name = arch[0];
|
||||||
|
Reference in New Issue
Block a user