[CMake] Get libraries from target

Tiago Macarios tiagomacarios at gmail.com
Tue Nov 8 18:05:10 EST 2016


Hi,

Is there a way for me to get CMake libraries out of a target?

For example:

target_link_libraries(A B C)

Can I get B and C from A?

What I am trying to do:
We are working on adding include-what-you-use into our build system and
some of the libraries have their on mapping files. So I was wondering if I
could somehow "attach" the mapping file to the target and then
"reconstruct" a mapping file for each target.

For example:

Library B and C have their own mapping, so I would:
set_target_properties(B
    PROPERTIES mapping /path/to/fileB)
set_target_properties(C
    PROPERTIES mapping /path/to/fileC)

Then a function would reconstruct a mapping for target A:
set_target_properties(A
    PROPERTIES mapping /path/to/fileA)

create_mapping_function(A):
     loop over dependencies of A
     get all mappings
     recreate a mapping file with all dependencies:

{ ref: "/path/to/fileA" },
{ ref: "/path/to/fileB" }
{ ref: "/path/to/fileC" }
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/cmake/attachments/20161108/32eb5f8f/attachment.html>


More information about the CMake mailing list