- CMake Cookbook
- Radovan Bast Roberto Di Remigio
- 147字
- 2025-04-04 16:17:17
There is more
The foreach() construct can be used in four different ways:
- foreach(loop_var arg1 arg2 ...): Where a loop variable and an explicit list of items are provided. This form was used when printing the compiler flag sets for the items in sources_with_lower_optimization. Note that if the list of items is in a variable, it has to be explicitly expanded; that is, ${sources_with_lower_optimization} has to be passed as an argument.
- As a loop over integer numbers by specifying a range, such as foreach(loop_var RANGE total) or alternatively
foreach(loop_var RANGE start stop [step]). - As a loop over list-valued variables, such as foreach(loop_var IN LISTS [list1 [...]]). The arguments are interpreted as lists and their contents automatically expanded accordingly.
- As a loop over items, such as foreach(loop_var IN ITEMS [item1 [...]]). The contents of the arguments are not expanded.