Reduced link interface - now for real

Alexander Neundorf neundorf at kde.org
Tue Nov 18 22:07:58 CET 2008


Hi,

maybe you noticed, now that we require 2.6.2 we can finally do reduced link 
interface correctly.
So, instead of setting the target property (the "debug" and "optimized" 
keywords are not supported there, so it can potentially fail if you just use 
the FOO_LIBRARIES variables there), there is a new keyword for 
TARGET_LINK_LIBRARIES.

So you create the targets as always and list the link libraries:
add_library(foo ${srcs} )
target_link_libraries(foo QtCore z png bz2)

Until now nothing has changed. Still all these libraries are used transitively 
if something else links to foo.
BUT if you use kde4_add_library(), the "link interface" is by default set to 
empty (*1). So none of these libraries is linked when something links to foo.
Next step (new !!!) is to add libraries to the "link interface" of foo:

target_link_libraries(foo LINK_INTERFACE_LIBRARIES QtCore)

This doesn't say"link foo against QtCore", instead this means "put QtCore into 
the link interface of foo". So if now something links against foo, it also 
links against QtCore.

(*1). Well, it is empty by default if the option 
KDE4_ENABLE_EXPERIMENTAL_LIB_EXPORT is TRUE. This is the case for kdelibs, 
for all other modules it is still FALSE by default.

So, what needs to be done ?

Remove setting the target property and instead insert the new 
target_link_libraries(... LINK_INTERFACE_LIBRARIES...) everywhere AND enable 
the aforementioned KDE4_ENABLE_EXPERIMENTAL_LIB_EXPORT manually in your build 
tree. Once you are sure enough that everything works, enable it fix, e.g. by 
putting a 
set(KDE4_ENABLE_EXPERIMENTAL_LIB_EXPORT  TRUE)
in the top level CMakeLists.txt, it must be after find_package(KDE4).

I won't have time to work on this this week, so please help.
I think we should really try to get this in and enabled unconditionally for 
KDE 4.2.

Alex

P.S. next week at this time my compile machine should be about 6 times as fast 
as it is now :-)


More information about the Kde-buildsystem mailing list