[CMake] Get libraries from target

Jakob van Bethlehem jsvanbethlehem at gmail.com
Wed Nov 9 07:53:09 EST 2016


Hej,

You should be able to query the LINK_LIBRARIES (and maybe some related
properties), see
https://cmake.org/cmake/help/v3.6/prop_tgt/LINK_LIBRARIES.html

Sincerely,
Jakob


On Wed, Nov 9, 2016 at 12:05 AM, Tiago Macarios <tiagomacarios at gmail.com>
wrote:

> 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" }
>
>
> --
>
> 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/20161109/460965e1/attachment-0001.html>


More information about the CMake mailing list