invitation: try compiling kdelibs using cmake

Alexander Neundorf neundorf at
Wed Jan 25 22:15:01 GMT 2006


as many of you probably know during the last two weeks I was busy with making 
trunk kdelibs build with cmake (

I think now I have reached a state were I can invite interested people to try 
compiling kdelibs with cmake.

I compiled kdelibs successfully on Slackware 9.1 (gcc 3.2.3) and FreeBSD 5.4 
(gcc 3.4.2) , Bill Hoffman was able to compile it on Debian (gcc 4.x).

kxmlcore and the directories which depend on it (kjs, khtml, kate) are still 
excluded from the build, neither gcc 3.2.3 on my slackware box nor gcc 
*3.4.2* on the FreeBSD box were able to compile it 

Right now everything compiles and links and correct install rules are created.
If the option "KDE4_BUILD_TESTS" is enabled, also most of the check_PROGRAMS 
are created (not all, I didn't understand all the custom rules yet).

cmake supports Makefiles for basically every UNIX including Mac OS X. It also 
support Makefiles for cygwin, mingw and cl, and it support project files for 
XCode and MSVC 6,7 and 8.

In order to compile kdelibs using cmake, you need cmake from current cmake 

$ cvs -d :pserver:anonymous at login
(respond with password cmake) 
Follow this command by checking out the source code:
$ cvs -d :pserver:anonymous at co CMake
(as usual: configure, make, make install)

Then build cmake: ./configure; make; make install

Then enter the kdelibs directory, and enter "cmake ."
Then the configure checks will be executed. If something isn't found, execute 
"ccmake ." and set the directories manually.
If Qt 4 wasn't found, either set it manually or set the QTDIR environment 

You can find all configure checks in kdelibs/ConfigureChecks.cmake.

The check_XXX() functions come from the CheckXXX.cmake files located in 
kdelibs/cmake/modules/ and from the cmake system module directory, 
usually /usr/local/share/CMake/Modules/. So if one of these checks go wrong, 
look in these files to see what they are doing.
To see what exactly went wrong, have a look at 

In ConfigureChecks.cmake there are also some checks like
find_package(Foo REQUIRED)
These commands look for a file named "FindFoo.cmake", located either in 
kdelibs/cmake/modules/ or the system cmake module directory (as above).
If something isn't found and you know it exists on your system, have a look at 
the FindFoo.cmake file.
To understand the commands used there, either read the cmake man page or read 
the documentation online: (*very 
recommded*). also the cmake Wiki: .

Ok, assume this step succeeded, simply run make. Chances are not too bad it 
will compile.

If not, the reason is usually a missing include directory or a missing link 

The build is specified in the files named CMakeLists.txt.
Important variables are CMAKE_SOURCE_DIR, CMAKE_BINARY_DIR, 
see .
Include directories are added using the include_directories() command.
Additional libraries is linked to using the target_link_libraries() command.

If you try to build it on Mac OS X or under Windows, you will immediately get 
an error message (see kdelibs/cmake/modules/FindKDE4.cmake . To get it 
working, remove the MESSAGE(FATAL_ERROR ...) from this file and see how far 
you get. Probably some of the system checks and FindFoo.cmake files have to 
be adjusted, compiler flags etc.

if you need to write additional FindFoo.cmake scripts, you can use the 
kdelibs/cmake/generate_findpackage_file script, written in Ruby. It generates 
simple generic cmake scripts which follow the cmake style.

If you have questions, please ask on the kde-buildsystem at mailing list, 
there are also two of the cmake developers subscribed. They want cmake to 
become the buildsystem for KDE 4.

Have fun
Work: alexander.neundorf AT -
Home: neundorf AT                -
      alex AT               -

More information about the kde-core-devel mailing list