[CMake] Iterating over a generator expression list, specifically $<TARGET_OBJECTS:objlib> of an OBJECT library
George PF
george.p.f at mail.com
Tue Aug 28 09:39:45 EDT 2018
Hello,
how can e.g. $<TARGET_OBJECTS:objlib> be iterated over in cmake?
This builds the lib, but the loop is never run:
add_library(objlib12 OBJECT lib1.c lib2.c)
foreach(o IN LISTS $<TARGET_OBJECTS:objlib12>)
message("obj ${o}")
endforeach()
But the $<TARGET_OBJECTS:objlib12> variable is set correctly, as this builds a shared library:
add_library(lib12 SHARED $<TARGET_OBJECTS:objlib12>)
And the ;-separated list is visible when running this custom command via the 'test12' target:
add_custom_command(OUTPUT libtest.cc
COMMAND bash -c "echo '$<TARGET_OBJECTS:objlib12>'; echo > libtest.cc"
VERBATIM)
add_library(test12 SHARED libtest.cc)
Why does the for loop completely ignore this variable?
Regards
GPF
More information about the CMake
mailing list