cmake/Help/command/while.rst

34 lines
891 B
ReStructuredText
Raw Normal View History

2014-08-03 19:52:23 +02:00
while
-----
Evaluate a group of commands while a condition is true
2019-11-11 23:01:05 +01:00
.. code-block:: cmake
2014-08-03 19:52:23 +02:00
2019-11-11 23:01:05 +01:00
while(<condition>)
<commands>
endwhile()
2014-08-03 19:52:23 +02:00
2015-11-17 17:22:37 +01:00
All commands between while and the matching :command:`endwhile` are recorded
without being invoked. Once the :command:`endwhile` is evaluated, the
2019-11-11 23:01:05 +01:00
recorded list of commands is invoked as long as the ``<condition>`` is true.
The ``<condition>`` has the same syntax and is evaluated using the same logic
as described at length for the :command:`if` command.
The commands :command:`break` and :command:`continue` provide means to
escape from the normal control flow.
Per legacy, the :command:`endwhile` command admits
an optional ``<condition>`` argument.
If used, it must be a verbatim repeat of the argument of the opening
``while`` command.
2022-11-16 20:14:03 +01:00
See Also
^^^^^^^^
2023-05-23 16:38:00 +02:00
* :command:`break`
* :command:`continue`
* :command:`foreach`
* :command:`endwhile`