A page to document the variables, macros and other useful stuff we have to use CMake as the KDE4 buildsystem.

A page to document the variables, macros and other useful stuff we have to use CMake as the KDE4 buildsystem.

+

+

You may also want to visit the automatically generated documentation for [http://api.kde.org/cmake/modules.html#module_FindKDE4Internal FindKDE4Internal.cmake], which is generated directly from the current FindKDE4Internal.cmake and may be more up-to-date.

+

+

== Buildtypes==

+

CMake supports different build types for compiling the source code.

+

The following built-in build types are available to the CMake buildsystem:

+

+

;Release: optimized for speed, no debug symbols or qDebug/kDebug messages, no asserts

+

;RelWithDebInfo: similiar to ''release'', but with debug symbols for backtraces (-g). This is the default if none other is chosen.

+

;Debug: optimized for speed, but debuggable (you can still single-step through functions and set most breakpoints) and with debug symbols for backtraces (-g)

+

;DebugFull: no optimizations, full debug support and information (-g3). Note that some compiler warnings rely on the optimizer being available.

* '''XDG_APPS_INSTALL_DIR''' - the application install directory from [http://standards.freedesktop.org/basedir-spec/basedir-spec-latest.html the definition] by X Development Group which is the former name for [http://FreeDeskTop.org FreeDeskTop.org].

* '''XDG_DIRECTORY_INSTALL_DIR''' - the XDG directory

* '''XDG_DIRECTORY_INSTALL_DIR''' - the XDG directory

* '''XDG_MIME_INSTALL_DIR''' - the XDG mimetypes install dir

* '''XDG_MIME_INSTALL_DIR''' - the XDG mimetypes install dir

Line 65:

Line 101:

== Macros ==

== Macros ==

−

Lots of useful macros:

+

Lots of useful macros: (Question: Is there a URL to download these macros?)

* '''KDE4_ADD_UI_FILES (SRCS_VAR file1.ui ... fileN.ui)'''

* '''KDE4_ADD_UI_FILES (SRCS_VAR file1.ui ... fileN.ui)'''

Line 127:

Line 163:

Add a unit test, which is executed when running make test

Add a unit test, which is executed when running make test

−

It will be built with RPATH poiting to the build dir

+

It will be built with RPATH pointing to the build dir

The targets are always created, but only built for the "all" target if the option KDE4_BUILD_TESTS is enabled. Otherwise the rules for the target are created but not built by default. You can build them by manually building the target.

The targets are always created, but only built for the "all" target if the option KDE4_BUILD_TESTS is enabled. Otherwise the rules for the target are created but not built by default. You can build them by manually building the target.

Line 137:

Line 173:

Add a test executable

Add a test executable

−

It will be built with RPATH poiting to the build dir

+

It will be built with RPATH pointing to the build dir

The targets are always created, but only built for the "all" target if the option KDE4_BUILD_TESTS is enabled. Otherwise the rules for the target are created but not built by default. You can build them by manually building the target.

The targets are always created, but only built for the "all" target if the option KDE4_BUILD_TESTS is enabled. Otherwise the rules for the target are created but not built by default. You can build them by manually building the target.

Line 147:

Line 183:

Notifies the icon cache that new icons have been installed by updating mtime of ${ICON_INSTALL_DIR}/hicolor directory.

Notifies the icon cache that new icons have been installed by updating mtime of ${ICON_INSTALL_DIR}/hicolor directory.

Installs all png and svgz files in the current directory to the icon directory given in path, in the subdirectory for the given icon theme.

+

Installs all png and svgz files in the current directory that comply to the [[Development/Tutorials/Icons#The_icon_naming_scheme|icon naming scheme]] to the icon directory given in path, in the subdirectory for the given icon theme.

−

* '''KDE4_CREATE_HANDBOOK( docbookfile )'''

+

* '''KDE4_ADD_APP_ICON(appsources pattern)'''

−

Create the handbook from the docbookfile (using meinproc)

+

Mac OS X and Windows only: Adds application icon to target source list. This macro adds an application icon to the specified target. Mac OS X notes: the application icon is added to a Mac OS X bundle so that Finder and friends show the right thing. You need to provide a 128x128 version of the icon for this to work. Windows notes: the application icon(s) are compiled into the application binary.

Create a KDE application in the form of a module loadable via kdeinit.

A library named kdeinit_<name> will be created and a small executable which links to it.

It supports KDE4_ENABLE_FINAL

If the executable has to be run from the buildtree (e.g. unit tests and code generators used later on when compiling), set the option RUN_UNINSTALLED.

If the executable doesn't have a GUI, use the option NOGUI. By default on OS X application bundles are created, with the NOGUI option no bundles but simple executables are created. Currently it doesn't have any effect on other platforms.

KDE4_ADD_EXECUTABLE (name [NOGUI] [RUN_UNINSTALLED] file1 ... fileN)

Equivalent to ADD_EXECUTABLE(), but additionally adds some more features:

** support for KDE4_ENABLE_FINAL
** support for automoc
** automatic RPATH handling

If the executable has to be run from the buildtree (e.g. unit tests and code generators used later on when compiling), set the option RUN_UNINSTALLED.

If the executable doesn't have a GUI, use the option NOGUI. By default on OS X application bundles are created, with the NOGUI option no bundles but simple executables are created. Currently it doesn't have any effect on other platforms.

KDE4_ADD_LIBRARY (name [STATIC | SHARED | MODULE ] file1 ... fileN)

Equivalent to ADD_LIBRARY(), but additionally it supports KDE4_ENABLE_FINAL and under Windows it adds a -DMAKE_<name>_LIB definition to the compilation.

KDE4_ADD_UNIT_TEST (testname [TESTNAME targetname] file1 ... fileN)

Add a unit test, which is executed when running make test

It will be built with RPATH pointing to the build dir

The targets are always created, but only built for the "all" target if the option KDE4_BUILD_TESTS is enabled. Otherwise the rules for the target are created but not built by default. You can build them by manually building the target.

The name of the target can be specified using TESTNAME <targetname>, if it is not given the macro will default to the <testname>

KDE4_ADD_TEST_EXECUTABLE (name file1 ... fileN)

Add a test executable

It will be built with RPATH pointing to the build dir

The targets are always created, but only built for the "all" target if the option KDE4_BUILD_TESTS is enabled. Otherwise the rules for the target are created but not built by default. You can build them by manually building the target.

KDESRCDIR is set to the source directory of the test, this can be used with KGlobal::dirs()->addResourceDir( "data", KDESRCDIR ); to be able to use xmlgui and other things in the test, that normally require installation

KDE4_UPDATE_ICONCACHE()

Notifies the icon cache that new icons have been installed by updating mtime of ${ICON_INSTALL_DIR}/hicolor directory.

Installs all png and svgz files in the current directory that comply to the icon naming scheme to the icon directory given in path, in the subdirectory for the given icon theme.

KDE4_ADD_APP_ICON(appsources pattern)

Mac OS X and Windows only: Adds application icon to target source list. This macro adds an application icon to the specified target. Mac OS X notes: the application icon is added to a Mac OS X bundle so that Finder and friends show the right thing. You need to provide a 128x128 version of the icon for this to work. Windows notes: the application icon(s) are compiled into the application binary.