diff options
author | Brad King <brad.king@kitware.com> | 2015-12-02 13:35:44 (GMT) |
---|---|---|
committer | CMake Topic Stage <kwrobot@kitware.com> | 2015-12-02 13:35:44 (GMT) |
commit | 5257a3b931e3a2edc3fbe262c8215af6e7f5bfd7 (patch) | |
tree | 08c609c79df547b78bfb8fb12e68f4ee0f212b60 | |
parent | 36e6ee913d7ea22060cc45b6a6a7b7e573402b28 (diff) | |
parent | 4e3cf8b012404e4d9602c16d473480cc3d0c7928 (diff) | |
download | CMake-5257a3b931e3a2edc3fbe262c8215af6e7f5bfd7.zip CMake-5257a3b931e3a2edc3fbe262c8215af6e7f5bfd7.tar.gz CMake-5257a3b931e3a2edc3fbe262c8215af6e7f5bfd7.tar.bz2 |
Merge topic 'reduce-realpath-calls'
4e3cf8b0 cmOrderDirectories: Reduce repeat realpath() calls
6b185287 cmOrderDirectories: Factor out directory comparison
-rw-r--r-- | Source/cmOrderDirectories.cxx | 26 | ||||
-rw-r--r-- | Source/cmOrderDirectories.h | 6 |
2 files changed, 28 insertions, 4 deletions
diff --git a/Source/cmOrderDirectories.cxx b/Source/cmOrderDirectories.cxx index e3eedc7..61efd01 100644 --- a/Source/cmOrderDirectories.cxx +++ b/Source/cmOrderDirectories.cxx @@ -73,10 +73,8 @@ public: { // Check if this directory conflicts with the entry. std::string const& dir = this->OD->OriginalDirectories[i]; - if(dir != this->Directory && - cmSystemTools::GetRealPath(dir) != - cmSystemTools::GetRealPath(this->Directory) && - this->FindConflict(dir)) + if (!this->OD->IsSameDirectory(dir, this->Directory) && + this->FindConflict(dir)) { // The library will be found in this directory but this is not // the directory named for it. Add an entry to make sure the @@ -639,3 +637,23 @@ void cmOrderDirectories::DiagnoseCycle() ->IssueMessage(cmake::WARNING, e.str(), this->Target->GetBacktrace()); } + +bool cmOrderDirectories::IsSameDirectory(std::string const& l, + std::string const& r) +{ + return this->GetRealPath(l) == this->GetRealPath(r); +} + +std::string const& cmOrderDirectories::GetRealPath(std::string const& dir) +{ + std::map<std::string, std::string>::iterator i = + this->RealPaths.lower_bound(dir); + if (i == this->RealPaths.end() || + this->RealPaths.key_comp()(dir, i->first)) + { + typedef std::map<std::string, std::string>::value_type value_type; + i = this->RealPaths.insert( + i, value_type(dir, cmSystemTools::GetRealPath(dir))); + } + return i->second; +} diff --git a/Source/cmOrderDirectories.h b/Source/cmOrderDirectories.h index 211c786..477216b 100644 --- a/Source/cmOrderDirectories.h +++ b/Source/cmOrderDirectories.h @@ -80,6 +80,12 @@ private: struct ConflictList: public std::vector<ConflictPair> {}; std::vector<ConflictList> ConflictGraph; + // Compare directories after resolving symlinks. + bool IsSameDirectory(std::string const& l, std::string const& r); + + std::string const& GetRealPath(std::string const& dir); + std::map<std::string, std::string> RealPaths; + friend class cmOrderDirectoriesConstraint; friend class cmOrderDirectoriesConstraintLibrary; }; |