mirror of
https://github.com/Kitware/CMake.git
synced 2026-01-09 07:11:05 -06:00
Makefile,Ninja: De-duplicate MSVC compiler PDB path selection
Add a helper to cmCommonTargetGenerator instead of duplicating it in cmMakefileTargetGenerator and cmNinjaTargetGenerator.
This commit is contained in:
@@ -184,6 +184,28 @@ std::vector<std::string> cmCommonTargetGenerator::GetLinkedTargetDirectories()
|
||||
return dirs;
|
||||
}
|
||||
|
||||
std::string cmCommonTargetGenerator::ComputeTargetCompilePDB() const
|
||||
{
|
||||
std::string compilePdbPath;
|
||||
if (this->GeneratorTarget->GetType() > cmStateEnums::OBJECT_LIBRARY) {
|
||||
return compilePdbPath;
|
||||
}
|
||||
compilePdbPath =
|
||||
this->GeneratorTarget->GetCompilePDBPath(this->GetConfigName());
|
||||
if (compilePdbPath.empty()) {
|
||||
// Match VS default: `$(IntDir)vc$(PlatformToolsetVersion).pdb`.
|
||||
// A trailing slash tells the toolchain to add its default file name.
|
||||
compilePdbPath = this->GeneratorTarget->GetSupportDirectory() + "/";
|
||||
if (this->GeneratorTarget->GetType() == cmStateEnums::STATIC_LIBRARY) {
|
||||
// Match VS default for static libs: `$(IntDir)$(ProjectName).pdb`.
|
||||
compilePdbPath += this->GeneratorTarget->GetName();
|
||||
compilePdbPath += ".pdb";
|
||||
}
|
||||
}
|
||||
|
||||
return compilePdbPath;
|
||||
}
|
||||
|
||||
std::string cmCommonTargetGenerator::GetManifests()
|
||||
{
|
||||
std::vector<cmSourceFile const*> manifest_srcs;
|
||||
|
||||
@@ -66,6 +66,7 @@ protected:
|
||||
std::string GetManifests();
|
||||
|
||||
std::vector<std::string> GetLinkedTargetDirectories() const;
|
||||
std::string ComputeTargetCompilePDB() const;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -504,7 +504,7 @@ void cmMakefileTargetGenerator::WriteObjectBuildFile(
|
||||
{
|
||||
std::string targetFullPathReal;
|
||||
std::string targetFullPathPDB;
|
||||
std::string targetFullPathCompilePDB;
|
||||
std::string targetFullPathCompilePDB = this->ComputeTargetCompilePDB();
|
||||
if (this->GeneratorTarget->GetType() == cmStateEnums::EXECUTABLE ||
|
||||
this->GeneratorTarget->GetType() == cmStateEnums::STATIC_LIBRARY ||
|
||||
this->GeneratorTarget->GetType() == cmStateEnums::SHARED_LIBRARY ||
|
||||
@@ -516,21 +516,6 @@ void cmMakefileTargetGenerator::WriteObjectBuildFile(
|
||||
targetFullPathPDB += "/";
|
||||
targetFullPathPDB += this->GeneratorTarget->GetPDBName(this->ConfigName);
|
||||
}
|
||||
if (this->GeneratorTarget->GetType() <= cmStateEnums::OBJECT_LIBRARY) {
|
||||
targetFullPathCompilePDB =
|
||||
this->GeneratorTarget->GetCompilePDBPath(this->ConfigName);
|
||||
if (targetFullPathCompilePDB.empty()) {
|
||||
// Match VS default: `$(IntDir)vc$(PlatformToolsetVersion).pdb`.
|
||||
// A trailing slash tells the toolchain to add its default file name.
|
||||
targetFullPathCompilePDB =
|
||||
this->GeneratorTarget->GetSupportDirectory() + "/";
|
||||
if (this->GeneratorTarget->GetType() == cmStateEnums::STATIC_LIBRARY) {
|
||||
// Match VS default for static libs: `$(IntDir)$(ProjectName).pdb`.
|
||||
targetFullPathCompilePDB += this->GeneratorTarget->GetName();
|
||||
targetFullPathCompilePDB += ".pdb";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
targetOutPathReal = this->LocalGenerator->ConvertToOutputFormat(
|
||||
this->LocalGenerator->MaybeConvertToRelativePath(
|
||||
|
||||
@@ -346,7 +346,7 @@ bool cmNinjaTargetGenerator::SetMsvcTargetPdbVariable(cmNinjaVars& vars) const
|
||||
if (mf->GetDefinition("MSVC_C_ARCHITECTURE_ID") ||
|
||||
mf->GetDefinition("MSVC_CXX_ARCHITECTURE_ID")) {
|
||||
std::string pdbPath;
|
||||
std::string compilePdbPath;
|
||||
std::string compilePdbPath = this->ComputeTargetCompilePDB();
|
||||
if (this->GeneratorTarget->GetType() == cmStateEnums::EXECUTABLE ||
|
||||
this->GeneratorTarget->GetType() == cmStateEnums::STATIC_LIBRARY ||
|
||||
this->GeneratorTarget->GetType() == cmStateEnums::SHARED_LIBRARY ||
|
||||
@@ -355,20 +355,6 @@ bool cmNinjaTargetGenerator::SetMsvcTargetPdbVariable(cmNinjaVars& vars) const
|
||||
pdbPath += "/";
|
||||
pdbPath += this->GeneratorTarget->GetPDBName(this->GetConfigName());
|
||||
}
|
||||
if (this->GeneratorTarget->GetType() <= cmStateEnums::OBJECT_LIBRARY) {
|
||||
compilePdbPath =
|
||||
this->GeneratorTarget->GetCompilePDBPath(this->GetConfigName());
|
||||
if (compilePdbPath.empty()) {
|
||||
// Match VS default: `$(IntDir)vc$(PlatformToolsetVersion).pdb`.
|
||||
// A trailing slash tells the toolchain to add its default file name.
|
||||
compilePdbPath = this->GeneratorTarget->GetSupportDirectory() + "/";
|
||||
if (this->GeneratorTarget->GetType() == cmStateEnums::STATIC_LIBRARY) {
|
||||
// Match VS default for static libs: `$(IntDir)$(ProjectName).pdb`.
|
||||
compilePdbPath += this->GeneratorTarget->GetName();
|
||||
compilePdbPath += ".pdb";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
vars["TARGET_PDB"] = this->GetLocalGenerator()->ConvertToOutputFormat(
|
||||
ConvertToNinjaPath(pdbPath), cmOutputConverter::SHELL);
|
||||
|
||||
Reference in New Issue
Block a user