[cmake-developers] Creating IMPORTED targets for both SHARED and STATIC libraries

David Cole david.cole at kitware.com
Mon Jun 25 11:06:54 EDT 2012


On Mon, Jun 25, 2012 at 11:02 AM, Stephen Kelly <steveire at gmail.com> wrote:
> David Cole wrote:
>
>> Otherwise,
>>
>>   target_link_libraries(tgt target_to_link_to)
>>
>> would be ambiguous if there were two or more "target_to_link_to" targets.
>>
>
> Yes. My understanding is that you can have a shared or static libc and a few
> others, so the distinction is between system libraries and userspace
> libraries and somehow the correct one is chosen?
>
> Thanks,
>
> Steve.
>
>
>
>
> --
>
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html
>
> Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ
>
> Follow this link to subscribe/unsubscribe:
> http://public.kitware.com/cgi-bin/mailman/listinfo/cmake-developers


When target_to_link_to names a target, there is no ambiguity. There's
only one target with that name. And it's either static or shared and
we know which one.

When it does not name a target, it names a library. If you specify the
library by full path name to the library file, again, there is no
ambiguity.

If you don't use the full path and just "name a library name", then
you have no idea what you're linking to... You'll end up linking to
whatever CMake and/or the linker thinks is best. (Honestly, I always
avoid ambiguity and don't have deep knowledge of how ambiguity in this
situation is resolved. I'd have to study up on the source code and
linker behaviors on the platforms I care about to figure it out...)


HTH,
David



More information about the cmake-developers mailing list