cmInstallFilesCommand.cxx 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  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 "cmInstallFilesCommand.h"
  14. #include "cmCacheManager.h"
  15. // cmExecutableCommand
  16. bool cmInstallFilesCommand::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. m_Makefile->ExpandSourceListArguments(argsIn, args, 2);
  25. // Create an INSTALL_FILES target specifically for this path.
  26. m_TargetName = "INSTALL_FILES_"+args[0];
  27. cmTarget target;
  28. target.SetInAll(false);
  29. target.SetType(cmTarget::INSTALL_FILES);
  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 cmInstallFilesCommand::FinalPass()
  40. {
  41. std::string testf;
  42. std::string ext = m_FinalArgs[0];
  43. std::vector<std::string>& targetSourceLists =
  44. m_Makefile->GetTargets()[m_TargetName].GetSourceLists();
  45. // two different options
  46. if (m_FinalArgs.size() > 1)
  47. {
  48. // now put the files into the list
  49. std::vector<std::string>::iterator s = m_FinalArgs.begin();
  50. ++s;
  51. // for each argument, get the files
  52. for (;s != m_FinalArgs.end(); ++s)
  53. {
  54. // replace any variables
  55. std::string temps = *s;
  56. testf = temps + ext;
  57. // add to the result
  58. targetSourceLists.push_back(testf);
  59. }
  60. }
  61. else // reg exp list
  62. {
  63. std::vector<std::string> files;
  64. std::string regex = m_FinalArgs[0].c_str();
  65. cmSystemTools::Glob(m_Makefile->GetCurrentDirectory(),
  66. regex.c_str(), files);
  67. std::vector<std::string>::iterator s = files.begin();
  68. // for each argument, get the files
  69. for (;s != files.end(); ++s)
  70. {
  71. targetSourceLists.push_back(*s);
  72. }
  73. }
  74. }