How to create libraries in KDE Frameworks 5

Stephen Kelly steveire at
Mon Aug 8 16:44:36 BST 2011


I've just pushed an update to the frameworks branch in kdelibs.git. I moved 
some classes from kdeui/itemviews to tier1/itemmodels/ and added them to the 
buildsystem in a library.

Just for the need of starting somewhere I created a top-level directory 
called tier1 to hold the library. As with all of this stuff we may have to 
refine how it's all organized as we go on.

One important difference to how things have been done before is that an 
export header is generated by cmake now instead of requiring the creation of 
a <libname>_export.h header which uses kdemacros.h.

Instead, the export header is created by the cmake macro 
kdelibs/cmake/modules/GenerateExportHeader.cmake. This macro will be part of 
cmake 2.8.6. 

After using kde4_add_library the macro generate_export_header should be 

kde4_add_library(itemmodels ...)

Obviously this should be part of kde4_add_library itself, but that failed to 
build for me when building kparts or kio (iirc) because kde4_add_library 
seems to be used for more than just libraries. I'll revisit that later.

The itemmodels_export.h file is created in the build directory instead of 
being checked in. That means that it must be installed with a referenece to 
the build dir, like 


Another important change is that I added the itemmodels library to the 
${KDE4_KDEUI_LIBS} variable. I also added some typedefs for classes which I 
refactored and renamed.

Thanks for reading. Please read the commits to see the details, including 
how I removed a KConfig dependency while keeping source compatibility (I 
think). Obviously we're not going to achieve 100% compatibility as we go on, 
but it's worth making early effort I think.

All the best,


More information about the kde-core-devel mailing list