summaryrefslogtreecommitdiffstats
path: root/Source
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2024-07-17 15:33:29 (GMT)
committerBrad King <brad.king@kitware.com>2024-07-17 15:42:31 (GMT)
commita9210a0c02dd8cc1325d2cbb5eb53e29276f7d4a (patch)
tree86359f486acba42581d01c4f4446b9672a516097 /Source
parent3b2ef9b54ca91ed9e0be2680558021b3d000a2ea (diff)
downloadCMake-a9210a0c02dd8cc1325d2cbb5eb53e29276f7d4a.zip
CMake-a9210a0c02dd8cc1325d2cbb5eb53e29276f7d4a.tar.gz
CMake-a9210a0c02dd8cc1325d2cbb5eb53e29276f7d4a.tar.bz2
VS: Restore support for CUDA with no optimization flags
Since commit 67de5b7b82 (VS: Suppress MSBuild default settings affected by UseDebugLibraries, 2024-02-13, v3.30.0-rc1~538^2~1) we generate an empty `Optimization` element for the host compiler when there are no C or C++ optimization flags enabled. The CUDA Toolkit Visual Studio integration fails with an error if an empty string is inherited from the host compiler's `Optimization` element. If no CUDA optimization flags are specified, write an explicit empty `Optimization` element for the CUDA compiler too. Fixes: #26144
Diffstat (limited to 'Source')
-rw-r--r--Source/cmVisualStudio10TargetGenerator.cxx8
1 files changed, 8 insertions, 0 deletions
diff --git a/Source/cmVisualStudio10TargetGenerator.cxx b/Source/cmVisualStudio10TargetGenerator.cxx
index 0fb8bae..a3d5244 100644
--- a/Source/cmVisualStudio10TargetGenerator.cxx
+++ b/Source/cmVisualStudio10TargetGenerator.cxx
@@ -3880,6 +3880,14 @@ bool cmVisualStudio10TargetGenerator::ComputeCudaOptions(
cudaOptions.AddFlag("CudaRuntime", "None");
}
+ if (this->ProjectType == VsProjectType::vcxproj && this->MSTools) {
+ // Suppress inheritance of host compiler optimization flags
+ // when the project does not specify any optimization flags for CUDA.
+ if (!cudaOptions.HasFlag("Optimization")) {
+ cudaOptions.AddFlag("Optimization", "");
+ }
+ }
+
this->CudaOptions[configName] = std::move(pOptions);
return true;
}