Guidelines and HOWTOs/Build from source: Difference between revisions

From KDE Community Wiki
(→‎Qt 5: init-repository script is broken in the dev branch)
(→‎Qt5-based dependencies: make libdbusmenu-qt not depend on doxygen)
Line 83: Line 83:
   $ mkdir build
   $ mkdir build
   $ cd build
   $ cd build
   $ cmake -DCMAKE_INSTALL_PREFIX=$KF5 -DCMAKE_PREFIX_PATH=$KF5 ..
   $ cmake -DCMAKE_INSTALL_PREFIX=$KF5 -DCMAKE_PREFIX_PATH=$KF5 -DWITH_DOC:bool=OFF ..
   $ make
   $ make
   $ make install
   $ make install

Revision as of 23:00, 19 May 2013

Build requirements

This section provides information about hard (required) and optional software packages needed to build the KDE Framework.

kdelibs dependencies

  • deb-based distributions (Debian, Ubuntu...): All the dependencies used for the packages can be installed by running
$ apt-get build-dep {packagename}
  • for instance on Ubuntu:
$ sudo apt-get build-dep kdelibs5
  • OpenSuSE: All the dependencies used for building kdelibs can be installed by running:
$ zypper si -d kdelibs5
  • Fedora: All the dependencies used for building kdelibs can be installed by running:
$ yum-builddep kdelibs5

CMake from Git

You need a unreleased version of CMake for KDE Frameworks 5. Kitware hosts a nightly binary snapshot if you want to skip building it (scroll to the bottom to get the latest). Alternatively you can build it straight from their git:

  • Choose an install prefix, for instance
 $ export KF5=$HOME/kf5

To avoid repetition of command you can append ~/.bashrc file with above line and execute,

 $ source ~/.bashrc  
  • Checkout and install Latest version of CMake using Git.
 $ git clone git://cmake.org/cmake.git
 $ cd cmake
 $ ./configure --prefix=$KF5
 $ make
 $ make install

Extra CMake Modules

  • Checkout and build extra-cmake-modules
 $ git clone git://anongit.kde.org/extra-cmake-modules
 $ cd extra-cmake-modules
 $ cmake -DCMAKE_INSTALL_PREFIX=$KF5 . 
 $ make 
 $ make install

Qt 5

To build all of qt5 execute:

 $ git clone git://gitorious.org/qt/qt5.git --branch stable
 $ cd qt5
 $ ./init-repository
 $ mkdir build
 $ cd build
 $ ../configure -prefix $KF5 -opensource -confirm-license -nomake tests -nomake demos -nomake examples -xcb -qpa xcb -no-gtkstyle
 $ make
 $ make install

To update qt5 later:

 $ git pull
 $ git submodule update

If you don't have enough time and disk space for all of qt5, you could restrict yourself to separate checkouts of qtbase.git, qtsvg.git and qtx11extras.git, this is enough to build kdelibs frameworks (but not enough for plasma-framework). NOTE: to ensure you have the same stuff as everyone else, you should check out c002a2742 in qtbase.git rather than latest dev).

NOTE for ArchLinux users: qtwebkit uses python to generate some files, but it uses python2 syntax. So if you have installed python3, you'll get a compilation error on the file itab.py bevause print is no longer a statement, but a function. So, you would like to make /usr/bin/python to point to /usr/bin/python2. See also https://wiki.archlinux.org/index.php/Python

Qt5-based dependencies

First, let's setup a "kde:" prefix for git commands. Add the following text to your ~/.gitconfig:

 [url "git://anongit.kde.org/"]
    insteadOf = kde:
 [url "ssh://[email protected]/"]
    pushInsteadOf = kde:

At this point you can continue building things by hand, or download http://www.davidfaure.fr/kde/kf5-qt5-kdesrc-buildrc into your source dir, adjust the paths and run kdesrc-build.

To build phonon by hand execute:

 $ git clone kde:phonon --branch phonon4qt5
 $ mkdir phonon/build
 $ cd phonon/build
 $ cmake -DCMAKE_INSTALL_PREFIX=$KF5 -DCMAKE_PREFIX_PATH=$KF5 ..
 $ make
 $ make install

Then build attica (branch master), and strigi (branch master, with submodules) and install them into the same prefix.

To check out and build libdbusmenu-qt execute:

 $ bzr branch lp:libdbusmenu-qt
 $ cd libdbusmenu-qt
 $ mkdir build
 $ cd build
 $ cmake -DCMAKE_INSTALL_PREFIX=$KF5 -DCMAKE_PREFIX_PATH=$KF5 -DWITH_DOC:bool=OFF ..
 $ make
 $ make install

Build KDE frameworks

Current state of KDE framework exist in frameworks branch of kdelibs.

Execute:

 $ git clone kde:kdelibs --branch frameworks
 $ mkdir  kdelibs/build 
 $ cd kdelibs/build 
 $ cmake -DCMAKE_INSTALL_PREFIX=$KF5 -DCMAKE_PREFIX_PATH=$KF5 ..
 $ make
 $ make install

Debugging options: The default debug setting is RelWithDebInfo which is suitable for most developers. If you are debugging frameworks and cannot trace the code, you can set CMAKE_BUILD_TYPE to "DebugFull" to get a slower build but with even more verbose debugging (backtrace) information. For this replace -DCMAKE_BUILD_TYPE=RelWithDebInfo in the above cmake command with -DCMAKE_BUILD_TYPE=DebugFull.

Updating the already built framework: If the source code has been checked from a branch, it is possible to update the source code with newly added changes and build again. Usually only changing parts will be built, so this operation would be faster than building the source code from scratch.

Go to your source directory and execute following commands.

 $ git pull --rebase
 $ cd build
 $ make
 $ make install

Plasma

plasma-framework

The Plasma libraries and runtime components have moved into a new repository: plasma-framework. To get libplasma and the QML support for Plasma, after building kdelibs as shown above, execute the following commands:

 $ git clone kde:plasma-framework
 $ mkdir  plasma-framework/build 
 $ cd plasma-framework/build 
 $ cmake -DCMAKE_INSTALL_PREFIX=$KF5 -DCMAKE_PREFIX_PATH=$KF5 ..
 $ make
 $ make install

kde-workspace & Friends

Plasma-based components such as the code in the kde-workspace repo is being ported inside those repositories in the frameworks-scratch branch. This works for the kde-workspace, kdeplasma-addons and kdeexamples repositories. You can install whatever is already ported and enabled using the following commands:

 $ git clone kde:kde-workspace
 $ mkdir  kde-workspace/build 
 $ cd kde-workspace/build 
 $ git checkout frameworks-scratch
 $ cmake -DCMAKE_INSTALL_PREFIX=$KF5 -DCMAKE_PREFIX_PATH=$KF5 ..
 $ make
 $ make install

If you want to build one of the other repositories, just replace kde-workspace with e.g. kdeplasma-addons.

Runtime setup

To use your new KF5 install prefix (let's call it $KF5) :

export XDG_DATA_DIRS=$KF5/share:$XDG_DATA_DIRS
export XDG_CONFIG_DIRS=$KF5/etc/xdg:$XDG_CONFIG_DIRS
export PATH=$KF5/bin:$PATH
export LD_LIBRARY_PATH=$KF5/lib:$QTDIR/lib:$LD_LIBRARY_PATH
   (lib64 instead of lib, on OpenSUSE and similar)
export QT_PLUGIN_PATH=$KF5/lib/plugins:$QTDIR/plugins:$QT_PLUGIN_PATH
   (lib64 instead of lib, on OpenSUSE and similar)
export QML2_IMPORT_PATH=$KF5/lib/qml

To use separate user settings for KF5:

export XDG_DATA_HOME=$HOME/.local5
export XDG_CONFIG_HOME=$HOME/.config5
export XDG_CACHE_HOME=$HOME/.cache5

To be able to compile other stuff on top of KF5:

export CMAKE_PREFIX_PATH=$KF5:$CMAKE_PREFIX_PATH

To get more information out of qDebug statements (i.e. make it more like kDebug) :

export QT_MESSAGE_PATTERN='%{appname}(%{pid})/%{category} %{function}: %{message}'

Don't bother with KDEDIR and KDEHOME etc. this stuff isn't used anymore.

Running unit tests

You need a separate DBus session because the dbus server needs to have the right value of XDG_DATA_DIRS, in order to find $KF5/share/dbus-1/services for starting services (e.g. kded5).

eval `dbus-launch`
kdeinit5
make test

Warning: never start a KDE4 application in this separate DBus session, it would conflict with your running KDE4 desktop.