<div dir="ltr"><br><br><div class="gmail_quote"><div dir="ltr">Le mar. 28 août 2018 à  15:39, George PF <<a href="mailto:george.p.f@mail.com">george.p.f@mail.com</a>> a écrit :<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Hello,<br>
<br>
how can e.g. $<TARGET_OBJECTS:objlib> be iterated over in cmake?<br>
<br>
This builds the lib, but the loop is never run:<br>
<br>
  add_library(objlib12 OBJECT lib1.c lib2.c)<br>
  foreach(o IN LISTS $<TARGET_OBJECTS:objlib12>)<br>
    message("obj ${o}")<br>
  endforeach()<br>
<br>
But the $<TARGET_OBJECTS:objlib12> variable is set correctly, as this builds a shared library:<br>
<br>
  add_library(lib12 SHARED $<TARGET_OBJECTS:objlib12>)<br>
<br>
And the ;-separated list is visible when running this custom command via the 'test12' target:<br>
<br>
  add_custom_command(OUTPUT libtest.cc<br>
    COMMAND bash -c "echo '$<TARGET_OBJECTS:objlib12>'; echo > libtest.cc"<br>
    VERBATIM)<br>
  add_library(test12 SHARED libtest.cc)<br>
<br>
<br>
Why does the for loop completely ignore this variable?<br></blockquote><div><br></div><div>Because generator expressions are not handled in every cmake construct:</div><div>Â <a href="https://cmake.org/cmake/help/v3.12/manual/cmake-generator-expressions.7.html">https://cmake.org/cmake/help/v3.12/manual/cmake-generator-expressions.7.html</a><br></div><div><br></div><div>genex is probably not handled in foreach.</div></div><div><br></div><div><br></div>-- <br><div dir="ltr" class="gmail_signature"><div dir="ltr"><div><div dir="ltr"><div>Eric<br></div></div></div></div></div></div>