cmGeneratorTarget: Move GetLibraryNames from cmTarget.

This commit is contained in:
Stephen Kelly 2015-08-04 19:19:45 +02:00
parent 47803e6f8e
commit 766839c56d
9 changed files with 107 additions and 109 deletions

View File

@ -693,8 +693,8 @@ std::string cmGeneratorTarget::GetSOName(const std::string& config) const
std::string realName;
std::string impName;
std::string pdbName;
this->Target->GetLibraryNames(name, soName, realName,
impName, pdbName, config);
this->GetLibraryNames(name, soName, realName,
impName, pdbName, config);
return soName;
}
}
@ -1254,7 +1254,7 @@ void cmGeneratorTarget::GenerateTargetManifest(
this->GetType() == cmTarget::SHARED_LIBRARY ||
this->GetType() == cmTarget::MODULE_LIBRARY)
{
this->Target->GetLibraryNames(name, soName, realName, impName, pdbName,
this->GetLibraryNames(name, soName, realName, impName, pdbName,
config);
}
else
@ -1378,12 +1378,99 @@ cmGeneratorTarget::NormalGetRealName(const std::string& config) const
std::string realName;
std::string impName;
std::string pdbName;
this->Target->GetLibraryNames(name, soName, realName,
impName, pdbName, config);
this->GetLibraryNames(name, soName, realName,
impName, pdbName, config);
return realName;
}
}
//----------------------------------------------------------------------------
void cmGeneratorTarget::GetLibraryNames(std::string& name,
std::string& soName,
std::string& realName,
std::string& impName,
std::string& pdbName,
const std::string& config) const
{
// This should not be called for imported targets.
// TODO: Split cmTarget into a class hierarchy to get compile-time
// enforcement of the limited imported target API.
if(this->Target->IsImported())
{
std::string msg = "GetLibraryNames called on imported target: ";
msg += this->GetName();
this->LocalGenerator->IssueMessage(cmake::INTERNAL_ERROR,
msg);
return;
}
// Check for library version properties.
const char* version = this->GetProperty("VERSION");
const char* soversion = this->GetProperty("SOVERSION");
if(!this->Target->HasSOName(config) ||
this->Target->IsFrameworkOnApple())
{
// Versioning is supported only for shared libraries and modules,
// and then only when the platform supports an soname flag.
version = 0;
soversion = 0;
}
if(version && !soversion)
{
// The soversion must be set if the library version is set. Use
// the library version as the soversion.
soversion = version;
}
if(!version && soversion)
{
// Use the soversion as the library version.
version = soversion;
}
// Get the components of the library name.
std::string prefix;
std::string base;
std::string suffix;
this->Target->GetFullNameInternal(config, false, prefix, base, suffix);
// The library name.
name = prefix+base+suffix;
if(this->Target->IsFrameworkOnApple())
{
realName = prefix;
realName += "Versions/";
realName += this->Target->GetFrameworkVersion();
realName += "/";
realName += base;
soName = realName;
}
else
{
// The library's soname.
this->Target->ComputeVersionedName(soName, prefix, base, suffix,
name, soversion);
// The library's real name on disk.
this->Target->ComputeVersionedName(realName, prefix, base, suffix,
name, version);
}
// The import library name.
if(this->GetType() == cmTarget::SHARED_LIBRARY ||
this->GetType() == cmTarget::MODULE_LIBRARY)
{
impName = this->Target->GetFullNameInternal(config, true);
}
else
{
impName = "";
}
// The program database file name.
pdbName = this->Target->GetPDBName(config);
}
//----------------------------------------------------------------------------
void cmGeneratorTarget::GetExecutableNames(std::string& name,
std::string& realName,
@ -1446,7 +1533,6 @@ void cmGeneratorTarget::GetExecutableNames(std::string& name,
pdbName = this->Target->GetPDBName(config);
}
bool cmStrictTargetComparison::operator()(cmTarget const* t1,
cmTarget const* t2) const
{

View File

@ -191,6 +191,13 @@ public:
std::string& impName, std::string& pdbName,
const std::string& config) const;
/** Get the names of the library needed to generate a build rule
that takes into account shared library version numbers. This
should be called only on a library target. */
void GetLibraryNames(std::string& name, std::string& soName,
std::string& realName, std::string& impName,
std::string& pdbName, const std::string& config) const;
struct SourceFileFlags
GetTargetSourceFileFlags(const cmSourceFile* sf) const;

View File

@ -185,7 +185,7 @@ void cmInstallTargetGenerator::GenerateScriptForConfig(std::ostream& os,
std::string targetNameReal;
std::string targetNameImport;
std::string targetNamePDB;
this->Target->Target->GetLibraryNames(targetName, targetNameSO,
this->Target->GetLibraryNames(targetName, targetNameSO,
targetNameReal,
targetNameImport, targetNamePDB,
config);
@ -411,7 +411,7 @@ cmInstallTargetGenerator::GetInstallFilename(cmTarget const* target,
std::string targetNameReal;
std::string targetNameImport;
std::string targetNamePDB;
target->GetLibraryNames(targetName, targetNameSO, targetNameReal,
gtgt->GetLibraryNames(targetName, targetNameSO, targetNameReal,
targetNameImport, targetNamePDB, config);
if(nameType == NameImplib)
{

View File

@ -1147,7 +1147,7 @@ void cmLocalVisualStudio7Generator::OutputBuildTool(std::ostream& fout,
std::string targetNameFull;
std::string targetNameImport;
std::string targetNamePDB;
target.GetLibraryNames(targetName, targetNameSO, targetNameFull,
gt->GetLibraryNames(targetName, targetNameSO, targetNameFull,
targetNameImport, targetNamePDB, configName);
// Compute the link library and directory information.

View File

@ -28,7 +28,7 @@ cmMakefileLibraryTargetGenerator
this->CustomCommandDriver = OnDepends;
if (this->Target->GetType() != cmTarget::INTERFACE_LIBRARY)
{
this->Target->GetLibraryNames(
this->GeneratorTarget->GetLibraryNames(
this->TargetNameOut, this->TargetNameSO, this->TargetNameReal,
this->TargetNameImport, this->TargetNamePDB, this->ConfigName);
}
@ -266,7 +266,7 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules
std::string targetNameReal;
std::string targetNameImport;
std::string targetNamePDB;
this->Target->GetLibraryNames(
this->GeneratorTarget->GetLibraryNames(
targetName, targetNameSO, targetNameReal, targetNameImport, targetNamePDB,
this->ConfigName);

View File

@ -49,7 +49,7 @@ cmNinjaNormalTargetGenerator(cmGeneratorTarget* target)
this->TargetNamePDB,
GetLocalGenerator()->GetConfigName());
else
target->Target->GetLibraryNames(this->TargetNameOut,
this->GetGeneratorTarget()->GetLibraryNames(this->TargetNameOut,
this->TargetNameSO,
this->TargetNameReal,
this->TargetNameImport,

View File

@ -3861,95 +3861,6 @@ void cmTarget::GetFullNameInternal(const std::string& config,
outSuffix = targetSuffix?targetSuffix:"";
}
//----------------------------------------------------------------------------
void cmTarget::GetLibraryNames(std::string& name,
std::string& soName,
std::string& realName,
std::string& impName,
std::string& pdbName,
const std::string& config) const
{
// This should not be called for imported targets.
// TODO: Split cmTarget into a class hierarchy to get compile-time
// enforcement of the limited imported target API.
if(this->IsImported())
{
std::string msg = "GetLibraryNames called on imported target: ";
msg += this->GetName();
this->Makefile->IssueMessage(cmake::INTERNAL_ERROR,
msg);
return;
}
assert(this->GetType() != INTERFACE_LIBRARY);
// Check for library version properties.
const char* version = this->GetProperty("VERSION");
const char* soversion = this->GetProperty("SOVERSION");
if(!this->HasSOName(config) ||
this->Makefile->IsOn("CMAKE_PLATFORM_NO_VERSIONED_SONAME") ||
this->IsFrameworkOnApple())
{
// Versioning is supported only for shared libraries and modules,
// and then only when the platform supports an soname flag.
version = 0;
soversion = 0;
}
if(version && !soversion)
{
// The soversion must be set if the library version is set. Use
// the library version as the soversion.
soversion = version;
}
if(!version && soversion)
{
// Use the soversion as the library version.
version = soversion;
}
// Get the components of the library name.
std::string prefix;
std::string base;
std::string suffix;
this->GetFullNameInternal(config, false, prefix, base, suffix);
// The library name.
name = prefix+base+suffix;
if(this->IsFrameworkOnApple())
{
realName = prefix;
realName += "Versions/";
realName += this->GetFrameworkVersion();
realName += "/";
realName += base;
soName = realName;
}
else
{
// The library's soname.
this->ComputeVersionedName(soName, prefix, base, suffix,
name, soversion);
// The library's real name on disk.
this->ComputeVersionedName(realName, prefix, base, suffix,
name, version);
}
// The import library name.
if(this->GetType() == cmTarget::SHARED_LIBRARY ||
this->GetType() == cmTarget::MODULE_LIBRARY)
{
impName = this->GetFullNameInternal(config, true);
}
else
{
impName = "";
}
// The program database file name.
pdbName = this->GetPDBName(config);
}
//----------------------------------------------------------------------------
void cmTarget::ComputeVersionedName(std::string& vName,
std::string const& prefix,

View File

@ -399,13 +399,6 @@ public:
no soname at all. */
bool IsImportedSharedLibWithoutSOName(const std::string& config) const;
/** Get the names of the library needed to generate a build rule
that takes into account shared library version numbers. This
should be called only on a library target. */
void GetLibraryNames(std::string& name, std::string& soName,
std::string& realName, std::string& impName,
std::string& pdbName, const std::string& config) const;
/** Does this target have a GNU implib to convert to MS format? */
bool HasImplibGNUtoMS() const;

View File

@ -2477,7 +2477,8 @@ cmVisualStudio10TargetGenerator::ComputeLinkOptions(std::string const& config)
}
else
{
this->Target->GetLibraryNames(targetName, targetNameSO, targetNameFull,
this->GeneratorTarget->GetLibraryNames(targetName, targetNameSO,
targetNameFull,
targetNameImport, targetNamePDB,
config.c_str());
}