ecm-kde-modules man page

ecm-kde-modules — ECM KDE Modules Reference


Extra CMake Modules (ECM) provides several modules that provide default settings (like installation directories, compiler flags and other CMake options) aimed at software produced by the KDE modules; these are documented here. ECM also provides modules with more general functionality, documented in ecm-modules(7), and ones that extend the functionality of the find_package command, documented in ecm-find-modules(7).

To use these modules, you need to tell CMake to find the ECM package, and then add either ${ECM_MODULE_PATH} or ${ECM_KDE_MODULE_DIR} to the CMAKE_MODULE_PATH variable:


Using ${ECM_MODULE_PATH} will also make the other types of modules available.

All Kde Modules


Changes various CMake settings to what the KDE community views as more sensible defaults.

It is recommended to include this module with the NO_POLICY_SCOPE flag, otherwise you may get spurious warnings with some versions of CMake.

It is split into three parts, which can be independently disabled if desired.

Runtime Paths

The default runtime path (used on Unix systems to search for dynamically-linked libraries) is set to include the location that libraries will be installed to (as set in LIB_INSTALL_DIR or, if the former is not set, KDE_INSTALL_LIBDIR), and also the linker search path.

Note that LIB_INSTALL_DIR or alternatively KDE_INSTALL_LIBDIR needs to be set before including this module. Typically, this is done by including the KDEInstallDirs module.

This section can be disabled by setting KDE_SKIP_RPATH_SETTINGS to TRUE before including this module.


Testing is enabled by default, and an option (BUILD_TESTING) is provided for users to control this. See the CTest module documentation in the CMake manual for more details.

This section can be disabled by setting KDE_SKIP_TEST_SETTINGS to TRUE before including this module.

Build Settings

Various CMake build defaults are altered, such as searching source and build directories for includes first and enabling automoc by default.

This section can be disabled by setting KDE_SKIP_BUILD_SETTINGS to TRUE before including this module.

This section also provides an "uninstall" target that can be individually disabled by setting KDE_SKIP_UNINSTALL_TARGET to TRUE before including this module.

By default on OS X, X11 and XCB related detections are disabled. However if the need would arise to use these technologies, the detection can be enabled by setting APPLE_FORCE_X11 to ON.

A warning is printed for the developer to know that the detection is disabled on OS X. This message can be turned off by setting APPLE_SUPPRESS_X11_WARNING to ON.

Since pre-1.0.0.

ENABLE_CLAZY option is added (OFF by default) when clang is being used. Turning this option on will force clang to load the clazy plugins for richer warnings on Qt-related code.

If clang is not being used, this won't have an effect. See

Since 5.17.0


Uninstall target functionality since 1.7.0.


APPLE_FORCE_X11 option since 5.14.0 (detecting X11 was previously the default behavior)


APPLE_SUPPRESS_X11_WARNING option since 5.14.0


Set useful compile and link flags for C++ (and C) code.

Enables many more warnings than the default, and sets stricter modes for some compiler features.  By default, exceptions are disabled; kde_target_enable_exceptions() can be used to re-enable them for a specific target.

NB: it is recommended to include this module with the NO_POLICY_SCOPE flag, otherwise you may get spurious warnings with some versions of CMake.

This module provides the following functions:

kde_source_files_enable_exceptions([file1 [file2 [...]]])

Enables exceptions for specific source files.  This should not be used on source files in a language other than C++.

kde_target_enable_exceptions(target <INTERFACE|PUBLIC|PRIVATE>)

Enables exceptions for a specific target.  This should not be used on a target that has source files in a language other than C++.


Enables exceptions for C++ source files compiled for the CMakeLists.txt file in the current directory and all subdirectories.

Since pre-1.0.0.


Set stricter compile and link flags for KDE Frameworks modules.

The KDECompilerSettings module is included and, in addition, various defines that affect the Qt libraries are set to enforce certain conventions.

For example, constructions like QString("foo") are prohibited, instead forcing the use of QLatin1String or QStringLiteral, and some Qt-defined keywords like signals and slots will not be defined.

NB: it is recommended to include this module with the NO_POLICY_SCOPE flag, otherwise you may get spurious warnings with some versions of CMake.

Since pre-1.0.0.


Define KDE standard installation directories.

Note that none of the variables defined by this module provide any information about the location of already-installed KDE software.

Inclusion of this module defines the following variables:


destination for files of a given type


corresponding absolute path

where <dir> is one of (default values in parentheses and alternative, deprecated variable name in square brackets):


application bundles (/Applications/KDE) [BUNDLE_INSTALL_DIR]


executables and libraries (<empty>) [EXEC_INSTALL_PREFIX]


user executables (EXECROOTDIR/bin) [BIN_INSTALL_DIR]


system admin executables (EXECROOTDIR/sbin) [SBIN_INSTALL_DIR]


object code libraries (EXECROOTDIR/lib, EXECROOTDIR/lib64 or EXECROOTDIR/lib/<multiarch-tuple on Debian) [LIB_INSTALL_DIR]


executables for internal use by programs and libraries (BINDIR on Windows, LIBDIR/libexec otherwise) [LIBEXEC_INSTALL_DIR]


CMake packages, including config files (LIBDIR/cmake) [CMAKECONFIG_INSTALL_PREFIX]


Qt plugins (LIBDIR/plugins) [QT_PLUGIN_INSTALL_DIR]




QtQuick1 imports (QTPLUGINDIR/imports) [IMPORTS_INSTALL_DIR]


QtQuick2 imports (LIBDIR/qml) [QML_INSTALL_DIR]


C and C++ header files (include) [INCLUDE_INSTALL_DIR]


modifiable single-machine data (var)


modifiable architecture-independent data (com)


read-only architecture-independent data root (share) [SHARE_INSTALL_PREFIX]


read-only architecture-independent data (DATAROOTDIR) [DATA_INSTALL_DIR]


documentation bundles generated using kdoctools (DATAROOTDIR/doc/HTML) [HTML_INSTALL_DIR]


kconfig description files (DATAROOTDIR/config.kcfg) [KCFG_INSTALL_DIR]


kconf_update scripts (DATAROOTDIR/kconf_update) [KCONF_UPDATE_INSTALL_DIR]


services for KDE Frameworks 5 (DATAROOTDIR/kservices5) [SERVICES_INSTALL_DIR]


service types for KDE Frameworks 5 (DATAROOTDIR/kservicetypes5) [SERVICETYPES_INSTALL_DIR]


knotify description files (DATAROOTDIR/kxmlgui5) [KXMLGUI_INSTALL_DIR]


Kapptemplate and Kdevelop templates (kdevappwizard/templates)


knotify description files (DATAROOTDIR/knotifications5) [KNOTIFYRC_INSTALL_DIR]




knotify description files (DATAROOTDIR/locale) [LOCALE_INSTALL_DIR]


sound files (DATAROOTDIR/sounds) [SOUND_INSTALL_DIR]




desktop wallpaper images (DATAROOTDIR/wallpapers) [WALLPAPER_INSTALL_DIR]


application desktop files (DATAROOTDIR/applications) [XDG_APPS_INSTALL_DIR]


desktop directories (DATAROOTDIR/desktop-directories) [XDG_DIRECTORY_INSTALL_DIR]


mime description files (DATAROOTDIR/mime/packages) [XDG_MIME_INSTALL_DIR]


AppStream component metadata files (DATAROOTDIR/metainfo)


man documentation (DATAROOTDIR/man) [MAN_INSTALL_DIR]


info documentation (DATAROOTDIR/info)


D-Bus (DATAROOTDIR/dbus-1)


D-Bus interfaces (DBUSDIR/interfaces) [DBUS_INTERFACES_INSTALL_DIR]


D-Bus session services (DBUSDIR/services) [DBUS_SERVICES_INSTALL_DIR]


D-Bus system services (DBUSDIR/system-services) [DBUS_SYSTEM_SERVICES_INSTALL_DIR]


read-only single-machine data (etc, or /etc if CMAKE_INSTALL_PREFIX is /usr) [SYSCONF_INSTALL_DIR]


application configuration files (SYSCONFDIR/xdg) [CONFIG_INSTALL_DIR]


autostart files (CONFDIR/autostart) [AUTOSTART_INSTALL_DIR]

If KDE_INSTALL_DIRS_NO_DEPRECATED is set to TRUE before including this module, the deprecated variables (listed in the square brackets above) are not defined.

In addition, for each KDE_INSTALL_* variable, an equivalent CMAKE_INSTALL_* variable is defined. If KDE_INSTALL_DIRS_NO_DEPRECATED is set to TRUE, only those variables defined by the GNUInstallDirs module (shipped with CMake) are defined. If KDE_INSTALL_DIRS_NO_CMAKE_VARIABLES is set to TRUE, no variables with a CMAKE_ prefix will be defined by this module (other than CMAKE_INSTALL_DEFAULT_COMPONENT_NAME - see below).

The KDE_INSTALL_<dir> variables (or their CMAKE_INSTALL_<dir> or deprecated counterparts) may be passed to the DESTINATION options of install() commands for the corresponding file type.  They are set in the CMake cache, and so the defaults above can be overridden by users.

Note that the KDE_INSTALL_<dir>, CMAKE_INSTALL_<dir> or deprecated form of the variable can be changed using CMake command line variable definitions; in either case, all forms of the variable will be affected. The effect of passing multiple forms of the same variable on the command line (such as KDE_INSTALL_BINDIR and CMAKE_INSTALL_BINDIR is undefined.

The variable KDE_INSTALL_TARGETS_DEFAULT_ARGS is also defined (along with the deprecated form INSTALL_TARGETS_DEFAULT_ARGS).  This should be used when libraries or user-executable applications are installed, in the following manner:


It MUST NOT be used for installing plugins, system admin executables or executables only intended for use internally by other code.  Those should use KDE_INSTALL_PLUGINDIR, KDE_INSTALL_SBINDIR or KDE_INSTALL_LIBEXECDIR respectively.

Additionally, CMAKE_INSTALL_DEFAULT_COMPONENT_NAME will be set to ${PROJECT_NAME} to provide a sensible default for this CMake option.

Note that mixing absolute and relative paths, particularly for BINDIR, LIBDIR and INCLUDEDIR, can cause issues with exported targets. Given that the default values for these are relative paths, relative paths should be used on the command line when possible (eg: use -DKDE_INSTALL_LIBDIR=lib64 instead of -DKDE_INSTALL_LIBDIR=/usr/lib/lib64 to override the library directory).

Since pre-1.0.0.

NB: The variables starting KDE_INSTALL_ are only available since 1.6.0. The APPDIR install variable is available since 1.1.0.


Packages KApptemplate/KDevelop compatible application templates

This module provides a functionality to package in a tarball and install project templates compatible with the format used by KApptemplate and KDevelop. Useful for providing minimal examples for the usage of the KDE Frameworks.

This module provides the following function:

kde_package_app_templates( TEMPLATES template1 [template2] [...] INSTALL_DIR directory)

INSTALL_DIR is the directory to install the template package to. In most cases you will want to use the variable KDE_INSTALL_KTEMPLATESDIR from KDEInstallDirs.

TEMPLATES lists subdirectories containing template files; each <template> directory will be packaged into a file named <template>.tar.bz2 and installed to the appropriate location.

The template is a minimal source tree of an application as if it was an application project by itself, with names (file names or text inside) the text files replaced by the following placeholders when needed:


%{APPNAMELC}-%{VERSION} for KAppTemplate


project name as entered by user ex: MyKApp


project name in lower case ex: mykapp


project name in upper case ex: MYKAPP


license header for cpp file


license header for h file


author name ex: George Ignacious


author email ex:


project version ex: 0.1


used in .kdevtemplate


used in .kdevtemplate

Multiple templates can be passed at once.

Since 5.18

See Also

ecm(7), ecm-modules(7), ecm-find-modules(7)

Referenced By

ecm(7), ecm-find-modules(7), ecm-modules(7).

Feb 06, 2017 5.31 Extra CMake Modules