cmBreakCommand.cxx 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  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 "cmBreakCommand.h"
  11. // cmBreakCommand
  12. bool cmBreakCommand::InitialPass(std::vector<std::string> const &args,
  13. cmExecutionStatus &status)
  14. {
  15. if(!this->Makefile->IsLoopBlock())
  16. {
  17. bool issueMessage = true;
  18. std::ostringstream e;
  19. cmake::MessageType messageType = cmake::AUTHOR_WARNING;
  20. switch(this->Makefile->GetPolicyStatus(cmPolicies::CMP0055))
  21. {
  22. case cmPolicies::WARN:
  23. e << (this->Makefile->GetPolicies()
  24. ->GetPolicyWarning(cmPolicies::CMP0055)) << "\n";
  25. break;
  26. case cmPolicies::OLD:
  27. issueMessage = false;
  28. break;
  29. case cmPolicies::REQUIRED_ALWAYS:
  30. case cmPolicies::REQUIRED_IF_USED:
  31. case cmPolicies::NEW:
  32. messageType = cmake::FATAL_ERROR;
  33. break;
  34. }
  35. if(issueMessage)
  36. {
  37. e << "A BREAK command was found outside of a proper "
  38. "FOREACH or WHILE loop scope.";
  39. this->Makefile->IssueMessage(messageType, e.str());
  40. if(messageType == cmake::FATAL_ERROR)
  41. {
  42. return false;
  43. }
  44. }
  45. }
  46. status.SetBreakInvoked(true);
  47. if(!args.empty())
  48. {
  49. bool issueMessage = true;
  50. std::ostringstream e;
  51. cmake::MessageType messageType = cmake::AUTHOR_WARNING;
  52. switch(this->Makefile->GetPolicyStatus(cmPolicies::CMP0055))
  53. {
  54. case cmPolicies::WARN:
  55. e << (this->Makefile->GetPolicies()
  56. ->GetPolicyWarning(cmPolicies::CMP0055)) << "\n";
  57. break;
  58. case cmPolicies::OLD:
  59. issueMessage = false;
  60. break;
  61. case cmPolicies::REQUIRED_ALWAYS:
  62. case cmPolicies::REQUIRED_IF_USED:
  63. case cmPolicies::NEW:
  64. messageType = cmake::FATAL_ERROR;
  65. break;
  66. }
  67. if(issueMessage)
  68. {
  69. e << "The BREAK command does not accept any arguments.";
  70. this->Makefile->IssueMessage(messageType, e.str());
  71. if(messageType == cmake::FATAL_ERROR)
  72. {
  73. return false;
  74. }
  75. }
  76. }
  77. return true;
  78. }