cmCustomCommand.cxx 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151
  1. /*============================================================================
  2. CMake - Cross Platform Makefile Generator
  3. Copyright 2000-2009 Kitware, Inc., Insight Software Consortium
  4. Distributed under the OSI-approved BSD License (the "License");
  5. see accompanying file Copyright.txt for details.
  6. This software is distributed WITHOUT ANY WARRANTY; without even the
  7. implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  8. See the License for more information.
  9. ============================================================================*/
  10. #include "cmCustomCommand.h"
  11. //----------------------------------------------------------------------------
  12. cmCustomCommand::cmCustomCommand()
  13. {
  14. this->HaveComment = false;
  15. this->EscapeOldStyle = true;
  16. this->EscapeAllowMakeVars = false;
  17. }
  18. //----------------------------------------------------------------------------
  19. cmCustomCommand::cmCustomCommand(const cmCustomCommand& r):
  20. Outputs(r.Outputs),
  21. Depends(r.Depends),
  22. CommandLines(r.CommandLines),
  23. HaveComment(r.HaveComment),
  24. Comment(r.Comment),
  25. WorkingDirectory(r.WorkingDirectory),
  26. EscapeAllowMakeVars(r.EscapeAllowMakeVars),
  27. EscapeOldStyle(r.EscapeOldStyle)
  28. {
  29. }
  30. //----------------------------------------------------------------------------
  31. cmCustomCommand::cmCustomCommand(const std::vector<std::string>& outputs,
  32. const std::vector<std::string>& depends,
  33. const cmCustomCommandLines& commandLines,
  34. const char* comment,
  35. const char* workingDirectory):
  36. Outputs(outputs),
  37. Depends(depends),
  38. CommandLines(commandLines),
  39. HaveComment(comment?true:false),
  40. Comment(comment?comment:""),
  41. WorkingDirectory(workingDirectory?workingDirectory:""),
  42. EscapeAllowMakeVars(false),
  43. EscapeOldStyle(true)
  44. {
  45. this->EscapeOldStyle = true;
  46. this->EscapeAllowMakeVars = false;
  47. }
  48. //----------------------------------------------------------------------------
  49. const std::vector<std::string>& cmCustomCommand::GetOutputs() const
  50. {
  51. return this->Outputs;
  52. }
  53. //----------------------------------------------------------------------------
  54. const char* cmCustomCommand::GetWorkingDirectory() const
  55. {
  56. if(this->WorkingDirectory.size() == 0)
  57. {
  58. return 0;
  59. }
  60. return this->WorkingDirectory.c_str();
  61. }
  62. //----------------------------------------------------------------------------
  63. const std::vector<std::string>& cmCustomCommand::GetDepends() const
  64. {
  65. return this->Depends;
  66. }
  67. //----------------------------------------------------------------------------
  68. const cmCustomCommandLines& cmCustomCommand::GetCommandLines() const
  69. {
  70. return this->CommandLines;
  71. }
  72. //----------------------------------------------------------------------------
  73. const char* cmCustomCommand::GetComment() const
  74. {
  75. const char* no_comment = 0;
  76. return this->HaveComment? this->Comment.c_str() : no_comment;
  77. }
  78. //----------------------------------------------------------------------------
  79. void cmCustomCommand::AppendCommands(const cmCustomCommandLines& commandLines)
  80. {
  81. for(cmCustomCommandLines::const_iterator i=commandLines.begin();
  82. i != commandLines.end(); ++i)
  83. {
  84. this->CommandLines.push_back(*i);
  85. }
  86. }
  87. //----------------------------------------------------------------------------
  88. void cmCustomCommand::AppendDepends(const std::vector<std::string>& depends)
  89. {
  90. for(std::vector<std::string>::const_iterator i=depends.begin();
  91. i != depends.end(); ++i)
  92. {
  93. this->Depends.push_back(*i);
  94. }
  95. }
  96. //----------------------------------------------------------------------------
  97. bool cmCustomCommand::GetEscapeOldStyle() const
  98. {
  99. return this->EscapeOldStyle;
  100. }
  101. //----------------------------------------------------------------------------
  102. void cmCustomCommand::SetEscapeOldStyle(bool b)
  103. {
  104. this->EscapeOldStyle = b;
  105. }
  106. //----------------------------------------------------------------------------
  107. bool cmCustomCommand::GetEscapeAllowMakeVars() const
  108. {
  109. return this->EscapeAllowMakeVars;
  110. }
  111. //----------------------------------------------------------------------------
  112. void cmCustomCommand::SetEscapeAllowMakeVars(bool b)
  113. {
  114. this->EscapeAllowMakeVars = b;
  115. }
  116. //----------------------------------------------------------------------------
  117. cmCustomCommand::ImplicitDependsList const&
  118. cmCustomCommand::GetImplicitDepends() const
  119. {
  120. return this->ImplicitDepends;
  121. }
  122. //----------------------------------------------------------------------------
  123. void cmCustomCommand::SetImplicitDepends(ImplicitDependsList const& l)
  124. {
  125. this->ImplicitDepends = l;
  126. }
  127. //----------------------------------------------------------------------------
  128. void cmCustomCommand::AppendImplicitDepends(ImplicitDependsList const& l)
  129. {
  130. this->ImplicitDepends.insert(this->ImplicitDepends.end(),
  131. l.begin(), l.end());
  132. }