diff options
author | Brad King <brad.king@kitware.com> | 2008-02-13 15:29:55 -0500 |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2008-02-13 15:29:55 -0500 |
commit | 98621ecfaa4794cf934011205ca1d9832600f14d (patch) | |
tree | de4fc9b08ac939bf87974058cebf9d06bd5b950c /Source | |
parent | ad95a57509380ba9050379a76dec305f4957eab7 (diff) | |
download | cmake-98621ecfaa4794cf934011205ca1d9832600f14d.tar.gz |
BUG: Update cmComputeLinkDepends to support leading/trailing whitespace stripping off link items for compatibility.
Diffstat (limited to 'Source')
-rw-r--r-- | Source/cmComputeLinkDepends.cxx | 37 | ||||
-rw-r--r-- | Source/cmComputeLinkDepends.h | 1 |
2 files changed, 36 insertions, 2 deletions
diff --git a/Source/cmComputeLinkDepends.cxx b/Source/cmComputeLinkDepends.cxx index 29164a2f8c..391b991692 100644 --- a/Source/cmComputeLinkDepends.cxx +++ b/Source/cmComputeLinkDepends.cxx @@ -510,13 +510,14 @@ cmComputeLinkDepends::AddLinkEntries(int depender_index, { // Skip entries that will resolve to the target getting linked or // are empty. - if(*li == this->Target->GetName() || li->empty()) + std::string item = this->CleanItemName(*li); + if(item == this->Target->GetName() || item.empty()) { continue; } // Add a link entry for this item. - int dependee_index = this->AddLinkEntry(*li); + int dependee_index = this->AddLinkEntry(item); // The depender must come before the dependee. if(depender_index >= 0) @@ -551,6 +552,38 @@ cmComputeLinkDepends::AddLinkEntries(int depender_index, } //---------------------------------------------------------------------------- +std::string cmComputeLinkDepends::CleanItemName(std::string const& item) +{ + // Strip whitespace off the library names because we used to do this + // in case variables were expanded at generate time. We no longer + // do the expansion but users link to libraries like " ${VAR} ". + std::string lib = item; + std::string::size_type pos = lib.find_first_not_of(" \t\r\n"); + if(pos != lib.npos) + { + lib = lib.substr(pos, lib.npos); + } + pos = lib.find_last_not_of(" \t\r\n"); + if(pos != lib.npos) + { + lib = lib.substr(0, pos+1); + } + if(lib != item && !this->Makefile->NeedBackwardsCompatibility(2,4)) + { + cmOStringStream e; + e << "Target \"" << this->Target->GetName() << "\" links to item \"" + << item << "\" which has leading or trailing whitespace. " + << "CMake is stripping off the whitespace but this may not be " + << "supported in the future. " + << "Update the CMakeLists.txt files to avoid adding the whitespace. " + << "Set CMAKE_BACKWARDS_COMPATIBILITY to 2.4 or lower to disable this " + << "warning."; + cmSystemTools::Message(e.str().c_str()); + } + return lib; +} + +//---------------------------------------------------------------------------- void cmComputeLinkDepends::InferDependencies() { // The inferred dependency sets for each item list the possible diff --git a/Source/cmComputeLinkDepends.h b/Source/cmComputeLinkDepends.h index b81f8bcc4d..c20890904a 100644 --- a/Source/cmComputeLinkDepends.h +++ b/Source/cmComputeLinkDepends.h @@ -78,6 +78,7 @@ private: LinkLibraryVectorType const& libs); void AddLinkEntries(int depender_index, std::vector<std::string> const& libs); + std::string CleanItemName(std::string const& item); // One entry for each unique item. std::vector<LinkEntry> EntryList; |