cmConfigureFileCommand.cxx 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  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 "cmConfigureFileCommand.h"
  14. #include <cmsys/RegularExpression.hxx>
  15. // cmConfigureFileCommand
  16. bool cmConfigureFileCommand::InitialPass(std::vector<std::string> const& args)
  17. {
  18. if(args.size() < 2 )
  19. {
  20. this->SetError("called with incorrect number of arguments, expected 2");
  21. return false;
  22. }
  23. m_InputFile = args[0];
  24. m_OuputFile = args[1];
  25. m_CopyOnly = false;
  26. m_EscapeQuotes = false;
  27. m_Immediate = false;
  28. m_AtOnly = false;
  29. for(unsigned int i=2;i < args.size();++i)
  30. {
  31. if(args[i] == "COPYONLY")
  32. {
  33. m_CopyOnly = true;
  34. }
  35. else if(args[i] == "ESCAPE_QUOTES")
  36. {
  37. m_EscapeQuotes = true;
  38. }
  39. else if(args[i] == "@ONLY")
  40. {
  41. m_AtOnly = true;
  42. }
  43. else if(args[i] == "IMMEDIATE")
  44. {
  45. m_Immediate = true;
  46. }
  47. }
  48. // If we were told to copy the file immediately, then do it on the
  49. // first pass (now).
  50. if(m_Immediate)
  51. {
  52. this->ConfigureFile();
  53. }
  54. return true;
  55. }
  56. void cmConfigureFileCommand::FinalPass()
  57. {
  58. if(!m_Immediate)
  59. {
  60. this->ConfigureFile();
  61. }
  62. }
  63. void cmConfigureFileCommand::ConfigureFile()
  64. {
  65. m_Makefile->ConfigureFile(m_InputFile.c_str(),
  66. m_OuputFile.c_str(),
  67. m_CopyOnly,
  68. m_AtOnly,
  69. m_EscapeQuotes);
  70. }