fixed bug and modified functionality

This commit is contained in:
Ken Martin 2001-02-26 17:14:33 -05:00
parent 3acd5951ba
commit 7cde8fd0f4
2 changed files with 26 additions and 19 deletions

View File

@ -40,28 +40,35 @@ bool cmFindProgramCommand::Invoke(std::vector<std::string>& args)
m_Makefile->AddDefinition(define, cacheValue); m_Makefile->AddDefinition(define, cacheValue);
return true; return true;
} }
// if it is not in the cache, then search the system path // if it is not in the cache, then search the system path
// add any user specified paths
std::vector<std::string> path; std::vector<std::string> path;
cmSystemTools::GetPath(path); for (unsigned int j = 2; j < args.size(); j++)
for(; i != args.end(); ++i)
{ {
for(unsigned int k=0; k < path.size(); k++) // expand variables
{ std::string exp = args[j];
std::string tryPath = path[k]; m_Makefile->ExpandVariablesInString(exp);
tryPath += "/"; path.push_back(exp);
tryPath += *i; }
cmSystemTools::GetPath(path);
for(unsigned int k=0; k < path.size(); k++)
{
std::string tryPath = path[k];
tryPath += "/";
tryPath += *i;
#ifdef _WIN32 #ifdef _WIN32
tryPath += ".exe"; tryPath += ".exe";
#endif #endif
if(cmSystemTools::FileExists(tryPath.c_str())) if(cmSystemTools::FileExists(tryPath.c_str()))
{ {
// Save the value in the cache // Save the value in the cache
cmCacheManager::GetInstance()->AddCacheEntry(define, cmCacheManager::GetInstance()->AddCacheEntry(define,
tryPath.c_str(), tryPath.c_str(),
cmCacheManager::FILEPATH); cmCacheManager::FILEPATH);
m_Makefile->AddDefinition(define, tryPath.c_str()); m_Makefile->AddDefinition(define, tryPath.c_str());
return true; return true;
}
} }
} }
return false; return false;

View File

@ -53,7 +53,7 @@ public:
/** /**
* The name of the command as specified in CMakeList.txt. * The name of the command as specified in CMakeList.txt.
*/ */
virtual const char* GetName() { return "FIND_PROGRARM";} virtual const char* GetName() { return "FIND_PROGRAM";}
/** /**
* Succinct documentation. * Succinct documentation.
@ -69,7 +69,7 @@ public:
virtual const char* GetFullDocumentation() virtual const char* GetFullDocumentation()
{ {
return return
"FIND_PROGRAM(NAME executable1 executable2 ...)"; "FIND_PROGRAM(NAME executable1 extrapath extrapath ...)";
} }
cmTypeMacro(cmFindProgramCommand, cmCommand); cmTypeMacro(cmFindProgramCommand, cmCommand);