cmInstallProgramsCommand.cxx 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  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& args)
  17. {
  18. if(args.size() < 2)
  19. {
  20. this->SetError("called with incorrect number of arguments");
  21. return false;
  22. }
  23. // Create an INSTALL_PROGRAMS target specifically for this path.
  24. m_TargetName = "INSTALL_PROGRAMS_"+args[0];
  25. cmTarget target;
  26. target.SetInAll(false);
  27. target.SetType(cmTarget::INSTALL_PROGRAMS);
  28. target.SetInstallPath(args[0].c_str());
  29. m_Makefile->GetTargets().insert(cmTargets::value_type(m_TargetName, target));
  30. std::vector<std::string>::const_iterator s = args.begin();
  31. for (++s;s != args.end(); ++s)
  32. {
  33. m_FinalArgs.push_back(*s);
  34. }
  35. return true;
  36. }
  37. void cmInstallProgramsCommand::FinalPass()
  38. {
  39. std::vector<std::string>& targetSourceLists =
  40. m_Makefile->GetTargets()[m_TargetName].GetSourceLists();
  41. // two different options
  42. if (m_FinalArgs.size() > 1)
  43. {
  44. // for each argument, get the programs
  45. for (std::vector<std::string>::iterator s = m_FinalArgs.begin();
  46. s != m_FinalArgs.end(); ++s)
  47. {
  48. // replace any variables
  49. std::string temps = *s;
  50. m_Makefile->ExpandVariablesInString(temps);
  51. // add to the result
  52. targetSourceLists.push_back(temps);
  53. }
  54. }
  55. else // reg exp list
  56. {
  57. std::vector<std::string> programs;
  58. cmSystemTools::Glob(m_Makefile->GetCurrentDirectory(),
  59. m_FinalArgs[0].c_str(), programs);
  60. std::vector<std::string>::iterator s = programs.begin();
  61. // for each argument, get the programs
  62. for (;s != programs.end(); ++s)
  63. {
  64. targetSourceLists.push_back(*s);
  65. }
  66. }
  67. }