[CMake] How to figure out the "type" of an imported library

Tamás Kenéz tamas.kenez at gmail.com
Thu Oct 29 15:42:50 EDT 2015


There's a TYPE property which should contain what you need:
https://cmake.org/cmake/help/latest/prop_tgt/TYPE.html

On Thu, Oct 29, 2015 at 4:53 PM, Attila Krasznahorkay <
attila.krasznahorkay at gmail.com> wrote:

> Dear All,
>
> In my code I'm trying to do something slightly tricky. I include packages
> that provide imported libraries (amongst other things). Then, because of
> how my project is structured, I don't make use of the imported libraries
> directly, but first make "copies" of them, and then make use of these
> copies in my build.
>
> (The reason is that I allow the project to override libraries that are
> available from the base packages as well. In which case components using
> this overridden library need to use this instance instead of the imported
> one. But if no such override is in place, I need to give the library a name
> that the components in the project expect to find it with.)
>
> If there would be a way in CMake to "clone" an imported library with a new
> name, that would be perfect for my use case. Since as far as I know there's
> no such thing, I use code like:
>
>       ...
>       add_library( ${libName} SHARED IMPORTED GLOBAL )
>       # Check which builds it is available for:
>       get_property( _builds TARGET ${prefix}_${libName}
>          PROPERTY IMPORTED_CONFIGURATIONS )
>       set_property( TARGET ${libName} PROPERTY
>          IMPORTED_CONFIGURATIONS ${_builds} )
>       ...
>
> Now, I recently started producing MODULE and INTERFACE libraries as well.
> So the first line in this code is no longer correct for all the imported
> libraries. Plus, for INTERFACE libraries the get_property call on
> IMPORTED_CONFIGURATIONS just fails with an error message.
>
> So now I wonder: Is there a target property on INTERFACE libraries that I
> could use to identify them? Like how there is the target property IMPORTED
> on the imported libraries.
>
> Cheers,
>             Attila
> --
>
> 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/20151029/be4127ad/attachment.html>


More information about the CMake mailing list