KDE Frameworks/Getting Started/Build/For Beginners

From KDE TechBase

Most of the software produced by KDE uses CMake to control how it is built and installed. If you're not used to building software that uses CMake, don't worry! This guide will teach you how.

Overview

The build process follows four basic steps:

Configuring
Determines what is available on the system, where to find it and how to use it. For example, do you have a C++ compiler? What arguments will need to be passed to it? Do you have the required libraries? Where can they be found?
Generating
Using the information gathered in the previous step, creates files that describe how to build the project.
Building
Calls the compiler, linker and other tools to create the libraries, executables and other files that are part of the "finished product". The descriptions generated in the previous step control how this is done.
Installing
Copies the files that were built (and possibly some other resources) to the right locations on the system.

There is also an optional extra step, running automated tests, which can happen either before or after installing.

CMake is used to perform the configuring and generating steps. The build description it generates is then used by another tool - typically Make on UNIX systems - to do the building and installing steps. Running the automated tests is done by CTest, which ships as part of CMake.

Prerequisites

Before you can start, you will need to install a few pieces of software.

Build environment
There is usually a fairly easy way to get the basic software you will need to build C++ programs. For example, most Linux distributions offer a "virtual package" that includes a C++ compiler, Make and other useful tools (eg: Debian calls this "build-essential"). On Windows, you might use Visual Studio, while OS X has XCode. You will need to find out how to get this for your particular system.
CMake
On Linux systems, you can usually get this through your package manager. Otherwise, you will need to download and install it. You will need at least version 2.8.12.
Qt
Almost all software produced by KDE is built on top of Qt, so it would be sensible to get hold of it now. Again, you can get it via your package manager on Linux, or download it yourself. Watch out, though! While a lot of KDE software is using Qt 5 (you'll probably want at least 5.4 if possible), some is still using Qt 4 (specifically 4.8). These are not compatible. The general rule is: software using KDE Frameworks needs Qt 5, software using kdelibs needs Qt 4.
Note
On most Linux distributions, packages come in several parts; specifically, the core package can be installed without the "development files" or the debugging information. When you are building software, you need to make sure the development packages of any libraries are installed (and you may want the debugging ones as well). For example, in addition to the "qtbase5" package, you will also want a package called something like "qtbase5-dev" or "qtbase5-devel"


Running CMake

TODO: examples, etc.

Building

make (and other systems?)

Installing

make install (and other systems?)

A Simpler Way

TODO: link to kdesrc-build instructions