summaryrefslogtreecommitdiffstats
path: root/Source/cmVisualStudio10TargetGenerator.cxx
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2021-12-16 15:27:04 (GMT)
committerKitware Robot <kwrobot@kitware.com>2021-12-16 15:27:21 (GMT)
commit4663c82f9e74700ebf7f1677c518869fe5589f8c (patch)
tree27d056504d8a34325ed20c7d00dab3b8af28242c /Source/cmVisualStudio10TargetGenerator.cxx
parentb24da17d9bc1ebe913d8650a9e7a4b288a22d941 (diff)
parent574b492b47316dbb860535e870a74cdf60b7e446 (diff)
downloadCMake-4663c82f9e74700ebf7f1677c518869fe5589f8c.zip
CMake-4663c82f9e74700ebf7f1677c518869fe5589f8c.tar.gz
CMake-4663c82f9e74700ebf7f1677c518869fe5589f8c.tar.bz2
Merge topic 'msvc_cuda_propagate_defines_to_ptx'
574b492b47 CUDA: Visual Studio Generator propagates definitions for PTX files Acked-by: Kitware Robot <kwrobot@kitware.com> Merge-request: !6802
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 5bec7d3..4d0773b 100644
--- a/Source/cmVisualStudio10TargetGenerator.cxx
+++ b/Source/cmVisualStudio10TargetGenerator.cxx
@@ -3245,6 +3245,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",
@@ -3280,7 +3282,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())) {