Skip to content

Commit

Permalink
VS: Restore support for CUDA with no optimization flags
Browse files Browse the repository at this point in the history
Since commit 67de5b7 (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
  • Loading branch information
bradking committed Jul 17, 2024
1 parent 3b2ef9b commit a9210a0
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions Source/cmVisualStudio10TargetGenerator.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down

0 comments on commit a9210a0

Please sign in to comment.