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