cmBreakCommand.cxx 840 B

12345678910111213141516171819202122232425262728293031
  1. /* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
  2. file Copyright.txt or https://cmake.org/licensing for details. */
  3. #include "cmBreakCommand.h"
  4. #include "cmExecutionStatus.h"
  5. #include "cmMakefile.h"
  6. #include "cmMessageType.h"
  7. // cmBreakCommand
  8. bool cmBreakCommand(std::vector<std::string> const& args,
  9. cmExecutionStatus& status)
  10. {
  11. if (!status.GetMakefile().IsLoopBlock()) {
  12. status.GetMakefile().IssueMessage(
  13. MessageType::FATAL_ERROR,
  14. "A BREAK command was found outside of a proper "
  15. "FOREACH or WHILE loop scope.");
  16. return false;
  17. }
  18. status.SetBreakInvoked();
  19. if (!args.empty()) {
  20. status.GetMakefile().IssueMessage(
  21. MessageType::FATAL_ERROR,
  22. "The BREAK command does not accept any arguments.");
  23. return false;
  24. }
  25. return true;
  26. }