Recognize shared library files with a numerical suffix

When processing link line entries we check for matches with known naming
patterns for static and shared libraries.  Teach this logic to recognize
numerical suffixes after shared library names such as "libfoo.so.1".
This commit is contained in:
Stephen Kelly 2013-04-11 16:55:36 +02:00 committed by Brad King
parent 272431a84f
commit 342fc04010
2 changed files with 12 additions and 5 deletions

View File

@ -882,7 +882,8 @@ void cmComputeLinkInformation::ComputeItemParserInfo()
}
// Compute a regex to match link extensions.
std::string libext = this->CreateExtensionRegex(this->LinkExtensions);
std::string libext = this->CreateExtensionRegex(this->LinkExtensions,
LinkUnknown);
// Create regex to remove any library extension.
std::string reg("(.*)");
@ -916,7 +917,8 @@ void cmComputeLinkInformation::ComputeItemParserInfo()
if(!this->StaticLinkExtensions.empty())
{
std::string reg_static = reg;
reg_static += this->CreateExtensionRegex(this->StaticLinkExtensions);
reg_static += this->CreateExtensionRegex(this->StaticLinkExtensions,
LinkStatic);
#ifdef CM_COMPUTE_LINK_INFO_DEBUG
fprintf(stderr, "static regex [%s]\n", reg_static.c_str());
#endif
@ -928,7 +930,7 @@ void cmComputeLinkInformation::ComputeItemParserInfo()
{
std::string reg_shared = reg;
this->SharedRegexString =
this->CreateExtensionRegex(this->SharedLinkExtensions);
this->CreateExtensionRegex(this->SharedLinkExtensions, LinkShared);
reg_shared += this->SharedRegexString;
#ifdef CM_COMPUTE_LINK_INFO_DEBUG
fprintf(stderr, "shared regex [%s]\n", reg_shared.c_str());
@ -966,7 +968,7 @@ void cmComputeLinkInformation::AddLinkExtension(const char* e, LinkType type)
//----------------------------------------------------------------------------
std::string
cmComputeLinkInformation
::CreateExtensionRegex(std::vector<std::string> const& exts)
::CreateExtensionRegex(std::vector<std::string> const& exts, LinkType type)
{
// Build a list of extension choices.
std::string libext = "(";
@ -995,6 +997,10 @@ cmComputeLinkInformation
{
libext += "(\\.[0-9]+\\.[0-9]+)?";
}
else if(type == LinkShared)
{
libext += "(\\.[0-9]+)?";
}
libext += "$";
return libext;

View File

@ -134,7 +134,8 @@ private:
bool OpenBSD;
void AddLinkPrefix(const char* p);
void AddLinkExtension(const char* e, LinkType type);
std::string CreateExtensionRegex(std::vector<std::string> const& exts);
std::string CreateExtensionRegex(std::vector<std::string> const& exts,
LinkType type);
std::string NoCaseExpression(const char* str);
// Handling of link items.