From 3a5bdaa21319665405104964562dd471aee7cb48 Mon Sep 17 00:00:00 2001 From: Brad King Date: Wed, 30 Apr 2008 18:04:48 -0400 Subject: ENH: When preserving potentially static portions of original user link lines recognize shared library names by their extension and skip them. --- Source/cmComputeLinkDepends.cxx | 16 ++++++++++++++-- Source/cmComputeLinkDepends.h | 5 +++++ Source/cmComputeLinkInformation.cxx | 5 ++++- Source/cmComputeLinkInformation.h | 1 + 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 +#include #include @@ -198,6 +199,12 @@ void cmComputeLinkDepends::SetOldLinkDirMode(bool b) } //---------------------------------------------------------------------------- +void cmComputeLinkDepends::SetSharedRegex(std::string const& regex) +{ + this->SharedRegexString = regex; +} + +//---------------------------------------------------------------------------- std::vector 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::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 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 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 const& exts); -- cgit v0.12