cmInstallFilesCommand.cxx 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  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& 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_FILES target specifically for this path.
  24. m_TargetName = "INSTALL_FILES_"+args[0];
  25. cmTarget target;
  26. target.SetInAll(false);
  27. target.SetType(cmTarget::INSTALL_FILES);
  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 cmInstallFilesCommand::FinalPass()
  38. {
  39. std::string testf;
  40. std::string ext = m_FinalArgs[0];
  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. // now put the files into the list
  47. std::vector<std::string>::iterator s = m_FinalArgs.begin();
  48. ++s;
  49. // for each argument, get the files
  50. for (;s != m_FinalArgs.end(); ++s)
  51. {
  52. // replace any variables
  53. std::string temps = *s;
  54. m_Makefile->ExpandVariablesInString(temps);
  55. // look for a srclist
  56. if (m_Makefile->GetSources().find(temps) != m_Makefile->GetSources().end())
  57. {
  58. const std::vector<cmSourceFile> &clsList =
  59. m_Makefile->GetSources().find(temps)->second;
  60. std::vector<cmSourceFile>::const_iterator c = clsList.begin();
  61. for (; c != clsList.end(); ++c)
  62. {
  63. testf = c->GetSourceName() + ext;
  64. // add to the result
  65. targetSourceLists.push_back(testf);
  66. }
  67. }
  68. // if one wasn't found then assume it is a single class
  69. else
  70. {
  71. testf = temps + ext;
  72. // add to the result
  73. targetSourceLists.push_back(testf);
  74. }
  75. }
  76. }
  77. else // reg exp list
  78. {
  79. std::vector<std::string> files;
  80. std::string regex = m_FinalArgs[0].c_str();
  81. m_Makefile->ExpandVariablesInString(regex);
  82. cmSystemTools::Glob(m_Makefile->GetCurrentDirectory(),
  83. regex.c_str(), files);
  84. std::vector<std::string>::iterator s = files.begin();
  85. // for each argument, get the files
  86. for (;s != files.end(); ++s)
  87. {
  88. targetSourceLists.push_back(*s);
  89. }
  90. }
  91. }