Parallel iteration over lists in makefile or CMake file

前端 未结 3 622
故里飘歌
故里飘歌 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

    Here you go:

    set(list1 1 2 3 4 5)
    set(list2 6 7 8 9 0)
    
    list(LENGTH list1 len1)
    math(EXPR len2 "${len1} - 1")
    
    foreach(val RANGE ${len2})
      list(GET list1 ${val} val1)
      list(GET list2 ${val} val2)
      message(STATUS "${val1}  ${val2}")
    endforeach()
    

提交回复
热议问题