Skip to content

foreach: Introduce `IN ZIP_LISTS` mode

Alex Turbov requested to merge zaufi/cmake:feature/foreach-IN-ZIP_LISTS into master

Example:

  list(APPEND English one two three)
  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

Also in this MR:

  • Modernize the code (1st commit) and add tests for the existed functionality;
  • Fix a bug when foreach(var IN LISTS … ITEMS …) works, but foreach(var IN ITEMS … LISTS …) didn't (2nd commit).
Edited by Alex Turbov

Merge request reports

Loading