1
0

cmInstallProgramsCommand.cxx 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. /*=========================================================================
  2. Program: Insight Segmentation & Registration Toolkit
  3. Module: $RCSfile$
  4. Language: C++
  5. Date: $Date$
  6. Version: $Revision$
  7. Copyright (c) 2002 Insight Consortium. All rights reserved.
  8. See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm 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 "cmInstallProgramsCommand.h"
  14. #include "cmCacheManager.h"
  15. // cmExecutableCommand
  16. bool cmInstallProgramsCommand::InitialPass(std::vector<std::string> const& argsIn)
  17. {
  18. if(argsIn.size() < 2)
  19. {
  20. this->SetError("called with incorrect number of arguments");
  21. return false;
  22. }
  23. std::vector<std::string> args;
  24. cmSystemTools::ExpandListArguments(argsIn, args);
  25. // Create an INSTALL_PROGRAMS target specifically for this path.
  26. m_TargetName = "INSTALL_PROGRAMS_"+args[0];
  27. cmTarget target;
  28. target.SetInAll(false);
  29. target.SetType(cmTarget::INSTALL_PROGRAMS);
  30. target.SetInstallPath(args[0].c_str());
  31. m_Makefile->GetTargets().insert(cmTargets::value_type(m_TargetName, target));
  32. std::vector<std::string>::const_iterator s = args.begin();
  33. for (++s;s != args.end(); ++s)
  34. {
  35. m_FinalArgs.push_back(*s);
  36. }
  37. return true;
  38. }
  39. void cmInstallProgramsCommand::FinalPass()
  40. {
  41. std::vector<std::string>& targetSourceLists =
  42. m_Makefile->GetTargets()[m_TargetName].GetSourceLists();
  43. // two different options
  44. if (m_FinalArgs.size() > 1)
  45. {
  46. // for each argument, get the programs
  47. for (std::vector<std::string>::iterator s = m_FinalArgs.begin();
  48. s != m_FinalArgs.end(); ++s)
  49. {
  50. // add to the result
  51. targetSourceLists.push_back(*s);
  52. }
  53. }
  54. else // reg exp list
  55. {
  56. std::vector<std::string> programs;
  57. cmSystemTools::Glob(m_Makefile->GetCurrentDirectory(),
  58. m_FinalArgs[0].c_str(), programs);
  59. std::vector<std::string>::iterator s = programs.begin();
  60. // for each argument, get the programs
  61. for (;s != programs.end(); ++s)
  62. {
  63. targetSourceLists.push_back(*s);
  64. }
  65. }
  66. }