diff options
author | Alex Turbov <i.zaufi@gmail.com> | 2019-11-09 15:42:08 (GMT) |
---|---|---|
committer | Alex Turbov <i.zaufi@gmail.com> | 2019-12-01 20:28:39 (GMT) |
commit | f3e51a2b1d1742a21f18717a361338149954728c (patch) | |
tree | c98d5eaa75a70688f957852ae8a67f384970cb85 /Help | |
parent | 74569996e8fe798386cca2d4241acea0644f6275 (diff) | |
download | CMake-f3e51a2b1d1742a21f18717a361338149954728c.zip CMake-f3e51a2b1d1742a21f18717a361338149954728c.tar.gz CMake-f3e51a2b1d1742a21f18717a361338149954728c.tar.bz2 |
foreach: Introduce `IN ZIP_LISTS` mode
Diffstat (limited to 'Help')
-rw-r--r-- | Help/command/foreach.rst | 28 | ||||
-rw-r--r-- | Help/release/dev/foreach-ZIP_LISTS.rst | 5 |
2 files changed, 33 insertions, 0 deletions
diff --git a/Help/command/foreach.rst b/Help/command/foreach.rst index ecbfed3..dbd2fac 100644 --- a/Help/command/foreach.rst +++ b/Help/command/foreach.rst @@ -82,3 +82,31 @@ yields -- X=6 -- X=7 -- X=8 + + +.. code-block:: cmake + + foreach(<loop_var> IN ZIP_LISTS <lists>) + +In this variant, ``<lists>`` is a whitespace or semicolon +separated list of list-valued variables. The ``foreach`` +command iterates over each list simultaneously and set the +``loop_var_N`` variables to the current item from the +corresponding list. If some list is shorter than others, +the corresponding iteration variable is not defined. + +.. code-block:: cmake + + list(APPEND English one two three four) + list(APPEND Bahasa satu dua tiga) + foreach(X IN ZIP_LISTS English Bahasa) + message(STATUS "X_0=${X_0}, X_1=${X_1}") + endforeach() + +yields +:: + + -- X_0=one, X_1=satu + -- X_0=two, X_1=dua + -- X_0=three, X_1=tiga + -- X_0=four, X_1= diff --git a/Help/release/dev/foreach-ZIP_LISTS.rst b/Help/release/dev/foreach-ZIP_LISTS.rst new file mode 100644 index 0000000..d45d9b9 --- /dev/null +++ b/Help/release/dev/foreach-ZIP_LISTS.rst @@ -0,0 +1,5 @@ +foreach-ZIP_LISTS +----------------- + +* The :command:`foreach` learned a new option ``ZIP_LISTS`` to iterate + over multiple lists simultaneously. |