summaryrefslogtreecommitdiffstats
path: root/Source
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2008-04-30 22:04:48 (GMT)
committerBrad King <brad.king@kitware.com>2008-04-30 22:04:48 (GMT)
commit3a5bdaa21319665405104964562dd471aee7cb48 (patch)
tree935e1dea807312fc591a429f340dc3efe744c944 /Source
parent9631c499dc31ea1aba70201afc1a565b84c33620 (diff)
downloadCMake-3a5bdaa21319665405104964562dd471aee7cb48.zip
CMake-3a5bdaa21319665405104964562dd471aee7cb48.tar.gz
CMake-3a5bdaa21319665405104964562dd471aee7cb48.tar.bz2
ENH: When preserving potentially static portions of original user link lines recognize shared library names by their extension and skip them.
Diffstat (limited to 'Source')
-rw-r--r--Source/cmComputeLinkDepends.cxx16
-rw-r--r--Source/cmComputeLinkDepends.h5
-rw-r--r--Source/cmComputeLinkInformation.cxx5
-rw-r--r--Source/cmComputeLinkInformation.h1
4 files changed, 24 insertions, 3 deletions
diff --git a/Source/cmComputeLinkDepends.cxx b/Source/cmComputeLinkDepends.cxx
index 72dd198..305c06d 100644
--- a/Source/cmComputeLinkDepends.cxx
+++ b/Source/cmComputeLinkDepends.cxx
@@ -24,6 +24,7 @@
#include "cmake.h"
#include <cmsys/stl/algorithm>
+#include <cmsys/RegularExpression.hxx>
#include <assert.h>
@@ -198,6 +199,12 @@ void cmComputeLinkDepends::SetOldLinkDirMode(bool b)
}
//----------------------------------------------------------------------------
+void cmComputeLinkDepends::SetSharedRegex(std::string const& regex)
+{
+ this->SharedRegexString = regex;
+}
+
+//----------------------------------------------------------------------------
std::vector<cmComputeLinkDepends::LinkEntry> const&
cmComputeLinkDepends::Compute()
{
@@ -874,6 +881,9 @@ void cmComputeLinkDepends::CheckWrongConfigItem(std::string const& item)
//----------------------------------------------------------------------------
void cmComputeLinkDepends::PreserveOriginalEntries()
{
+ // Regular expression to match shared libraries.
+ cmsys::RegularExpression shared_lib(this->SharedRegexString.c_str());
+
// Skip the part of the input sequence that already appears in the
// output.
std::vector<int>::const_iterator in = this->OriginalEntries.begin();
@@ -882,7 +892,8 @@ void cmComputeLinkDepends::PreserveOriginalEntries()
out != this->FinalLinkOrder.end())
{
cmTarget* tgt = this->EntryList[*in].Target;
- if(tgt && tgt->GetType() != cmTarget::STATIC_LIBRARY)
+ if((tgt && tgt->GetType() != cmTarget::STATIC_LIBRARY) ||
+ (!tgt && shared_lib.find(this->EntryList[*in].Item)))
{
// Skip input items known to not be static libraries.
++in;
@@ -905,7 +916,8 @@ void cmComputeLinkDepends::PreserveOriginalEntries()
while(in != this->OriginalEntries.end())
{
cmTarget* tgt = this->EntryList[*in].Target;
- if(tgt && tgt->GetType() != cmTarget::STATIC_LIBRARY)
+ if((tgt && tgt->GetType() != cmTarget::STATIC_LIBRARY) ||
+ (!tgt && shared_lib.find(this->EntryList[*in].Item)))
{
// Skip input items known to not be static libraries.
++in;
diff --git a/Source/cmComputeLinkDepends.h b/Source/cmComputeLinkDepends.h
index 3e42580..1b2809b 100644
--- a/Source/cmComputeLinkDepends.h
+++ b/Source/cmComputeLinkDepends.h
@@ -58,6 +58,10 @@ public:
std::set<cmTarget*> const& GetOldWrongConfigItems() const
{ return this->OldWrongConfigItems; }
+ /** Set a regular expression that matches strings ending in a shared
+ library extension. */
+ void SetSharedRegex(std::string const& regex);
+
private:
// Context information.
@@ -137,6 +141,7 @@ private:
// Preservation of original link line.
std::vector<int> OriginalEntries;
void PreserveOriginalEntries();
+ std::string SharedRegexString;
// Compatibility help.
bool OldLinkDirMode;
diff --git a/Source/cmComputeLinkInformation.cxx b/Source/cmComputeLinkInformation.cxx
index 5e10537..b133e35 100644
--- a/Source/cmComputeLinkInformation.cxx
+++ b/Source/cmComputeLinkInformation.cxx
@@ -511,6 +511,7 @@ bool cmComputeLinkInformation::Compute()
// Compute the ordered link line items.
cmComputeLinkDepends cld(this->Target, this->Config);
cld.SetOldLinkDirMode(this->OldLinkDirMode);
+ cld.SetSharedRegex(this->SharedRegexString);
cmComputeLinkDepends::EntryVector const& linkEntries = cld.Compute();
// Add the link line items.
@@ -864,7 +865,9 @@ void cmComputeLinkInformation::ComputeItemParserInfo()
if(!this->SharedLinkExtensions.empty())
{
std::string reg_shared = reg;
- reg_shared += this->CreateExtensionRegex(this->SharedLinkExtensions);
+ this->SharedRegexString =
+ this->CreateExtensionRegex(this->SharedLinkExtensions);
+ reg_shared += this->SharedRegexString;
#ifdef CM_COMPUTE_LINK_INFO_DEBUG
fprintf(stderr, "shared regex [%s]\n", reg_shared.c_str());
#endif
diff --git a/Source/cmComputeLinkInformation.h b/Source/cmComputeLinkInformation.h
index 31d0e33..0ac0afc 100644
--- a/Source/cmComputeLinkInformation.h
+++ b/Source/cmComputeLinkInformation.h
@@ -129,6 +129,7 @@ private:
cmsys::RegularExpression ExtractStaticLibraryName;
cmsys::RegularExpression ExtractSharedLibraryName;
cmsys::RegularExpression ExtractAnyLibraryName;
+ std::string SharedRegexString;
void AddLinkPrefix(const char* p);
void AddLinkExtension(const char* e, LinkType type);
std::string CreateExtensionRegex(std::vector<std::string> const& exts);