while.rst 891 B

123456789101112131415161718192021222324252627282930313233
  1. while
  2. -----
  3. Evaluate a group of commands while a condition is true
  4. .. code-block:: cmake
  5. while(<condition>)
  6. <commands>
  7. endwhile()
  8. All commands between while and the matching :command:`endwhile` are recorded
  9. without being invoked. Once the :command:`endwhile` is evaluated, the
  10. recorded list of commands is invoked as long as the ``<condition>`` is true.
  11. The ``<condition>`` has the same syntax and is evaluated using the same logic
  12. as described at length for the :command:`if` command.
  13. The commands :command:`break` and :command:`continue` provide means to
  14. escape from the normal control flow.
  15. Per legacy, the :command:`endwhile` command admits
  16. an optional ``<condition>`` argument.
  17. If used, it must be a verbatim repeat of the argument of the opening
  18. ``while`` command.
  19. See Also
  20. ^^^^^^^^
  21. * :command:`break`
  22. * :command:`continue`
  23. * :command:`foreach`
  24. * :command:`endwhile`