[CMake] Transitive linking and imported targets

Hendrik Sattler post at hendrik-sattler.de
Tue Mar 31 15:10:02 EDT 2009


Am Dienstag 31 März 2009 19:48:49 schrieb Tobias Rudolph:
> ----
> add_library( iLib SHARED IMPORTED )
> set_target_properties( iLib PROPERTIES IMPORTED_LOCATION "/opt/local/
> lib/libzip.dylib" )
>
> add_library( libFoo SHARED foo.cpp )
> target_link_libraries( libFoo iLib )
> ----
>
> According to the documentation, the imported target (iLib) is only
> know within libFoo and its subdirectories. So, when I try to link
> 'TestApp', it fails because the linker is looking for 'iLib' rather
> than '/opt/local/lib/libzip.dylib' due transitive linking (I suspect).
>
> Is that intended behavior?

Not sure but you don't need to link to iLib if you already link to libFoo 
unless libFoo exports interfaces from iLib.
See LINK_INTERFACE_LIBRARIES property.

HS



More information about the CMake mailing list