Reducing library dependancies

Alexander Neundorf neundorf at kde.org
Thu Aug 14 23:33:47 BST 2008


On Friday 15 August 2008, Thiago Macieira wrote:
> Alexander Neundorf wrote:
...
> >Can you please explain (for an --as-needed newbie) ?
>
> http://mail.kde.org/pipermail/kde-buildsystem/2008-June/004806.html
>
> In that message, we were discussing whether QtXml should be listed in
> krosscore's dependencies. That's because QtXml is exposed in krosscore's
> API, but in only one header.
>
> So we had to make an all-or-nothing decision.
>
> With --as-needed, we could make the decision to keep it. If QtXml isn't
> used by the target, then the linker drops the dependency.

So with --as-needed unused but listed libraries are not linked directly ?
Dirk said something about some issues with that, it sounded quite complicated, 
I don't remember the details. Are there known issues with this ?

...
> >Did you add the libs to the targets ?
> >Adding some widely used libs to the "link interface" of some central
> > libs should help a lot.
>
> Probably. But I didn't do that, since I had no clue how. I was just
> changing every single target until things linked.

Ah, ok.
So this is done by setting the LINK_INTERFACE_LIBRARIES target property, as 
e.g. like this:

add_library(foo SHARED ${fooSrcs})
target_link_libraries(foo z bz2 jpeg)

set_target_properties(foo PROPERTIES 
                          LINK_INTERFACE_LIBRARIES "z;bz2" )

Which removes "jpeg" from the "interface". This is done e.g. for the kdecore 
library, so you can have a look there.

Alex




More information about the kde-core-devel mailing list