Parallel iteration over lists in makefile or CMake file

前端 未结 3 628
故里飘歌
故里飘歌 2021-02-12 19:35

Is there a way to loop over multiple lists in parallel in a makefile or CMake file?

I would like to do something like the following in CMake, except AFAICT this syntax i

3条回答
  •  无人及你
    2021-02-12 20:14

    As of CMake 3.17, the foreach() loop supports a ZIP_LISTS option to iterate through two (or more) lists simultaneously:

    set(a_values a0 a1 a2)
    set(b_values b0 b1 b2)
    foreach(a b IN ZIP_LISTS a_values b_values)
        message("${a} ${b}")
    endforeach()
    

    This prints:

    a0 b0
    a1 b1
    a2 b2
    

提交回复
热议问题