cmFindProgramCommand.cxx 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. /*=========================================================================
  2. Program: Insight Segmentation & Registration Toolkit
  3. Module: $RCSfile$
  4. Language: C++
  5. Date: $Date$
  6. Version: $Revision$
  7. Copyright (c) 2000 National Library of Medicine
  8. All rights reserved.
  9. See COPYRIGHT.txt for copyright details.
  10. =========================================================================*/
  11. #include "cmFindProgramCommand.h"
  12. #include <stdlib.h>
  13. #include <stdio.h>
  14. // cmFindProgramCommand
  15. bool cmFindProgramCommand::Invoke(std::vector<std::string>& args)
  16. {
  17. if(args.size() < 2 )
  18. {
  19. this->SetError("called with incorrect number of arguments");
  20. return false;
  21. }
  22. std::vector<std::string> path;
  23. cmSystemTools::GetPath(path);
  24. std::vector<std::string>::iterator i = args.begin();
  25. const char* define = (*i).c_str();
  26. i++;
  27. for(; i != args.end(); ++i)
  28. {
  29. for(int k=0; k < path.size(); k++)
  30. {
  31. std::string tryPath = path[k];
  32. tryPath += "/";
  33. tryPath += *i;
  34. #ifdef _WIN32
  35. tryPath += ".exe";
  36. #endif
  37. if(cmSystemTools::FileExists(tryPath.c_str()))
  38. {
  39. m_Makefile->AddDefinition(define, tryPath.c_str());
  40. return true;
  41. }
  42. }
  43. }
  44. return false;
  45. }