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.
This commit is contained in:
parent
8c280435df
commit
b0cd630521
@ -299,11 +299,7 @@ bool cmFindBase::ParseArguments(std::vector<std::string> const& argsIn)
|
|||||||
this->GetIgnoredPaths(ignored);
|
this->GetIgnoredPaths(ignored);
|
||||||
this->FilterPaths(this->SearchPaths, ignored);
|
this->FilterPaths(this->SearchPaths, ignored);
|
||||||
|
|
||||||
// Handle search root stuff.
|
this->ComputeFinalPaths();
|
||||||
this->RerootPaths(this->SearchPaths);
|
|
||||||
|
|
||||||
// Add a trailing slash to all prefixes to aid the search process.
|
|
||||||
this->AddTrailingSlashes(this->SearchPaths);
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -471,8 +471,13 @@ void cmFindCommon::AddPathInternal(std::string const& in_path,
|
|||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
void cmFindCommon::AddTrailingSlashes(std::vector<std::string>& paths)
|
void cmFindCommon::ComputeFinalPaths()
|
||||||
{
|
{
|
||||||
|
std::vector<std::string>& 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.
|
// Add a trailing slash to all paths to aid the search process.
|
||||||
for(std::vector<std::string>::iterator i = paths.begin();
|
for(std::vector<std::string>::iterator i = paths.begin();
|
||||||
i != paths.end(); ++i)
|
i != paths.end(); ++i)
|
||||||
|
@ -47,8 +47,8 @@ protected:
|
|||||||
void FilterPaths(std::vector<std::string>& paths,
|
void FilterPaths(std::vector<std::string>& paths,
|
||||||
const std::set<std::string>& ignore);
|
const std::set<std::string>& ignore);
|
||||||
|
|
||||||
/** Add trailing slashes to all search paths. */
|
/** Compute final search path list (reroot + trailing slash). */
|
||||||
void AddTrailingSlashes(std::vector<std::string>& paths);
|
void ComputeFinalPaths();
|
||||||
|
|
||||||
/** Compute the current default root path mode. */
|
/** Compute the current default root path mode. */
|
||||||
void SelectDefaultRootPathMode();
|
void SelectDefaultRootPathMode();
|
||||||
|
@ -1243,7 +1243,7 @@ void cmFindPackageCommand::ComputePrefixes()
|
|||||||
this->AddPrefixesCMakeSystemVariable();
|
this->AddPrefixesCMakeSystemVariable();
|
||||||
this->AddPrefixesSystemRegistry();
|
this->AddPrefixesSystemRegistry();
|
||||||
this->AddPrefixesUserGuess();
|
this->AddPrefixesUserGuess();
|
||||||
this->ComputeFinalPrefixes();
|
this->ComputeFinalPaths();
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
@ -1573,18 +1573,6 @@ void cmFindPackageCommand::AddPrefixesUserHints()
|
|||||||
this->AddPathsInternal(this->UserHints, CMakePath);
|
this->AddPathsInternal(this->UserHints, CMakePath);
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
|
||||||
void cmFindPackageCommand::ComputeFinalPrefixes()
|
|
||||||
{
|
|
||||||
std::vector<std::string>& 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)
|
bool cmFindPackageCommand::SearchDirectory(std::string const& dir)
|
||||||
{
|
{
|
||||||
|
@ -93,7 +93,6 @@ private:
|
|||||||
void AddPrefixesCMakeSystemVariable();
|
void AddPrefixesCMakeSystemVariable();
|
||||||
void AddPrefixesUserGuess();
|
void AddPrefixesUserGuess();
|
||||||
void AddPrefixesUserHints();
|
void AddPrefixesUserHints();
|
||||||
void ComputeFinalPrefixes();
|
|
||||||
void LoadPackageRegistryDir(std::string const& dir);
|
void LoadPackageRegistryDir(std::string const& dir);
|
||||||
void LoadPackageRegistryWinUser();
|
void LoadPackageRegistryWinUser();
|
||||||
void LoadPackageRegistryWinSystem();
|
void LoadPackageRegistryWinSystem();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user