mirror of
https://github.com/Kitware/CMake.git
synced 2026-02-25 18:28:57 -06:00
find_program: Optionally consider all names in each directory
When more than one value is given to the NAMES option this command by default will consider one name at a time and search every directory for it. Add a NAMES_PER_DIR option to tell this command to consider one directory at a time and search for all names in it.
This commit is contained in:
@@ -85,6 +85,11 @@ struct cmFindProgramHelper
|
||||
}
|
||||
};
|
||||
|
||||
cmFindProgramCommand::cmFindProgramCommand()
|
||||
{
|
||||
this->NamesPerDirAllowed = true;
|
||||
}
|
||||
|
||||
// cmFindProgramCommand
|
||||
bool cmFindProgramCommand
|
||||
::InitialPass(std::vector<std::string> const& argsIn, cmExecutionStatus &)
|
||||
@@ -150,6 +155,42 @@ std::string cmFindProgramCommand::FindProgram()
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
std::string cmFindProgramCommand::FindNormalProgram()
|
||||
{
|
||||
if(this->NamesPerDir)
|
||||
{
|
||||
return this->FindNormalProgramNamesPerDir();
|
||||
}
|
||||
else
|
||||
{
|
||||
return this->FindNormalProgramDirsPerName();
|
||||
}
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
std::string cmFindProgramCommand::FindNormalProgramNamesPerDir()
|
||||
{
|
||||
// Search for all names in each directory.
|
||||
cmFindProgramHelper helper;
|
||||
for (std::vector<std::string>::const_iterator ni = this->Names.begin();
|
||||
ni != this->Names.end() ; ++ni)
|
||||
{
|
||||
helper.AddName(*ni);
|
||||
}
|
||||
// Search every directory.
|
||||
for (std::vector<std::string>::const_iterator
|
||||
p = this->SearchPaths.begin(); p != this->SearchPaths.end(); ++p)
|
||||
{
|
||||
if(helper.CheckDirectory(*p))
|
||||
{
|
||||
return helper.BestPath;
|
||||
}
|
||||
}
|
||||
// Couldn't find the program.
|
||||
return "";
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
std::string cmFindProgramCommand::FindNormalProgramDirsPerName()
|
||||
{
|
||||
// Search the entire path for each name.
|
||||
cmFindProgramHelper helper;
|
||||
|
||||
@@ -25,6 +25,7 @@
|
||||
class cmFindProgramCommand : public cmFindBase
|
||||
{
|
||||
public:
|
||||
cmFindProgramCommand();
|
||||
/**
|
||||
* This is a virtual constructor for the command.
|
||||
*/
|
||||
@@ -55,6 +56,8 @@ public:
|
||||
private:
|
||||
std::string FindProgram();
|
||||
std::string FindNormalProgram();
|
||||
std::string FindNormalProgramDirsPerName();
|
||||
std::string FindNormalProgramNamesPerDir();
|
||||
std::string FindAppBundle();
|
||||
std::string GetBundleExecutable(std::string bundlePath);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user