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
-- 

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

Reply via email to