cmBreakCommand.cxx 2.5 KB

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