summaryrefslogtreecommitdiffstats
path: root/Source
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2017-06-21 18:15:23 (GMT)
committerBrad King <brad.king@kitware.com>2017-06-21 18:24:11 (GMT)
commit3b75421515835b2fc6713be3015cc3f7324bb5a8 (patch)
tree6ede896d530967b49b29498ba79b6a8e36a22f3c /Source
parentf2059585e6302446707560b123c7b785df5f5859 (diff)
downloadCMake-3b75421515835b2fc6713be3015cc3f7324bb5a8.zip
CMake-3b75421515835b2fc6713be3015cc3f7324bb5a8.tar.gz
CMake-3b75421515835b2fc6713be3015cc3f7324bb5a8.tar.bz2
VS: Improve workaround for CUDA -Xcompiler placement bug
In commit v3.9.0-rc1~431^2~6 (VS: Place CUDA host compiler options in proper project file fields, 2017-03-07) we worked around a bug in the CUDA VS integration by dropping `AdditionalCompilerOptions`. However, this silently drops `-Xcompiler=` options given by the user that don't map to one of CudaCompile's dedicated settings. Improve the workaround to instead put the remaining `AdditionalCompilerOptions` into the `AdditionalOptions` field behind `-Xcompiler=` ourselves.
Diffstat (limited to 'Source')
-rw-r--r--Source/cmVisualStudio10TargetGenerator.cxx13
1 files changed, 10 insertions, 3 deletions
diff --git a/Source/cmVisualStudio10TargetGenerator.cxx b/Source/cmVisualStudio10TargetGenerator.cxx
index 2a7d96b..32ece3f 100644
--- a/Source/cmVisualStudio10TargetGenerator.cxx
+++ b/Source/cmVisualStudio10TargetGenerator.cxx
@@ -2523,9 +2523,16 @@ bool cmVisualStudio10TargetGenerator::ComputeCudaOptions(
cudaOptions.AddTable(gg->GetCudaHostFlagTable());
cudaOptions.Reparse("AdditionalCompilerOptions");
- // `CUDA 8.0.targets` places these before nvcc! Just drop whatever
- // did not parse and hope it works.
- cudaOptions.RemoveFlag("AdditionalCompilerOptions");
+ // `CUDA 8.0.targets` places AdditionalCompilerOptions before nvcc!
+ // Pass them through -Xcompiler in AdditionalOptions instead.
+ if (const char* acoPtr = cudaOptions.GetFlag("AdditionalCompilerOptions")) {
+ std::string aco = acoPtr;
+ cudaOptions.RemoveFlag("AdditionalCompilerOptions");
+ if (!aco.empty()) {
+ aco = this->LocalGenerator->EscapeForShell(aco, false);
+ cudaOptions.AppendFlag("AdditionalOptions", "-Xcompiler=" + aco);
+ }
+ }
cudaOptions.FixCudaCodeGeneration();