From a45fed81e5fd5d9b280c8dd70d50c9606a982a0b Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Tue, 4 Aug 2015 19:19:45 +0200 Subject: [PATCH] cmGeneratorTarget: Move GetCompilePDBPath from cmTarget. --- Source/cmGeneratorTarget.cxx | 45 ++++++++++++++++++++++ Source/cmGeneratorTarget.h | 6 +++ Source/cmLocalVisualStudio7Generator.cxx | 2 +- Source/cmMakefileTargetGenerator.cxx | 2 +- Source/cmNinjaTargetGenerator.cxx | 3 +- Source/cmTarget.cxx | 43 --------------------- Source/cmTarget.h | 6 --- Source/cmVisualStudio10TargetGenerator.cxx | 3 +- 8 files changed, 57 insertions(+), 53 deletions(-) diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index 2b3ebee9d..a125e474d 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -656,6 +656,51 @@ void cmGeneratorTarget::GetSourceFiles(std::vector &files, this->Target->GetSourceFiles(files, config); } +//---------------------------------------------------------------------------- +std::string +cmGeneratorTarget::GetCompilePDBName(const std::string& config) const +{ + std::string prefix; + std::string base; + std::string suffix; + this->Target->GetFullNameInternal(config, false, prefix, base, suffix); + + // Check for a per-configuration output directory target property. + std::string configUpper = cmSystemTools::UpperCase(config); + std::string configProp = "COMPILE_PDB_NAME_"; + configProp += configUpper; + const char* config_name = this->Target->GetProperty(configProp); + if(config_name && *config_name) + { + return prefix + config_name + ".pdb"; + } + + const char* name = this->Target->GetProperty("COMPILE_PDB_NAME"); + if(name && *name) + { + return prefix + name + ".pdb"; + } + + return ""; +} + +//---------------------------------------------------------------------------- +std::string +cmGeneratorTarget::GetCompilePDBPath(const std::string& config) const +{ + std::string dir = this->Target->GetCompilePDBDirectory(config); + std::string name = this->GetCompilePDBName(config); + if(dir.empty() && !name.empty()) + { + dir = this->Target->GetPDBDirectory(config); + } + if(!dir.empty()) + { + dir += "/"; + } + return dir + name; +} + //---------------------------------------------------------------------------- bool cmGeneratorTarget::HasSOName(const std::string& config) const { diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h index 925426544..9cdfd0080 100644 --- a/Source/cmGeneratorTarget.h +++ b/Source/cmGeneratorTarget.h @@ -163,6 +163,12 @@ public: /** Whether this library has soname enabled and platform supports it. */ bool HasSOName(const std::string& config) const; + /** Get the name of the compiler pdb file for the target. */ + std::string GetCompilePDBName(const std::string& config="") const; + + /** Get the path for the MSVC /Fd option for this target. */ + std::string GetCompilePDBPath(const std::string& config="") const; + /** * Flags for a given source file as used in this target. Typically assigned * via SET_TARGET_PROPERTIES when the property is a list of source files. diff --git a/Source/cmLocalVisualStudio7Generator.cxx b/Source/cmLocalVisualStudio7Generator.cxx index dd4cd33f8..799bac6cc 100644 --- a/Source/cmLocalVisualStudio7Generator.cxx +++ b/Source/cmLocalVisualStudio7Generator.cxx @@ -881,7 +881,7 @@ void cmLocalVisualStudio7Generator::WriteConfiguration(std::ostream& fout, if(target.GetType() <= cmTarget::OBJECT_LIBRARY) { // Specify the compiler program database file if configured. - std::string pdb = target.GetCompilePDBPath(configName); + std::string pdb = gt->GetCompilePDBPath(configName); if(!pdb.empty()) { fout << "\t\t\t\tProgramDataBaseFileName=\"" diff --git a/Source/cmMakefileTargetGenerator.cxx b/Source/cmMakefileTargetGenerator.cxx index ac8cd2995..f9125fc34 100644 --- a/Source/cmMakefileTargetGenerator.cxx +++ b/Source/cmMakefileTargetGenerator.cxx @@ -553,7 +553,7 @@ cmMakefileTargetGenerator if(this->Target->GetType() <= cmTarget::OBJECT_LIBRARY) { targetFullPathCompilePDB = - this->Target->GetCompilePDBPath(this->ConfigName); + this->GeneratorTarget->GetCompilePDBPath(this->ConfigName); if(targetFullPathCompilePDB.empty()) { targetFullPathCompilePDB = this->Target->GetSupportDirectory() + "/"; diff --git a/Source/cmNinjaTargetGenerator.cxx b/Source/cmNinjaTargetGenerator.cxx index cf80424d1..e61ba6fe1 100644 --- a/Source/cmNinjaTargetGenerator.cxx +++ b/Source/cmNinjaTargetGenerator.cxx @@ -277,7 +277,8 @@ bool cmNinjaTargetGenerator::SetMsvcTargetPdbVariable(cmNinjaVars& vars) const } if(this->Target->GetType() <= cmTarget::OBJECT_LIBRARY) { - compilePdbPath = this->Target->GetCompilePDBPath(this->GetConfigName()); + compilePdbPath = + this->GeneratorTarget->GetCompilePDBPath(this->GetConfigName()); if(compilePdbPath.empty()) { compilePdbPath = this->Target->GetSupportDirectory() + "/"; diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index e1b3e9481..188ad0f25 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -3491,49 +3491,6 @@ std::string cmTarget::GetPDBName(const std::string& config) const return prefix+base+".pdb"; } -//---------------------------------------------------------------------------- -std::string cmTarget::GetCompilePDBName(const std::string& config) const -{ - std::string prefix; - std::string base; - std::string suffix; - this->GetFullNameInternal(config, false, prefix, base, suffix); - - // Check for a per-configuration output directory target property. - std::string configUpper = cmSystemTools::UpperCase(config); - std::string configProp = "COMPILE_PDB_NAME_"; - configProp += configUpper; - const char* config_name = this->GetProperty(configProp); - if(config_name && *config_name) - { - return prefix + config_name + ".pdb"; - } - - const char* name = this->GetProperty("COMPILE_PDB_NAME"); - if(name && *name) - { - return prefix + name + ".pdb"; - } - - return ""; -} - -//---------------------------------------------------------------------------- -std::string cmTarget::GetCompilePDBPath(const std::string& config) const -{ - std::string dir = this->GetCompilePDBDirectory(config); - std::string name = this->GetCompilePDBName(config); - if(dir.empty() && !name.empty()) - { - dir = this->GetPDBDirectory(config); - } - if(!dir.empty()) - { - dir += "/"; - } - return dir + name; -} - //---------------------------------------------------------------------------- bool cmTarget::HasMacOSXRpathInstallNameDir(const std::string& config) const { diff --git a/Source/cmTarget.h b/Source/cmTarget.h index e89a212b6..162033cb5 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -380,12 +380,6 @@ public: /** Get the name of the pdb file for the target. */ std::string GetPDBName(const std::string& config) const; - /** Get the name of the compiler pdb file for the target. */ - std::string GetCompilePDBName(const std::string& config="") const; - - /** Get the path for the MSVC /Fd option for this target. */ - std::string GetCompilePDBPath(const std::string& config="") const; - /** Whether this library has \@rpath and platform supports it. */ bool HasMacOSXRpathInstallNameDir(const std::string& config) const; diff --git a/Source/cmVisualStudio10TargetGenerator.cxx b/Source/cmVisualStudio10TargetGenerator.cxx index 83775a5ad..16edf3c39 100644 --- a/Source/cmVisualStudio10TargetGenerator.cxx +++ b/Source/cmVisualStudio10TargetGenerator.cxx @@ -2026,7 +2026,8 @@ void cmVisualStudio10TargetGenerator::WriteClOptions( } // Specify the compiler program database file if configured. - std::string pdb = this->Target->GetCompilePDBPath(configName.c_str()); + std::string pdb = + this->GeneratorTarget->GetCompilePDBPath(configName.c_str()); if(!pdb.empty()) { this->ConvertToWindowsSlash(pdb);