summaryrefslogtreecommitdiffstats
path: root/Source/cmVisualStudio10TargetGenerator.cxx
diff options
context:
space:
mode:
authorunknown <rmaynard@nvidia.com>2021-12-08 14:19:31 (GMT)
committerRobert Maynard <rmaynard@nvidia.com>2021-12-14 19:55:48 (GMT)
commit574b492b47316dbb860535e870a74cdf60b7e446 (patch)
tree75d30ef376be533ff27fc2ac9d4576bcdfcaae7e /Source/cmVisualStudio10TargetGenerator.cxx
parent065604b2b3cabef95c0f406c990274f439452bbd (diff)
downloadCMake-574b492b47316dbb860535e870a74cdf60b7e446.zip
CMake-574b492b47316dbb860535e870a74cdf60b7e446.tar.gz
CMake-574b492b47316dbb860535e870a74cdf60b7e446.tar.bz2
CUDA: Visual Studio Generator propagates definitions for PTX files
From CUDA 9.0 to CUDA 11.4 the CUDA Visual Studio integration defines omitted user defines from PTX generation. With CUDA 11.5 this has been resolved, so we backport the fix to allow for consistent behavior when using CMake
Diffstat (limited to 'Source/cmVisualStudio10TargetGenerator.cxx')
-rw-r--r--Source/cmVisualStudio10TargetGenerator.cxx17
1 files changed, 17 insertions, 0 deletions
diff --git a/Source/cmVisualStudio10TargetGenerator.cxx b/Source/cmVisualStudio10TargetGenerator.cxx
index e9ff758..1c59450 100644
--- a/Source/cmVisualStudio10TargetGenerator.cxx
+++ b/Source/cmVisualStudio10TargetGenerator.cxx
@@ -3228,6 +3228,8 @@ bool cmVisualStudio10TargetGenerator::ComputeCudaOptions(
this->LocalGenerator, Options::CudaCompiler, gg->GetCudaFlagTable());
Options& cudaOptions = *pOptions;
+ auto cudaVersion = this->GlobalGenerator->GetPlatformToolsetCudaString();
+
// Get compile flags for CUDA in this directory.
std::string flags;
this->LocalGenerator->AddLanguageFlags(flags, this->GeneratorTarget, "CUDA",
@@ -3263,7 +3265,22 @@ bool cmVisualStudio10TargetGenerator::ComputeCudaOptions(
// to not have the source file extension at all
cudaOptions.AddFlag("CompileOut", "$(IntDir)%(Filename).ptx");
notPtx = false;
+
+ if (cmSystemTools::VersionCompare(cmSystemTools::OP_GREATER_EQUAL,
+ cudaVersion, "9.0") &&
+ cmSystemTools::VersionCompare(cmSystemTools::OP_LESS, cudaVersion,
+ "11.5")) {
+ // The DriverApi flag before 11.5 ( verified back to 9.0 ) which controls
+ // PTX compilation doesn't propagate user defines causing
+ // target_compile_definitions to behave differently for VS +
+ // PTX compared to other generators so we patch the rules
+ // to normalize behavior
+ cudaOptions.AddFlag("DriverApiCommandLineTemplate",
+ "%(BaseCommandLineTemplate) [CompileOut] [FastMath] "
+ "[Defines] \"%(FullPath)\"");
+ }
}
+
if (notPtx &&
cmSystemTools::VersionCompareGreaterEq(
"8.0", this->GlobalGenerator->GetPlatformToolsetCudaString())) {