From b0cd630521658ddf8f8547597ac9c24a725f20e7 Mon Sep 17 00:00:00 2001 From: Brad King Date: Fri, 23 Sep 2011 14:27:25 -0400 Subject: Refactor find_* command final path list computation All find_* commands re-root the list of paths and then add trailing slashes. Factor this pair of calls out into a dedicated method. The new method would be the only caller to AddTrailingSlashes, so subsume that method into it. --- Source/cmFindBase.cxx | 6 +----- Source/cmFindCommon.cxx | 7 ++++++- Source/cmFindCommon.h | 4 ++-- Source/cmFindPackageCommand.cxx | 14 +------------- Source/cmFindPackageCommand.h | 1 - 5 files changed, 10 insertions(+), 22 deletions(-) diff --git a/Source/cmFindBase.cxx b/Source/cmFindBase.cxx index ce9deb1..183da4a 100644 --- a/Source/cmFindBase.cxx +++ b/Source/cmFindBase.cxx @@ -299,11 +299,7 @@ bool cmFindBase::ParseArguments(std::vector const& argsIn) this->GetIgnoredPaths(ignored); this->FilterPaths(this->SearchPaths, ignored); - // Handle search root stuff. - this->RerootPaths(this->SearchPaths); - - // Add a trailing slash to all prefixes to aid the search process. - this->AddTrailingSlashes(this->SearchPaths); + this->ComputeFinalPaths(); return true; } diff --git a/Source/cmFindCommon.cxx b/Source/cmFindCommon.cxx index a05e337..b44864e 100644 --- a/Source/cmFindCommon.cxx +++ b/Source/cmFindCommon.cxx @@ -471,8 +471,13 @@ void cmFindCommon::AddPathInternal(std::string const& in_path, } //---------------------------------------------------------------------------- -void cmFindCommon::AddTrailingSlashes(std::vector& paths) +void cmFindCommon::ComputeFinalPaths() { + std::vector& paths = this->SearchPaths; + + // Expand list of paths inside all search roots. + this->RerootPaths(paths); + // Add a trailing slash to all paths to aid the search process. for(std::vector::iterator i = paths.begin(); i != paths.end(); ++i) diff --git a/Source/cmFindCommon.h b/Source/cmFindCommon.h index 875c223..542805f 100644 --- a/Source/cmFindCommon.h +++ b/Source/cmFindCommon.h @@ -47,8 +47,8 @@ protected: void FilterPaths(std::vector& paths, const std::set& ignore); - /** Add trailing slashes to all search paths. */ - void AddTrailingSlashes(std::vector& paths); + /** Compute final search path list (reroot + trailing slash). */ + void ComputeFinalPaths(); /** Compute the current default root path mode. */ void SelectDefaultRootPathMode(); diff --git a/Source/cmFindPackageCommand.cxx b/Source/cmFindPackageCommand.cxx index 2e72b58..7d3f09b 100644 --- a/Source/cmFindPackageCommand.cxx +++ b/Source/cmFindPackageCommand.cxx @@ -1243,7 +1243,7 @@ void cmFindPackageCommand::ComputePrefixes() this->AddPrefixesCMakeSystemVariable(); this->AddPrefixesSystemRegistry(); this->AddPrefixesUserGuess(); - this->ComputeFinalPrefixes(); + this->ComputeFinalPaths(); } //---------------------------------------------------------------------------- @@ -1574,18 +1574,6 @@ void cmFindPackageCommand::AddPrefixesUserHints() } //---------------------------------------------------------------------------- -void cmFindPackageCommand::ComputeFinalPrefixes() -{ - std::vector& prefixes = this->SearchPaths; - - // Construct the final set of prefixes. - this->RerootPaths(prefixes); - - // Add a trailing slash to all prefixes to aid the search process. - this->AddTrailingSlashes(prefixes); -} - -//---------------------------------------------------------------------------- bool cmFindPackageCommand::SearchDirectory(std::string const& dir) { assert(!dir.empty() && dir[dir.size()-1] == '/'); diff --git a/Source/cmFindPackageCommand.h b/Source/cmFindPackageCommand.h index 2b2e1da..e736352 100644 --- a/Source/cmFindPackageCommand.h +++ b/Source/cmFindPackageCommand.h @@ -93,7 +93,6 @@ private: void AddPrefixesCMakeSystemVariable(); void AddPrefixesUserGuess(); void AddPrefixesUserHints(); - void ComputeFinalPrefixes(); void LoadPackageRegistryDir(std::string const& dir); void LoadPackageRegistryWinUser(); void LoadPackageRegistryWinSystem(); -- cgit v0.12