diff options
author | Brad King <brad.king@kitware.com> | 2018-04-13 16:38:08 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2018-04-13 16:56:36 (GMT) |
commit | 134e795fa968a06e289f1449b6ca4bf4702da03b (patch) | |
tree | 25014da053bc985cbbaebf673393bf21d184f3f1 /Source | |
parent | 77705a2c2834e84a7413e01e5575201d1730b57a (diff) | |
download | CMake-134e795fa968a06e289f1449b6ca4bf4702da03b.zip CMake-134e795fa968a06e289f1449b6ca4bf4702da03b.tar.gz CMake-134e795fa968a06e289f1449b6ca4bf4702da03b.tar.bz2 |
VS: Add workaround for CUDA compiler PDB location
The CUDA Toolkit Visual Studio Integration does not honor the
`ClCompile.ProgramDataBaseFileName` field when telling `nvcc` how to
invoke `cl`. Work around this problem by passing `-Xcompiler=-Fd...`
ourselves through `AdditionalOptions`.
Fixes: #17647
Diffstat (limited to 'Source')
-rw-r--r-- | Source/cmVisualStudio10TargetGenerator.cxx | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/Source/cmVisualStudio10TargetGenerator.cxx b/Source/cmVisualStudio10TargetGenerator.cxx index 13af167..3869708 100644 --- a/Source/cmVisualStudio10TargetGenerator.cxx +++ b/Source/cmVisualStudio10TargetGenerator.cxx @@ -2690,6 +2690,20 @@ bool cmVisualStudio10TargetGenerator::ComputeCudaOptions( cudaOptions.AppendFlagString("AdditionalOptions", "-x cu"); } + // Specify the compiler program database file if configured. + std::string pdb = this->GeneratorTarget->GetCompilePDBPath(configName); + if (!pdb.empty()) { + // CUDA does not have a field for this and does not honor the + // ProgramDataBaseFileName field in ClCompile. Work around this + // limitation by creating the directory and passing the flag ourselves. + std::string const pdbDir = cmSystemTools::GetFilenamePath(pdb); + cmSystemTools::MakeDirectory(pdbDir); + pdb = this->ConvertPath(pdb, true); + ConvertToWindowsSlash(pdb); + std::string const clFd = "-Xcompiler=\"-Fd\\\"" + pdb + "\\\"\""; + cudaOptions.AppendFlagString("AdditionalOptions", clFd); + } + // CUDA automatically passes the proper '--machine' flag to nvcc // for the current architecture, but does not reflect this default // in the user-visible IDE settings. Set it explicitly. |