diff options
author | Brad King <brad.king@kitware.com> | 2015-12-01 16:00:49 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2015-12-01 16:00:49 (GMT) |
commit | 7b13759d5f030064fb9715f7a94194fd27aa55b0 (patch) | |
tree | b056f65d9085819ab081bd9b50b455cf3b14d62c | |
parent | f8deadc16d03233ecb92b4d05a9e9f0d6c9f56aa (diff) | |
parent | 4e3cf8b012404e4d9602c16d473480cc3d0c7928 (diff) | |
download | CMake-7b13759d5f030064fb9715f7a94194fd27aa55b0.zip CMake-7b13759d5f030064fb9715f7a94194fd27aa55b0.tar.gz CMake-7b13759d5f030064fb9715f7a94194fd27aa55b0.tar.bz2 |
Merge branch 'reduce-realpath-calls' into release
-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 35ee127..e3406a8 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->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; }; |