[CMake] add_library object argument question
Petr Kmoch
petr.kmoch at gmail.com
Mon Jan 25 09:56:24 EST 2016
Hi,
the name given after the : in the TARGET_OBJECTS generator expression is
the logical (CMake) name of a target. There's no scoping in target names,
they're all at the same global scope. So if you have this:
add_library(A OBJECT ...)
then you will access its objects like this:
add_library(... $<TARGET_OBJECTS:A> ...)
regardless of whether this happens in the same CMakeList or an entirely
different one (parent, child, sibling, it makes not difference).
Which also means there's no need for progressively going up levels: just
use all the A, B, C, D directly in the toplevel add_library call.
Petr
On Mon, Jan 25, 2016 at 3:34 PM, Vania Joloboff <vania.joloboff at inria.fr>
wrote:
> Hi
>
> In a library project there are two level of subdirectories that contain
> modules
> to be included into the main library.
> In other words, directory lib contains subdirectories foo and bar
> Subdirectory foo contains A and B.
> Subdirectory bar contains C and D.
> All of the objects from A, B, C and D must belong to the library
>
> I understand I can use at the bottom levels A, B, C, D
> add_library() with the OBJECT argument
> and I should be able to use add_library() in the top directory
> to collect all of the object files from the subdirectories
>
> add_library(... $<TARGET_OBJECTS:some_name> ...)
>
> for each of the sub directories. But the documentation is unclear
> about the naming schema to use. What is the syntax/meaning of some_name ?
>
> add_library(... $<TARGET_OBJECTS:foo/A> $<TARGET_OBJECTS:foo/B>
> $<TARGET_OBJECTS:bar/C> $<TARGET_OBJECTS:bar/D> ...)
>
> Or I need to gather at level foo and bar the objects from bottom layer
> and recursively make them go up one level by one level ?
>
> Thanks
> --
>
> 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:
> http://public.kitware.com/mailman/listinfo/cmake
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/cmake/attachments/20160125/d29a2752/attachment.html>
More information about the CMake
mailing list