diff options
Diffstat (limited to 'Source/cmFindProgramCommand.cxx')
-rw-r--r-- | Source/cmFindProgramCommand.cxx | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/Source/cmFindProgramCommand.cxx b/Source/cmFindProgramCommand.cxx index c9bc56d..e64ed87 100644 --- a/Source/cmFindProgramCommand.cxx +++ b/Source/cmFindProgramCommand.cxx @@ -85,6 +85,11 @@ struct cmFindProgramHelper } }; +cmFindProgramCommand::cmFindProgramCommand() +{ + this->NamesPerDirAllowed = true; +} + // cmFindProgramCommand bool cmFindProgramCommand ::InitialPass(std::vector<std::string> const& argsIn, cmExecutionStatus &) @@ -151,6 +156,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; for (std::vector<std::string>::const_iterator ni = this->Names.begin(); |