mirror of
https://github.com/Kitware/CMake.git
synced 2026-01-06 05:40:54 -06:00
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
This commit is contained in:
@@ -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.
|
||||
|
||||
Reference in New Issue
Block a user