KDb/Build: Difference between revisions

From KDE Community Wiki
< KDb
 
(49 intermediate revisions by the same user not shown)
Line 1: Line 1:
{{ForDevelopers}}
{{Note|Work in progress, can be obsolete}}
 
{{Note|&nbsp;
*This page is intended for power users and developers.
*This recipe was tested on Linux only.
*Follow this guide as an ordinary user. Do not login as '''root'''!
*Some distributions (*Buntu, Arch) are now making Qt5 the defaulft! That does not work. Do not try to use Qt5, use Qt4. Make sure packages like qt4-default are installed. You might have to also switch your default Qt setup with a tool like qtchooser.
}}


==Requirements==
==Requirements==
===Required software components===
===Required software components===
*'''C++ compiler''', e.g. gcc
*'''C++ compiler''', e.g. gcc
*'''Qt 4.7.0''' or newer (both libraries and development files/tools)
*'''Qt 5.4.0''' or newer (both libraries and development files/tools)
*'''SQLite''' 3.6.16 or newer (both the library and development files)
*Extra CMake Modules (ECM) 1.8.0 or newer
*KDE Development Frameworks (KF5) 5.16.0 or newer (both libraries and development files/tools; can be installed from packages or see the [[Frameworks]] page for build instructions; https://kdesrc-build.kde.org can be used for a quick and easy build)
*ICU (both libraries and development files; packages are usually called: icu, libicu and libicu-devel)
 
Detailed requirements are displayed on configure stage, KDb won't try to build if they are not met. You can also look for the "find_package" lines in the top level CMakeLists.txt file.


===Optional components===
===Optional components===
*'''libpq''' 7.3 or newer for PostgreSQL support (both the access library and development files)
All database drivers are optional, what gives you a full choice.
{{Note|PostgreSQL Server installation is not needed for building Predicate or software that uses Predicate. The server is needed only for running the actual database service. Any installaton on separate (e.g. remote) machine can be reused.}}
*For SQLite files support (a base format for .kexi files, truly recommended): '''SQLite 3''' 3.6.16 or newer (library and development files), usual package names: libsqlite3-0, libsqlite3-dev (Ubuntu), sqlite3-devel (openSUSE).
**Command-like client 'sqlite3' is needed as a build dependency, its usual package name is 'sqlite3'.
**SQLite needs to be built with extensions support. The configuration script checks this by looking for [https://www.sqlite.org/compile.html#omit_load_extension ''OMIT_LOAD_EXTENSION''] value in output of ''pragma compile_options;'' command in the sqlite3 shell.  
**Unicode support for the SQLite database driver: '''ICU''' (both the library and development files), SQLite database driver won't work without it; usual package names: libicu51_2 (openSUSE), libicu52 (Ubuntu), libicu-devel (openSUSE), libicu-dev (Ubuntu)


*'''libmysqlclient''' (both the access library and development files)
*For PostgreSQL support: '''libpq, postgresql server devel''' 9.x or newer (both the access library and client/server development files), usual package names: libpq5, libpq-dev (ubuntu), postgresql{version}-devel (openSUSE), postgresql-server-dev-{version} (ubuntu). Ubuntu needs 3 packages (1 lib, 2 devel), openSUSE 2 packages (1 lib, 1 devel).
{{Note|MySQL Server installation is not needed for building Predicate or software that uses Predicate. The server is needed only for running the actual database service. Any installaton on separate (e.g. remote) machine can be reused.}}
{{Note|PostgreSQL Server installation is not needed for building KDb or software that uses it. The server is needed only for running the actual database service. Any installation on separate (e.g. remote) machine can be reused.}}
 
*For MySQL support: '''libmysqlclient''' 5.x or newer (both the access library and development files)
{{Note|MySQL Server installation is not needed for building KDb or software that uses KDb. The server is needed for running actual database service. Any installation on separate (e.g. remote) machine can be reused.}}
 
*TODO: <strike>For Sybase and MSSQL support: '''libfreetds''' (both the access library and development files), usual package names: libfreetds (openSUSE), freetds-devel (openSUSE), libfreetds-common (Ubuntu), freetds-dev (Ubuntu)</strike>
 
*TODO: <strike>For Xbase files support: '''xbase''' (both the access library and development files), usual package names: xbase (openSUSE), xbase-devel (openSUSE), libxbase2.0-0 (Ubuntu), libxbase2.0-dev (Ubuntu)</strike>
 
{{Note|Sybase/MSSQL and xBase support is disabled for now --[[User:Jstaniek|Jstaniek]] ([[User talk:Jstaniek|talk]]) 14:14, 9 October 2014 (UTC)}}


==Get the source code==
==Get the source code==
Download Predicate source code as explained on the [[../Download|Download]] page. The root directory of the source code is referred as {predicate-source-dir}.
Download KDb source code as explained on the [[../Download|Download]] page. The root directory of the source code is referred as <tt>{kdb-source-dir}</tt>, and the root build directory is referred as <tt>{kdb-build-dir}</tt>.


==Configuration==
==Configuration==
===Option 1: Configuration for global installation===
===Configuration Variant 1: for global installation===
If you want to have Predicate installed in the global PREFIX, type:
Not recommended for developers, instead see Variant 2 below. You can install KDb in the global PREFIX ({kdb-install-prefix} = /usr by default), but this is not recommended as can be in conflict with existing or future installations, e.g. binaries installed from packages. Type:
 
mkdir {kdb-build-dir}
cd {kdb-build-dir}
cmake {options} {kdb-source-dir}
 
This will configure installation of KDb libraries into /usr/local/lib, its binaries into /usr/local/bin, etc.
 
To change that to /usr/lib (really really not recommended for developers), etc., change the cmake command to:
cmake '''-DCMAKE_INSTALL_PREFIX=/usr''' {options} {kdb-source-dir}
 
===Configuration Variant 2: for local installation===
Here is recommended directory structure:
;$HOME/kdb/src:{kdb-source-dir}
;$HOME/kdb/build:{kdb-build-dir}
;$HOME/kdb/inst:{kdb-install-prefix} directory that KDb will be installed in.


  mkdir {predicate-build-dir}
  mkdir {kdb-build-dir}
  cd {predicate-build-dir}
  cd {kdb-build-dir}
  cmake {predicate-source-dir}
  cmake '''-DCMAKE_INSTALL_PREFIX={kdb-install-prefix}'''  {options} {kdb-source-dir}
 
This will configure build dir as {kdb-build-dir} and installation of KDb libraries into {kdb-install-prefix}/lib(64), its binaries into {kdb-build-dir}/bin, etc.
 
===CMake options===
<tt>{options}</tt> mean some extra cmake options that let you to control how KDb is built and what is included:
*CMAKE_BUILD_TYPE: set up [[#Debugging_options|debugging]])
*BUILD_EXAMPLES: Build [[#Enabling_tests|example]] applications showing how to use KDb
*BUILD_TESTING: Enable [[#Enabling_tests|tests]] that can be then executed to control quality of KDb
*KDB_DEBUG_GUI: Enable to show a debugger window with internals of KDb
*BUILD_TEST_COVERAGE: Advanced: enable to build analysis of the percent of code that is covered by tests
*CMAKE_C_FLAGS, CMAKE_CXX_FLAGS: speed up [[#Speed_up_the_build|linking on Linux]]


This will configure installation of Predicate libraries into /usr/local/lib, its binaries into /usr/local/bin, etc.  
Instead of using command line, you can also alter these options once you configure the build by invoking an interactive tool:
ccmake .
in <tt>{kdb-build-dir}</tt>, then to reconfigure press <tt>c</tt> key when you're done and then press <tt>q</tt> key.


To change that to /usr/lib, etc., change the cmake command to:
Read about more CMake options [http://www.cmake.org/cmake/help/v2.8.12/cmake.html#section_Options here].
cmake -DCMAKE_INSTALL_PREFIX=/usr {predicate-source-dir}


===Option 2: Configuration for local installation===
At any time in the <tt>{kdb-build-dir}</tt> you can type
To void installing to global location like /usr, for whatever reason, for your convenience, [https://projects.kde.org/projects/playground/libs/predicate/repository/revisions/master/changes/tools/config-for-local.sh '''config-for-local.sh'''] script has been prepared with default configuration settings. You can find it in tools/ subdirectory of the source code. Use it as follows:
cmake .
and the configuration step will display you the current selection of options. Following sections are available:
*"The following features have been enabled" - with explanation of each feature
*"The following OPTIONAL packages have been found" - sometimes with required version
*"The following REQUIRED packages have been found" - sometimes with required version
*"The following features have been disabled" - useful to see more features that you can enable


First make sure '''$PREDICATE_INSTALL_PREFIX''' environment variable is set to directory that is indended PREFIX for the local Predicate installation, e.g. '''$HOME/predicate/install'''. Then:


mkdir -p {predicate-build-dir}
cd {predicate-build-dir}


(better pick your {predicate-build-dir} outside of the source code)
TODO: <strike>To avoid installing to global a location such as /usr, for whatever reason, for your convenience, [https://projects.kde.org/projects/playground/libs/predicate/repository/revisions/master/changes/tools/config-for-local.sh '''config-for-local.sh'''] script has been prepared with default configuration settings. You can find it in tools/ subdirectory of the source code. Use it as follows:


{predicate-source-dir}/tools/config-for-local.sh {predicate-source-dir}
1. Make sure '''$PREDICATE_INSTALL_PREFIX''' environment variable is set to directory that is indended PREFIX for the local Predicate installation, e.g. '''$HOME/predicate/inst'''.


Note that to have the Predicate installation work environment variables PATH, LD_LIBRARY_PATH, PKG_CONFIG_PATH, QT_PLUGIN_PATH should be set properly. Double check this:
2. To have the Predicate installation work environment variables PATH, LD_LIBRARY_PATH, PKG_CONFIG_PATH, QT_PLUGIN_PATH should be set properly. Double check this:
  _libdir=lib # or lib64 for 64-bit platforms
  _libdir=lib # or lib64 for 64-bit platforms
  export PATH=$PREDICATE_INSTALL_PREFIX/bin:$PATH
  export PATH=$PREDICATE_INSTALL_PREFIX/bin:$PATH
Line 49: Line 101:
  export QT_PLUGIN_PATH=$PREDICATE_INSTALL_PREFIX/$_libdir/plugins/predicate:$QT_PLUGIN_PATH
  export QT_PLUGIN_PATH=$PREDICATE_INSTALL_PREFIX/$_libdir/plugins/predicate:$QT_PLUGIN_PATH


===Option 3: Configuration for re-using local KDE 4 installation===
3. Then:
If you use local KDE 4 installation, e.g. for developed applications, for your convenience, [https://projects.kde.org/projects/playground/libs/predicate/repository/revisions/master/changes/tools/config-for-kde.sh '''config-for-kde.sh'''] script has been prepared with default configuration settings. You can find it in tools/ subdirectory of the source code. Use it as follows:
mkdir -p {predicate-build-dir}
cd {predicate-build-dir}
 
(better pick your <tt>{predicate-build-dir}</tt> outside of the source code)
 
{predicate-source-dir}/tools/config-for-local.sh {cmake-options}


First make sure '''$KDEDIRS''' environment variable is set to directory that is intended PREFIX for the local KDE 4 installation, e.g. '''$HOME/kde4/installs'''. Then:
For explanation of <tt>{cmake_options}</tt>, see the [[#cmake_options|cmake options]] section.</strike>


mkdir -p {predicate-build-dir}
<strike>===Variant 3: Configuration for re-using local KDE 4 installation===
cd {predicate-build-dir}
Here is recommendation of a directory structure:
;$HOME/kde4/src/predicate:{predicate-source-dir}
;$HOME/kde4/build/predicate:{predicate-build-dir}
;$HOME/kde4/inst:directory that Predicate will be installed in, shared with other locally installed KDE software


(better pick your {predicate-build-dir} outside of the source code)
If you use local KDE 4 installation, e.g. for developed applications, for your convenience, [https://projects.kde.org/projects/playground/libs/predicate/repository/revisions/master/changes/tools/config-for-kde.sh '''config-for-kde.sh'''] script has been prepared with default configuration settings. You can find it in tools/ subdirectory of the source code. Use it as follows:


{predicate-source-dir}/tools/config-for-kde.sh {predicate-source-dir}
1. Make sure '''$KDEDIRS''' environment variable is set to directory that is intended PREFIX for the local KDE 4 installation, e.g. '''$HOME/kde4/inst'''.


Note that to have the Predicate installation work environment variables PATH, LD_LIBRARY_PATH, PKG_CONFIG_PATH, QT_PLUGIN_PATH should be set set properly. Several of these are probably already set for the local KDE 4 installation but better double check this:
2. To make the Predicate installation work, environment variables PATH, LD_LIBRARY_PATH, PKG_CONFIG_PATH, QT_PLUGIN_PATH should be set properly. Several of these are probably already set for the local KDE 4 installation but better double check this:
  _libdir=lib # or lib64 for 64-bit platforms
  _libdir=lib # or lib64 for 64-bit platforms
  export PATH=$KDEDIRS/bin:$PATH
  export PATH=$KDEDIRS/bin:$PATH
Line 68: Line 128:
  export QT_PLUGIN_PATH=$KDEDIRS/$_libdir/kde4/plugins:$QT_PLUGIN_PATH
  export QT_PLUGIN_PATH=$KDEDIRS/$_libdir/kde4/plugins:$QT_PLUGIN_PATH


===Setting up debug build===
3. Then:
'''For any configuration option:''' to build with debug information add '''-DCMAKE_BUILD_TYPE=DebugFull''' to the '''cmake''' command.
mkdir -p {predicate-build-dir}
cd {predicate-build-dir}
 
(better pick your <tt>{predicate-build-dir}</tt> outside of the source code)


===Setting up building with tests===
{predicate-source-dir}/tools/config-for-kde.sh {cmake-options}
To build with tests enabled (both unit tests and functional tests), add '''-DBUILD_TESTING=ON''' to the '''cmake''' command.
 
For explanation of <tt>{cmake_options}</tt>, see the [[#cmake_options|cmake options]] section.
</strike>
 
==Debugging options==
'''Recommended for accurate debugging:''' The default debug setting is <tt>RelWithDebInfo</tt> which is suitable only for obtaining backtraces. If you are developing code that uses KDb or developing KDb itself you may want to precisely set breakpoints, watch points, use step by step command accurately in your debugger, rely on assertions, debug and warning messages. If this is the case, you can replace <tt>-DCMAKE_BUILD_TYPE=RelWithDebInfo</tt> cmake option with:
-DCMAKE_BUILD_TYPE=Debug
 
Using <tt>Debug</tt> results in a slower code. That can be acceptable in most cases during testing and development given the machine is fast enough. It is not intended for production releases of the software unless you know what you're doing.
 
==Enabling tests==
To build with tests enabled (both unit tests and functional tests), add '''-DBUILD_TESTING=ON''' to the '''cmake''' command before building.


==Build==
==Build==
Line 78: Line 152:
   make
   make
   make install
   make install
==Reconfiguration==
To completely reconfigure, remove the <tt>{kdb-build-dir}</tt> directory completely and repeat the configuration process.
==Speed up the build==
'''Recommended: Taking advantage of multi-core processors.''' On dual-core machines compilation can be '''greatly speed up''' with the <tt>-j</tt> parameter of the <tt>make</tt> program. For example whenever you are invoking <tt>make</tt>, for dual-core processor try to invoke:
make -j3
Similarly, for quad-core processor:
make -j5
Generaly for ''N-core'' processor use the <tt>-jN+1</tt> parameter.
'''Recommended: Faster linking on Linux.''' [http://en.wikipedia.org/wiki/Linker_%28computing%29 Linking] can take noticeable time in large software such as Calligra. On Linux [http://en.wikipedia.org/wiki/Gold_%28linker%29 Gold linker] can be used to speed up this task. If you're building for Linux, install the Gold linker package and add the following to your <tt>cmake</tt> command:
-DCMAKE_C_FLAGS=-fuse-linker-plugin -DCMAKE_CXX_FLAGS=-fuse-linker-plugin
(you can set the <tt>CMAKE_C_FLAGS</tt> adn <tt>CMAKE_CXX_FLAGS</tt> variables in your <tt>{build dir}/CMakeCache.txt</tt> file either using text editor or the <tt>ccmake</tt> tool)


==Notes==
==Notes==
To enable debugging inside of bison (.y) file, put this in .gdbinit:
To enable debugging inside of bison (.y) file, put this in your <tt>$HOME/.gdbinit</tt> config file:
  set directories ~/dev/src/predicate/Predicate/parser
  set directories {kdb-source-dir}/src/parser
(change {kdb-source-dir} to appropriate absolute path)

Latest revision as of 20:37, 10 November 2016

Note

Work in progress, can be obsolete


Note

 
  • This page is intended for power users and developers.
  • This recipe was tested on Linux only.
  • Follow this guide as an ordinary user. Do not login as root!
  • Some distributions (*Buntu, Arch) are now making Qt5 the defaulft! That does not work. Do not try to use Qt5, use Qt4. Make sure packages like qt4-default are installed. You might have to also switch your default Qt setup with a tool like qtchooser.


Requirements

Required software components

  • C++ compiler, e.g. gcc
  • Qt 5.4.0 or newer (both libraries and development files/tools)
  • Extra CMake Modules (ECM) 1.8.0 or newer
  • KDE Development Frameworks (KF5) 5.16.0 or newer (both libraries and development files/tools; can be installed from packages or see the Frameworks page for build instructions; https://kdesrc-build.kde.org can be used for a quick and easy build)
  • ICU (both libraries and development files; packages are usually called: icu, libicu and libicu-devel)

Detailed requirements are displayed on configure stage, KDb won't try to build if they are not met. You can also look for the "find_package" lines in the top level CMakeLists.txt file.

Optional components

All database drivers are optional, what gives you a full choice.

  • For SQLite files support (a base format for .kexi files, truly recommended): SQLite 3 3.6.16 or newer (library and development files), usual package names: libsqlite3-0, libsqlite3-dev (Ubuntu), sqlite3-devel (openSUSE).
    • Command-like client 'sqlite3' is needed as a build dependency, its usual package name is 'sqlite3'.
    • SQLite needs to be built with extensions support. The configuration script checks this by looking for OMIT_LOAD_EXTENSION value in output of pragma compile_options; command in the sqlite3 shell.
    • Unicode support for the SQLite database driver: ICU (both the library and development files), SQLite database driver won't work without it; usual package names: libicu51_2 (openSUSE), libicu52 (Ubuntu), libicu-devel (openSUSE), libicu-dev (Ubuntu)
  • For PostgreSQL support: libpq, postgresql server devel 9.x or newer (both the access library and client/server development files), usual package names: libpq5, libpq-dev (ubuntu), postgresql{version}-devel (openSUSE), postgresql-server-dev-{version} (ubuntu). Ubuntu needs 3 packages (1 lib, 2 devel), openSUSE 2 packages (1 lib, 1 devel).

Note

PostgreSQL Server installation is not needed for building KDb or software that uses it. The server is needed only for running the actual database service. Any installation on separate (e.g. remote) machine can be reused.


  • For MySQL support: libmysqlclient 5.x or newer (both the access library and development files)

Note

MySQL Server installation is not needed for building KDb or software that uses KDb. The server is needed for running actual database service. Any installation on separate (e.g. remote) machine can be reused.


  • TODO: For Sybase and MSSQL support: libfreetds (both the access library and development files), usual package names: libfreetds (openSUSE), freetds-devel (openSUSE), libfreetds-common (Ubuntu), freetds-dev (Ubuntu)
  • TODO: For Xbase files support: xbase (both the access library and development files), usual package names: xbase (openSUSE), xbase-devel (openSUSE), libxbase2.0-0 (Ubuntu), libxbase2.0-dev (Ubuntu)

Note

Sybase/MSSQL and xBase support is disabled for now --Jstaniek (talk) 14:14, 9 October 2014 (UTC)


Get the source code

Download KDb source code as explained on the Download page. The root directory of the source code is referred as {kdb-source-dir}, and the root build directory is referred as {kdb-build-dir}.

Configuration

Configuration Variant 1: for global installation

Not recommended for developers, instead see Variant 2 below. You can install KDb in the global PREFIX ({kdb-install-prefix} = /usr by default), but this is not recommended as can be in conflict with existing or future installations, e.g. binaries installed from packages. Type:

mkdir {kdb-build-dir}
cd {kdb-build-dir}
cmake {options} {kdb-source-dir}

This will configure installation of KDb libraries into /usr/local/lib, its binaries into /usr/local/bin, etc.

To change that to /usr/lib (really really not recommended for developers), etc., change the cmake command to:

cmake -DCMAKE_INSTALL_PREFIX=/usr {options} {kdb-source-dir}

Configuration Variant 2: for local installation

Here is recommended directory structure:

$HOME/kdb/src
{kdb-source-dir}
$HOME/kdb/build
{kdb-build-dir}
$HOME/kdb/inst
{kdb-install-prefix} directory that KDb will be installed in.
mkdir {kdb-build-dir}
cd {kdb-build-dir}
cmake -DCMAKE_INSTALL_PREFIX={kdb-install-prefix}  {options} {kdb-source-dir}

This will configure build dir as {kdb-build-dir} and installation of KDb libraries into {kdb-install-prefix}/lib(64), its binaries into {kdb-build-dir}/bin, etc.

CMake options

{options} mean some extra cmake options that let you to control how KDb is built and what is included:

  • CMAKE_BUILD_TYPE: set up debugging)
  • BUILD_EXAMPLES: Build example applications showing how to use KDb
  • BUILD_TESTING: Enable tests that can be then executed to control quality of KDb
  • KDB_DEBUG_GUI: Enable to show a debugger window with internals of KDb
  • BUILD_TEST_COVERAGE: Advanced: enable to build analysis of the percent of code that is covered by tests
  • CMAKE_C_FLAGS, CMAKE_CXX_FLAGS: speed up linking on Linux

Instead of using command line, you can also alter these options once you configure the build by invoking an interactive tool:

ccmake .

in {kdb-build-dir}, then to reconfigure press c key when you're done and then press q key.

Read about more CMake options here.

At any time in the {kdb-build-dir} you can type

cmake .

and the configuration step will display you the current selection of options. Following sections are available:

  • "The following features have been enabled" - with explanation of each feature
  • "The following OPTIONAL packages have been found" - sometimes with required version
  • "The following REQUIRED packages have been found" - sometimes with required version
  • "The following features have been disabled" - useful to see more features that you can enable


TODO: To avoid installing to global a location such as /usr, for whatever reason, for your convenience, config-for-local.sh script has been prepared with default configuration settings. You can find it in tools/ subdirectory of the source code. Use it as follows:

1. Make sure $PREDICATE_INSTALL_PREFIX environment variable is set to directory that is indended PREFIX for the local Predicate installation, e.g. $HOME/predicate/inst.

2. To have the Predicate installation work environment variables PATH, LD_LIBRARY_PATH, PKG_CONFIG_PATH, QT_PLUGIN_PATH should be set properly. Double check this:

_libdir=lib # or lib64 for 64-bit platforms
export PATH=$PREDICATE_INSTALL_PREFIX/bin:$PATH
export LD_LIBRARY_PATH=$PREDICATE_INSTALL_PREFIX/$_libdir:$LD_LIBRARY_PATH
export PKG_CONFIG_PATH=$PREDICATE_INSTALL_PREFIX/$_libdir/pkgconfig:$PKG_CONFIG_PATH
export QT_PLUGIN_PATH=$PREDICATE_INSTALL_PREFIX/$_libdir/plugins/predicate:$QT_PLUGIN_PATH

3. Then:

mkdir -p {predicate-build-dir}
cd {predicate-build-dir}

(better pick your {predicate-build-dir} outside of the source code)

{predicate-source-dir}/tools/config-for-local.sh {cmake-options}

For explanation of {cmake_options}, see the cmake options section.

===Variant 3: Configuration for re-using local KDE 4 installation=== Here is recommendation of a directory structure:

$HOME/kde4/src/predicate
{predicate-source-dir}
$HOME/kde4/build/predicate
{predicate-build-dir}
$HOME/kde4/inst
directory that Predicate will be installed in, shared with other locally installed KDE software

If you use local KDE 4 installation, e.g. for developed applications, for your convenience, config-for-kde.sh script has been prepared with default configuration settings. You can find it in tools/ subdirectory of the source code. Use it as follows:

1. Make sure $KDEDIRS environment variable is set to directory that is intended PREFIX for the local KDE 4 installation, e.g. $HOME/kde4/inst.

2. To make the Predicate installation work, environment variables PATH, LD_LIBRARY_PATH, PKG_CONFIG_PATH, QT_PLUGIN_PATH should be set properly. Several of these are probably already set for the local KDE 4 installation but better double check this:

_libdir=lib # or lib64 for 64-bit platforms
export PATH=$KDEDIRS/bin:$PATH
export LD_LIBRARY_PATH=$KDEDIRS/$_libdir:$LD_LIBRARY_PATH
export PKG_CONFIG_PATH=$KDEDIRS/$_libdir/pkgconfig:$PKG_CONFIG_PATH
export QT_PLUGIN_PATH=$KDEDIRS/$_libdir/kde4/plugins:$QT_PLUGIN_PATH

3. Then:

mkdir -p {predicate-build-dir}
cd {predicate-build-dir}

(better pick your {predicate-build-dir} outside of the source code)

{predicate-source-dir}/tools/config-for-kde.sh {cmake-options}

For explanation of {cmake_options}, see the cmake options section.

Debugging options

Recommended for accurate debugging: The default debug setting is RelWithDebInfo which is suitable only for obtaining backtraces. If you are developing code that uses KDb or developing KDb itself you may want to precisely set breakpoints, watch points, use step by step command accurately in your debugger, rely on assertions, debug and warning messages. If this is the case, you can replace -DCMAKE_BUILD_TYPE=RelWithDebInfo cmake option with:

-DCMAKE_BUILD_TYPE=Debug

Using Debug results in a slower code. That can be acceptable in most cases during testing and development given the machine is fast enough. It is not intended for production releases of the software unless you know what you're doing.

Enabling tests

To build with tests enabled (both unit tests and functional tests), add -DBUILD_TESTING=ON to the cmake command before building.

Build

For any configuration option: Type the above configuration command only once, to configure the cmake-based buildsystem. Then just type:

 make
 make install

Reconfiguration

To completely reconfigure, remove the {kdb-build-dir} directory completely and repeat the configuration process.

Speed up the build

Recommended: Taking advantage of multi-core processors. On dual-core machines compilation can be greatly speed up with the -j parameter of the make program. For example whenever you are invoking make, for dual-core processor try to invoke:

make -j3

Similarly, for quad-core processor:

make -j5

Generaly for N-core processor use the -jN+1 parameter.

Recommended: Faster linking on Linux. Linking can take noticeable time in large software such as Calligra. On Linux Gold linker can be used to speed up this task. If you're building for Linux, install the Gold linker package and add the following to your cmake command:

-DCMAKE_C_FLAGS=-fuse-linker-plugin -DCMAKE_CXX_FLAGS=-fuse-linker-plugin

(you can set the CMAKE_C_FLAGS adn CMAKE_CXX_FLAGS variables in your {build dir}/CMakeCache.txt file either using text editor or the ccmake tool)

Notes

To enable debugging inside of bison (.y) file, put this in your $HOME/.gdbinit config file:

set directories {kdb-source-dir}/src/parser

(change {kdb-source-dir} to appropriate absolute path)