cmFindProgramCommand.cxx 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. /*=========================================================================
  2. Program: CMake - Cross-Platform Makefile Generator
  3. Module: $RCSfile$
  4. Language: C++
  5. Date: $Date$
  6. Version: $Revision$
  7. Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved.
  8. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details.
  9. This software is distributed WITHOUT ANY WARRANTY; without even
  10. the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
  11. PURPOSE. See the above copyright notices for more information.
  12. =========================================================================*/
  13. #include "cmFindProgramCommand.h"
  14. #include "cmCacheManager.h"
  15. #include <stdlib.h>
  16. cmFindProgramCommand::cmFindProgramCommand()
  17. {
  18. cmSystemTools::ReplaceString(this->GenericDocumentation,
  19. "FIND_XXX", "FIND_PROGRAM");
  20. cmSystemTools::ReplaceString(this->GenericDocumentation,
  21. "CMAKE_XXX_PATH", "CMAKE_PROGRAM_PATH");
  22. cmSystemTools::ReplaceString(this->GenericDocumentation,
  23. "XXX_SYSTEM", "");
  24. cmSystemTools::ReplaceString(this->GenericDocumentation,
  25. "CMAKE_SYSTEM_XXX_PATH", "CMAKE_SYSTEM_PROGRAM_PATH");
  26. cmSystemTools::ReplaceString(this->GenericDocumentation,
  27. "SEARCH_XXX_DESC", "program");
  28. cmSystemTools::ReplaceString(this->GenericDocumentation,
  29. "SEARCH_XXX", "program");
  30. }
  31. // cmFindProgramCommand
  32. bool cmFindProgramCommand::InitialPass(std::vector<std::string> const& argsIn)
  33. {
  34. this->VariableDocumentation = "Path to a program.";
  35. this->CMakePathName = "PROGRAM";
  36. // call cmFindBase::ParseArguments
  37. if(!this->ParseArguments(argsIn))
  38. {
  39. return false;
  40. }
  41. if(this->AlreadyInCache)
  42. {
  43. return true;
  44. }
  45. std::string result = cmSystemTools::FindProgram(this->Names,
  46. this->SearchPaths, true);
  47. if(result != "")
  48. {
  49. // Save the value in the cache
  50. this->Makefile->AddCacheDefinition(this->VariableName.c_str(),
  51. result.c_str(),
  52. this->VariableDocumentation.c_str(),
  53. cmCacheManager::FILEPATH);
  54. return true;
  55. }
  56. this->Makefile->AddCacheDefinition(this->VariableName.c_str(),
  57. (this->VariableName + "-NOTFOUND").c_str(),
  58. this->VariableDocumentation.c_str(),
  59. cmCacheManager::FILEPATH);
  60. return true;
  61. }