cmake 2.6.2 now required - changes in handling shared libs

Ben Boeckel mathstuf at gmail.com
Tue Nov 25 23:02:05 CET 2008


On Monday 10 November 2008 19:00:50 Alexander Neundorf wrote:
> Hi,
>
> as of now cmake 2.6.2 is required to build KDE4 trunk.
>
> This brings some bugfixes, some nice features and one relatively big
> change, which concerns shared library handling.
>
> Warning: if you get linker errors or errors related to different build
> types/configurations (i.e. debug vs. release etc.) please let me know .
>
>
> Now straight on to the big change(TM).
>
> Short version:
> In kdelibs, when creating a shared lib, now also add the arguments
> "EXPORT kdelibsLibraryTargets" to the install(TARGETS ...) command, like
> this:
>
> install(TARGETS threadweaver EXPORT kdelibsLibraryTargets
>                              ${INSTALL_TARGETS_DEFAULT_ARGS})
>
> And to define a minimal link interface, do this:
>
> target_link_libraries(threadweaver
>                               LINK_INTERFACE_LIBRARIES ${QT_QTCORE_LIBRARY}
> )
>
>
> Now the long version (you should read it):
>
> The correct way to create and install a shared library is now:
>
> kde4_add_library(kfoo SHARED ${kfooSources} )
> target_link_libraries(kfoo kdecore ${QT_QTCORE_LIBRARY} ${ZLIB_LIBRARY})
>
> # No changes so far, but the next line is new.
> # It specifies to which libraries other targets will be linked which
> # link to libkfoo. By default these are all libraries kfoo links against,
> # which can lead to some unnecessary dependencies, slower startup, etc.
> # So we now specifiy which "link interface" the library kfoo has, ZLIB
> # is used only internally, so users of kfoo don't have to link against it:
>
> target_link_libraries(kfoo LINK_INTERFACE_LIBRARIES
>                            kdecore ${QT_QTCORE_LIBRARY})
>
> # Next change: shared libraries are now exported as targets, i.e. for every
> # library target a snippet of cmake code is created which can be included
> by # other cmake-using projects, and there this code will create "imported"
> # library targets. E.g. here we have the target kfoo, which can be
> referenced # within this project simply by its name "kfoo". With the
> exported (and then # imported) targets this is now also possible in
> external projects. # In order to have a target "exported", it must be
> installed and be marked as # belonging to an "export set", which can be
> assigned arbitrary names, here I # decided to name it "MyKFooExports":
>
> install(TARGETS kfoo EXPORT MyKFooExports 
${INSTALL_TARGETS_DEFAULT_ARGS})
>
> # The command above basically tells cmake to create the mentioned script
> # snippets. Now these must actually be installed themselves, so the
> following # command does that for all targets which have been marked as
> belonging to # "MyKFooExports":
> install(EXPORT MyKFooExports DESTINATION 
${DATA_INSTALL_DIR}/cmake/modules
>                              FILE MyKFooExportedLibraryTargets.cmake )
>
>
> Alex
>
> >> Visit http://mail.kde.org/mailman/listinfo/kde-devel#unsub to
> >> unsubscribe <<

Hi,

I am developing a project that uses KDE4 and I am trying to get the 
CMakeLists.txt to conform to the changes made upstream. I made the change to one 
of my libraries, but when I try to do it on another library which requires it, 
it errors with:

CMake Error: INSTALL(EXPORT "sigmod_EXPORTS" ...) includes target "sigmod" which 
requires target "sigcore" that is not in the export set.

How can I get the other library in the export set without having to install 
locally? Thanks.

--Ben

P.S. - I'm not subscribed, please CC me.




More information about the Kde-buildsystem mailing list