"Fossies" - the Fresh Open Source Software Archive

Member "cmake-3.6.2-win32-x86/share/cmake-3.6/Help/command/foreach.rst" (7 Sep 2016, 1471 Bytes) of archive /windows/misc/cmake-3.6.2-win32-x86.zip:

As a special service "Fossies" has tried to format the requested source page into HTML format (assuming markdown format). Alternatively you can here view or download the uninterpreted source code file. A member file download can also be achieved by clicking within a package contents listing on the according byte size field.


Evaluate a group of commands for each value in a list.


foreach(loop_var arg1 arg2 …) COMMAND1(ARGS …) COMMAND2(ARGS …) … endforeach(loop_var)

All commands between foreach and the matching endforeach are recorded without being invoked. Once the endforeach is evaluated, the recorded list of commands is invoked once for each argument listed in the original foreach command. Before each iteration of the loop ${loop_var} will be set as a variable with the current value in the list.


foreach(loop_var RANGE total) foreach(loop_var RANGE start stop [step])

Foreach can also iterate over a generated range of numbers. There are three types of this iteration:


foreach(loop_var IN [LISTS [list1 […]]] [ITEMS [item1 […]]])

Iterates over a precise list of items. The LISTS option names list-valued variables to be traversed, including empty elements (an empty string is a zero-length list). (Note macro arguments are not variables.) The ITEMS option ends argument parsing and includes all arguments following it in the iteration.