Hi, I apologize for initially sending this message to cmake-develop...@cmake.org, rather than here. I was confused and mistook the proper mailing list.
I have an `INTERFACE IMPORTED` library target that depends on a bunch of optional dependencies. Please see the snippet below: cmake_minimum_required(VERSION 3.14) add_library(example INTERFACE IMPORTED) set_property(TARGET example PROPERTY INTERFACE_LINK_LIBRARIES $<$<CONFIG:Debug>:${undefined_dependency_one} ${undefined_dependency_two}> ) It so happens that both of the optional dependencies `${undefined_dependency_one}` and `${undefined_dependency_two}` are set to empty/undefined on my system, which is perfectly fine. I want to do some postprocessing to the dependencies of my target: get_target_property(all_dependencies example INTERFACE_LINK_LIBRARIES) foreach(lib IN LISTS all_dependencies) message(STATUS "dependency on " ${lib}) endforeach() This `foreach()` loop gets confused about the generator expression. The output of the `message(STATUS ...)` calls in the snippet above is: -- dependency on $<$<CONFIG:Debug>: -- dependency on > Please note that the generator expression got mangled into two pieces by the `foreach()` loop. I was expecting to see a single line of `$<$<CONFIG:Debug>:>` I experimented with different versions of this test case and found variants that do not get mangled in the `foreach()` loop. In a modification when there is only one empty/undefined dependency the `foreach()` loop works as expected. set_property(TARGET example PROPERTY INTERFACE_LINK_LIBRARIES $<$<CONFIG:Debug>:${undefined_dependency_one}> ) A modification in which each empty/undefined dependency is surrounded with its own generator expression works correctly too: set_property(TARGET example PROPERTY INTERFACE_LINK_LIBRARIES $<$<CONFIG:Debug>:${undefined_dependency_one}> $<$<CONFIG:Debug>:${undefined_dependency_two}> ) Is that a bug in how CMake handles generator expressions? Am I misunderstanding some CMake language concepts here? (all code tested with CMake 3.14.3 on Ubuntu 18.04) I would be grateful on any feedback about what's going on in that `foreach` loop. -- Tadeusz Andrzej Kadłubowski | Senior Software Engineer Berlin, Germany tadeusz.kadlubow...@pix4d.com www.pix4d.com -- Tadeusz Andrzej Kadłubowski | Senior Software Engineer Berlin, Germany tadeusz.kadlubow...@pix4d.com www.pix4d.com -- Powered by www.kitware.com Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ Kitware offers various services to support the CMake community. For more information on each offering, please visit: CMake Support: http://cmake.org/cmake/help/support.html CMake Consulting: http://cmake.org/cmake/help/consulting.html CMake Training Courses: http://cmake.org/cmake/help/training.html Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html Follow this link to subscribe/unsubscribe: https://cmake.org/mailman/listinfo/cmake