cmTarget: Create helper method for versioned library names
Replace the duplicate logic for the realName and soName of versioned shared libraries with calls to a new ComputeVersionedName method.
This commit is contained in:
parent
9401da8084
commit
96f65ba68e
@ -131,6 +131,7 @@ cmTarget::cmTarget()
|
|||||||
this->LinkLibrariesAnalyzed = false;
|
this->LinkLibrariesAnalyzed = false;
|
||||||
this->HaveInstallRule = false;
|
this->HaveInstallRule = false;
|
||||||
this->DLLPlatform = false;
|
this->DLLPlatform = false;
|
||||||
|
this->IsApple = false;
|
||||||
this->IsImportedTarget = false;
|
this->IsImportedTarget = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1207,6 +1208,9 @@ void cmTarget::SetMakefile(cmMakefile* mf)
|
|||||||
this->Makefile->IsOn("CYGWIN") ||
|
this->Makefile->IsOn("CYGWIN") ||
|
||||||
this->Makefile->IsOn("MINGW"));
|
this->Makefile->IsOn("MINGW"));
|
||||||
|
|
||||||
|
// Check whether we are targeting an Apple platform.
|
||||||
|
this->IsApple = this->Makefile->IsOn("APPLE");
|
||||||
|
|
||||||
// Setup default property values.
|
// Setup default property values.
|
||||||
this->SetPropertyDefault("INSTALL_NAME_DIR", "");
|
this->SetPropertyDefault("INSTALL_NAME_DIR", "");
|
||||||
this->SetPropertyDefault("INSTALL_RPATH", "");
|
this->SetPropertyDefault("INSTALL_RPATH", "");
|
||||||
@ -3348,7 +3352,11 @@ void cmTarget::GetLibraryNames(std::string& name,
|
|||||||
// the library version as the soversion.
|
// the library version as the soversion.
|
||||||
soversion = version;
|
soversion = version;
|
||||||
}
|
}
|
||||||
bool isApple = this->Makefile->IsOn("APPLE");
|
if(!version && soversion)
|
||||||
|
{
|
||||||
|
// Use the soversion as the library version.
|
||||||
|
version = soversion;
|
||||||
|
}
|
||||||
|
|
||||||
// Get the components of the library name.
|
// Get the components of the library name.
|
||||||
std::string prefix;
|
std::string prefix;
|
||||||
@ -3360,47 +3368,12 @@ void cmTarget::GetLibraryNames(std::string& name,
|
|||||||
name = prefix+base+suffix;
|
name = prefix+base+suffix;
|
||||||
|
|
||||||
// The library's soname.
|
// The library's soname.
|
||||||
if(isApple)
|
this->ComputeVersionedName(soName, prefix, base, suffix,
|
||||||
{
|
name, soversion);
|
||||||
soName = prefix+base;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
soName = name;
|
|
||||||
}
|
|
||||||
if(soversion)
|
|
||||||
{
|
|
||||||
soName += ".";
|
|
||||||
soName += soversion;
|
|
||||||
}
|
|
||||||
if(isApple)
|
|
||||||
{
|
|
||||||
soName += suffix;
|
|
||||||
}
|
|
||||||
|
|
||||||
// The library's real name on disk.
|
// The library's real name on disk.
|
||||||
if(isApple)
|
this->ComputeVersionedName(realName, prefix, base, suffix,
|
||||||
{
|
name, version);
|
||||||
realName = prefix+base;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
realName = name;
|
|
||||||
}
|
|
||||||
if(version)
|
|
||||||
{
|
|
||||||
realName += ".";
|
|
||||||
realName += version;
|
|
||||||
}
|
|
||||||
else if(soversion)
|
|
||||||
{
|
|
||||||
realName += ".";
|
|
||||||
realName += soversion;
|
|
||||||
}
|
|
||||||
if(isApple)
|
|
||||||
{
|
|
||||||
realName += suffix;
|
|
||||||
}
|
|
||||||
|
|
||||||
// The import library name.
|
// The import library name.
|
||||||
if(this->GetType() == cmTarget::SHARED_LIBRARY ||
|
if(this->GetType() == cmTarget::SHARED_LIBRARY ||
|
||||||
@ -3417,6 +3390,23 @@ void cmTarget::GetLibraryNames(std::string& name,
|
|||||||
pdbName = prefix+base+".pdb";
|
pdbName = prefix+base+".pdb";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//----------------------------------------------------------------------------
|
||||||
|
void cmTarget::ComputeVersionedName(std::string& vName,
|
||||||
|
std::string const& prefix,
|
||||||
|
std::string const& base,
|
||||||
|
std::string const& suffix,
|
||||||
|
std::string const& name,
|
||||||
|
const char* version)
|
||||||
|
{
|
||||||
|
vName = this->IsApple? (prefix+base) : name;
|
||||||
|
if(version)
|
||||||
|
{
|
||||||
|
vName += ".";
|
||||||
|
vName += version;
|
||||||
|
}
|
||||||
|
vName += this->IsApple? suffix : std::string();
|
||||||
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
void cmTarget::GetExecutableNames(std::string& name,
|
void cmTarget::GetExecutableNames(std::string& name,
|
||||||
std::string& realName,
|
std::string& realName,
|
||||||
|
@ -557,6 +557,7 @@ private:
|
|||||||
cmPropertyMap Properties;
|
cmPropertyMap Properties;
|
||||||
LinkLibraryVectorType OriginalLinkLibraries;
|
LinkLibraryVectorType OriginalLinkLibraries;
|
||||||
bool DLLPlatform;
|
bool DLLPlatform;
|
||||||
|
bool IsApple;
|
||||||
bool IsImportedTarget;
|
bool IsImportedTarget;
|
||||||
|
|
||||||
// Cache target output paths for each configuration.
|
// Cache target output paths for each configuration.
|
||||||
@ -595,6 +596,12 @@ private:
|
|||||||
cmTargetInternalPointer Internal;
|
cmTargetInternalPointer Internal;
|
||||||
|
|
||||||
void ConstructSourceFileFlags();
|
void ConstructSourceFileFlags();
|
||||||
|
void ComputeVersionedName(std::string& vName,
|
||||||
|
std::string const& prefix,
|
||||||
|
std::string const& base,
|
||||||
|
std::string const& suffix,
|
||||||
|
std::string const& name,
|
||||||
|
const char* version);
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef std::map<cmStdString,cmTarget> cmTargets;
|
typedef std::map<cmStdString,cmTarget> cmTargets;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user