cmGeneratorTarget: Move HasImplibGNUtoMS from cmTarget.

This commit is contained in:
Stephen Kelly 2015-10-09 23:50:36 +02:00
parent a143d4ac60
commit 8d2e3e53b9
9 changed files with 37 additions and 36 deletions

View File

@ -217,7 +217,7 @@ cmExportBuildFileGenerator
std::string prop = "IMPORTED_IMPLIB";
prop += suffix;
std::string value = target->GetFullPath(config, true);
target->Target->GetImplibGNUtoMS(value, value,
target->GetImplibGNUtoMS(value, value,
"${CMAKE_IMPORT_LIBRARY_SUFFIX}");
properties[prop] = value;
}

View File

@ -5483,3 +5483,24 @@ cmGeneratorTarget::GetPDBDirectory(const std::string& config) const
}
return "";
}
//----------------------------------------------------------------------------
bool cmGeneratorTarget::HasImplibGNUtoMS() const
{
return this->Target->HasImportLibrary()
&& this->GetPropertyAsBool("GNUtoMS");
}
//----------------------------------------------------------------------------
bool cmGeneratorTarget::GetImplibGNUtoMS(std::string const& gnuName,
std::string& out, const char* newExt) const
{
if(this->HasImplibGNUtoMS() &&
gnuName.size() > 6 && gnuName.substr(gnuName.size()-6) == ".dll.a")
{
out = gnuName.substr(0, gnuName.size()-6);
out += newExt? newExt : ".lib";
return true;
}
return false;
}

View File

@ -390,6 +390,14 @@ public:
///! Return the preferred linker language for this target
std::string GetLinkerLanguage(const std::string& config = "") const;
/** Does this target have a GNU implib to convert to MS format? */
bool HasImplibGNUtoMS() const;
/** Convert the given GNU import library name (.dll.a) to a name with a new
extension (.lib or ${CMAKE_IMPORT_LIBRARY_SUFFIX}). */
bool GetImplibGNUtoMS(std::string const& gnuName, std::string& out,
const char* newExt = 0) const;
struct SourceFileFlags
GetTargetSourceFileFlags(const cmSourceFile* sf) const;

View File

@ -135,7 +135,7 @@ void cmInstallTargetGenerator::GenerateScriptForConfig(std::ostream& os,
filesFrom.push_back(from1);
filesTo.push_back(to1);
std::string targetNameImportLib;
if(this->Target->Target->GetImplibGNUtoMS(targetNameImport,
if(this->Target->GetImplibGNUtoMS(targetNameImport,
targetNameImportLib))
{
filesFrom.push_back(fromDirConfig + targetNameImportLib);
@ -199,7 +199,7 @@ void cmInstallTargetGenerator::GenerateScriptForConfig(std::ostream& os,
filesFrom.push_back(from1);
filesTo.push_back(to1);
std::string targetNameImportLib;
if(this->Target->Target->GetImplibGNUtoMS(targetNameImport,
if(this->Target->GetImplibGNUtoMS(targetNameImport,
targetNameImportLib))
{
filesFrom.push_back(fromDirConfig + targetNameImportLib);
@ -387,7 +387,7 @@ cmInstallTargetGenerator::GetInstallFilename(cmTarget const* target,
if(nameType == NameImplib)
{
// Use the import library name.
if(!target->GetImplibGNUtoMS(targetNameImport, fname,
if(!gtgt->GetImplibGNUtoMS(targetNameImport, fname,
"${CMAKE_IMPORT_LIBRARY_SUFFIX}"))
{
fname = targetNameImport;
@ -416,7 +416,7 @@ cmInstallTargetGenerator::GetInstallFilename(cmTarget const* target,
if(nameType == NameImplib)
{
// Use the import library name.
if(!target->GetImplibGNUtoMS(targetNameImport, fname,
if(!gtgt->GetImplibGNUtoMS(targetNameImport, fname,
"${CMAKE_IMPORT_LIBRARY_SUFFIX}"))
{
fname = targetNameImport;

View File

@ -259,7 +259,7 @@ void cmMakefileExecutableTargetGenerator::WriteExecutableRule(bool relink)
cmLocalGenerator::START_OUTPUT,
cmLocalGenerator::UNCHANGED));
std::string implib;
if(this->Target->GetImplibGNUtoMS(targetFullPathImport, implib))
if(this->GeneratorTarget->GetImplibGNUtoMS(targetFullPathImport, implib))
{
exeCleanFiles.push_back(this->Convert(implib,
cmLocalGenerator::START_OUTPUT,

View File

@ -410,7 +410,7 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules
cmLocalGenerator::START_OUTPUT,
cmLocalGenerator::UNCHANGED));
std::string implib;
if(this->Target->GetImplibGNUtoMS(targetFullPathImport, implib))
if(this->GeneratorTarget->GetImplibGNUtoMS(targetFullPathImport, implib))
{
libCleanFiles.push_back(this->Convert(implib,
cmLocalGenerator::START_OUTPUT,

View File

@ -1517,7 +1517,7 @@ std::string cmMakefileTargetGenerator::GetLinkRule(
const std::string& linkRuleVar)
{
std::string linkRule = this->Makefile->GetRequiredDefinition(linkRuleVar);
if(this->Target->HasImplibGNUtoMS())
if(this->GeneratorTarget->HasImplibGNUtoMS())
{
std::string ruleVar = "CMAKE_";
ruleVar += this->GeneratorTarget->GetLinkerLanguage(this->ConfigName);

View File

@ -2198,26 +2198,6 @@ void cmTarget::ComputeVersionedName(std::string& vName,
vName += this->IsApple? suffix : std::string();
}
//----------------------------------------------------------------------------
bool cmTarget::HasImplibGNUtoMS() const
{
return this->HasImportLibrary() && this->GetPropertyAsBool("GNUtoMS");
}
//----------------------------------------------------------------------------
bool cmTarget::GetImplibGNUtoMS(std::string const& gnuName,
std::string& out, const char* newExt) const
{
if(this->HasImplibGNUtoMS() &&
gnuName.size() > 6 && gnuName.substr(gnuName.size()-6) == ".dll.a")
{
out = gnuName.substr(0, gnuName.size()-6);
out += newExt? newExt : ".lib";
return true;
}
return false;
}
//----------------------------------------------------------------------------
void cmTarget::SetPropertyDefault(const std::string& property,
const char* default_value)

View File

@ -240,14 +240,6 @@ public:
void
GetTargetVersion(bool soversion, int& major, int& minor, int& patch) const;
/** Does this target have a GNU implib to convert to MS format? */
bool HasImplibGNUtoMS() const;
/** Convert the given GNU import library name (.dll.a) to a name with a new
extension (.lib or ${CMAKE_IMPORT_LIBRARY_SUFFIX}). */
bool GetImplibGNUtoMS(std::string const& gnuName, std::string& out,
const char* newExt = 0) const;
// Get the properties
cmPropertyMap &GetProperties() const { return this->Properties; }