Scroll to navigation

ECM-FIND-MODULES(7) Extra CMake Modules ECM-FIND-MODULES(7)

NAME

ecm-find-modules - ECM Find Modules Reference

INTRODUCTION

Find modules are used by the CMake find_package command to search for packages that do not provide their own CMake package config files. CMake provides an extensive set of find modules, and Extra CMake Modules (ECM) adds to that.

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

find_package(ECM REQUIRED NO_MODULE)
set(CMAKE_MODULE_PATH ${ECM_FIND_MODULE_DIR})


Using ${ECM_MODULE_PATH} will also make the modules intended for direct use by CMake scripts available (see ecm-modules(7) and ecm-kde-modules(7)).

You can also make local copies of find modules using the ecm_use_find_modules function from ECMUseFindModules, which is automatically included when ECM is found:

find_package(ECM REQUIRED NO_MODULE)
ecm_use_find_modules(

DIR "${CMAKE_BINARY_DIR}/cmake"
MODULES FindEGL.cmake ) set(CMAKE_MODULE_PATH "${CMAKE_BINARY_DIR}/cmake")


This allows selective use of ECM’s find modules, and the NO_OVERRIDE argument can be used to ensure that if CMake ships its own version of that find module, it will be used instead.

ALL FIND MODULES

Find7z

Try to find 7z.

If the 7z executable is not in your PATH, you can provide an alternative name or full path location with the 7z_EXECUTABLE variable.

This will define the following variables:

7z_FOUND
TRUE if 7z is available
7z_EXECUTABLE
Path to 7z executable

If 7z_FOUND is TRUE, it will also define the following imported target:

7z::7z
Path to 7z executable

Since 5.85.0.

FindCanberra

Try to find Canberra event sound library.

This will define the following variables:

True if (the requested version of) Canberra is available
The version of Canberra
The libraries of Canberra for use with target_link_libraries()
The include dirs of Canberra for use with target_include_directories()

If Canberra_FOUND is TRUE, it will also define the following imported target:

The Canberra library

In general we recommend using the imported target, as it is easier to use. Bear in mind, however, that if the target is in the link interface of an exported library, it must be made available by the package config file.

Since 5.56.0.

FindEGL

Try to find EGL.

This will define the following variables:

True if (the requested version of) EGL is available
The version of EGL; note that this is the API version defined in the headers, rather than the version of the implementation (eg: Mesa)
This can be passed to target_link_libraries() instead of the EGL::EGL target
This should be passed to target_include_directories() if the target is not used for linking
This should be passed to target_compile_options() if the target is not used for linking

If EGL_FOUND is TRUE, it will also define the following imported target:

The EGL library

In general we recommend using the imported target, as it is easier to use. Bear in mind, however, that if the target is in the link interface of an exported library, it must be made available by the package config file.

Since pre-1.0.0.

FindGLIB2

Try to locate the GLib2 library. If found, this will define the following variables:

True if the GLib2 library is available
The GLib2 include directories
The GLib2 libraries for linking
Deprecated, use GLIB2_INCLUDE_DIRS
Deprecated, use GLIB2_LIBRARIES

If GLIB2_FOUND is TRUE, it will also define the following imported target:

The GLIB2 library

Since 5.41.0.

FindGperf

Try to find GNU gperf.

If the gperf executable is not in your PATH, you can provide an alternative name or full path location with the Gperf_EXECUTABLE variable.

This will define the following variables:

True if gperf is available.
The gperf executable.
The gperf version. (since 5.85)

If Gperf_FOUND is TRUE, it will also define the following imported target:

The gperf executable.

and the following public function:

ecm_gperf_generate(<GperfInput> <OutputFile> <OutputVariable(|target (since 5.83))>

[GENERATION_FLAGS <flags>])


Run gperf on <GperfInput> to generate <OutputFile>, adding it to the <OutputVariable> variable which contains the source for the target where <OutputFile> is going to be built or, since KF 5.83, if the given argument is a target, to the list of private sources of that target. The target must not be an alias. The optional GENERATION_FLAGS argument is needed to pass extra parameters to gperf (note you cannot override that way the output file).

A simple invocation would be:

ecm_gperf_generate(simple.gperf ${CMAKE_CURRENT_BINARY_DIR}/simple.h MySources)


Since 5.35.0.

FindGradle

Provides the ability to build Android AAR libraries using Gradle.

This relies on the Qt provided Gradle, so a Qt for Android installation is required.

gradle_add_aar(<target>

BUIDLFILE build.gradle
NAME <aar-name>)


This builds an Android AAR library using the given build.gradle file.

gradle_install_aar(<target>

DESTINATION <dest>)


Installs a Android AAR library that has been created with gradle_add_aar.

Since 5.76.0.

FindIcoTool

Try to find icotool.

If the icotool executable is not in your PATH, you can provide an alternative name or full path location with the IcoTool_EXECUTABLE variable.

This will define the following variables:

True if icotool is available.
The icotool executable.

If IcoTool_FOUND is TRUE, it will also define the following imported target:

The icotool executable.

Since 5.49.

FindInotify

  • libinotify on Unix like systems, or
  • the kernel’s inotify on Linux systems.


This will define the following variables:

True if inotify is available
This has to be passed to target_link_libraries()
This has to be passed to target_include_directories()

On Linux and SunOS, the libraries and include directories are empty, even though Inotify_FOUND may be set to TRUE. This is because no special includes or libraries are needed. On other systems these may be needed to use inotify.

Since 5.32.0.

FindIsoCodes

Try to find iso-codes data files. Once done this will define:

Whether the system has iso-codes
The location in which the iso-codes data files are found
The available domains provided by iso-codes

Since 5.80.0.

FindKF5

Find KDE Frameworks 5 with a single find_package() call.

This will use the package config files provided by the individual frameworks. For example, if you wish to find KArchive, which presents itself to CMake as KF5Archive (ie: you would do find_package(KF5Archive) to find it directly), you can do

find_package(KF5 COMPONENTS Archive)


If all the required components (those given in the COMPONENTS argument, but not those given in the OPTIONAL_COMPONENTS argument) are found, KF5_FOUND will be set to true. Otherwise, it will be set to false.

Since pre-1.0.0.

FindLibExiv2

Try to find the Exiv2 library.

This will define the following variables:

True if (the requested version of) Exiv2 is available
The version of Exiv2
The include dirs of Exiv2 for use with target_include_directories()
The Exiv2 library for use with target_link_libraries(). This can be passed to target_link_libraries() instead of the LibExiv2::LibExiv2 target

If LibExiv2_FOUND is TRUE, it will also define the following imported target:

The Exiv2 library

In general we recommend using the imported target, as it is easier to use. Bear in mind, however, that if the target is in the link interface of an exported library, it must be made available by the package config file.

Since 5.53.0.

FindLibGit2

Try to find libgit2 on a Unix system.

This will define the following variables:

True if (the requested version of) libgit2 is available
The version of libgit2
This can be passed to target_link_libraries() instead of the LibGit2::LibGit2 target
This should be passed to target_include_directories() if the target is not used for linking
This should be passed to target_compile_options() if the target is not used for linking

If LIBGIT2_FOUND is TRUE, it will also define the following imported target:

The libgit2 library

In general we recommend using the imported target, as it is easier to use. Bear in mind, however, that if the target is in the link interface of an exported library, it must be made available by the package config file.

Since 1.3.0.

FindLibMount

Try to find the libmount library (part of util-linux), once done this will define:

LibMount was found on the system.
The libmount include directory.
The libmount libraries.
The libmount version.

If LibMount_FOUND is TRUE, it will also define the following imported target:

The libmount library

Since 5.83.0

FindLibcap

Try to find the setcap binary and cap libraries

This will define:

system has the cap library and setcap binary
cap libraries to link against
path of the setcap binary
Libcap::SetCapabilities

Since 5.80.0

FindOpenEXR

Try to find the OpenEXR libraries.

This will define the following variables:

True if OpenEXR is available
Link to these to use OpenEXR
Include directory for OpenEXR
Compiler flags required to link against OpenEXR

and the following imported targets:

The OpenEXR core library

In general we recommend using the imported target, as it is easier to use. Bear in mind, however, that if the target is in the link interface of an exported library, it must be made available by the package config file.

Since pre-1.0.0.

FindPhoneNumber

Try to find PhoneNumber.

This is a component-based find module, which makes use of the COMPONENTS and OPTIONAL_COMPONENTS arguments to find_module. The following components are available:

PhoneNumber  GeoCoding


If no components are specified, this module will act as though all components were passed to OPTIONAL_COMPONENTS.

This module will define the following variables, independently of the components searched for or found:

True if (the requestion version of) PhoneNumber is available

For each searched-for components, PhoneNumber_<component>_FOUND will be set to TRUE if the corresponding library was found, and FALSE otherwise. If PhoneNumber_<component>_FOUND is TRUE, the imported target PhoneNumber::<component> will be defined.

Since 5.54.0.

FindPoppler

Try to find Poppler.

This is a component-based find module, which makes use of the COMPONENTS and OPTIONAL_COMPONENTS arguments to find_module. The following components are available:

Core  Cpp  Qt5  Qt4  Glib


If no components are specified, this module will act as though all components were passed to OPTIONAL_COMPONENTS.

This module will define the following variables, independently of the components searched for or found:

TRUE if (the requested version of) Poppler is available
Found Poppler version
A list of all targets imported by this module (note that there may be more than the components that were requested)
This can be passed to target_link_libraries() instead of the imported targets
This should be passed to target_include_directories() if the targets are not used for linking
This should be passed to target_compile_options() if the targets are not used for linking

For each searched-for components, Poppler_<component>_FOUND will be set to TRUE if the corresponding Poppler library was found, and FALSE otherwise. If Poppler_<component>_FOUND is TRUE, the imported target Poppler::<component> will be defined. This module will also attempt to determine Poppler_*_VERSION variables for each imported target, although Poppler_VERSION should normally be sufficient.

In general we recommend using the imported targets, as they are easier to use and provide more control. Bear in mind, however, that if any target is in the link interface of an exported library, it must be made available by the package config file.

Since 5.19

FindPulseAudio

Try to locate the PulseAudio library. If found, this will define the following variables:

True if the system has the PulseAudio library of at least the minimum version specified by either the version parameter to find_package() or the variable PulseAudio_MINIMUM_VERSION
The PulseAudio include directory
The PulseAudio libraries for linking
The libraries needed to use PulseAudio Mainloop
The version of PulseAudio that was found
Deprecated, use PulseAudio_INCLUDE_DIRS
Deprecated, use PulseAudio_LIBRARIES

If PulseAudio_FOUND is TRUE, it will also define the following imported target:

The PulseAudio library

Since 5.41.0.

FindQtWaylandScanner

Try to find qtwaylandscanner.

If the qtwaylandscanner executable is not in your PATH, you can provide an alternative name or full path location with the QtWaylandScanner_EXECUTABLE variable.

This will define the following variables:

True if qtwaylandscanner is available
The qtwaylandscanner executable.

If QtWaylandScanner_FOUND is TRUE, it will also define the following imported target:

The qtwaylandscanner executable.

This module provides the following functions to generate C++ protocol implementations:

  • ecm_add_qtwayland_client_protocol
  • ecm_add_qtwayland_server_protocol



ecm_add_qtwayland_client_protocol(<target>

PROTOCOL <xmlfile>
BASENAME <basename>
[PREFIX <prefix>]) ecm_add_qtwayland_client_protocol(<source_files_var>
PROTOCOL <xmlfile>
BASENAME <basename>
[PREFIX <prefix>])


Generate C++ wrapper to Wayland client protocol files from <xmlfile> XML definition for the <basename> interface and append those files to <source_files_var> or <target>. Pass the <prefix> argument if the interface names don’t start with qt_ or wl_.

WaylandScanner is required and will be searched for.

ecm_add_qtwayland_server_protocol(<target>

PROTOCOL <xmlfile>
BASENAME <basename>
[PREFIX <prefix>]) ecm_add_qtwayland_server_protocol(<source_files_var>
PROTOCOL <xmlfile>
BASENAME <basename>
[PREFIX <prefix>])


Generate C++ wrapper to Wayland server protocol files from <xmlfile> XML definition for the <basename> interface and append those files to <source_files_var> or <target>. Pass the <prefix> argument if the interface names don’t start with qt_ or wl_.

WaylandScanner is required and will be searched for.

Since 1.4.0.

FindSasl2

Try to find the SASL2 library.

This will define the following variables:

System has SASL2.
The version of SASL2.
This should be passed to target_include_directories() if the target is not used for linking.
The SASL2 library. This can be passed to target_link_libraries() instead of the Sasl2::Sasl2 target

If Sasl2_FOUND is TRUE, the following imported target will be available:

The SASL2 library

Since 5.41.0.

FindSeccomp

Try to locate the libseccomp library.

This will define the following variables:

True if the seccomp library is available
The seccomp include directories
The seccomp libraries for linking

If Seccomp_FOUND is TRUE, it will also define the following imported target:

The Seccomp library

Since 5.44.0.

FindSharedMimeInfo

Try to find the shared-mime-info package.

This will define the following variables:

True if system has the shared-mime-info package
The update-mime-database executable

and the following imported targets:

The update-mime-database executable

The follow macro is available:

update_xdg_mimetypes(<path>)


Updates the XDG mime database at install time (unless the $DESTDIR environment variable is set, in which case it is up to package managers to perform this task).

Since pre-1.0.0.

FindTaglib

Try to find the Taglib library.

This will define the following variables:

True if the system has the taglib library of at least the minimum version specified by the version parameter to find_package()
The taglib include dirs for use with target_include_directories
The taglib libraries for use with target_link_libraries()
The version of taglib that was found

If Taglib_FOUND is TRUE, it will also define the following imported target:

The Taglib library

Since 5.72.0

FindUDev

Try to find the UDev library.

This will define the following variables:

System has UDev.
The libudev include directory.
The libudev libraries.
The libudev version.

If UDev_FOUND is TRUE, it will also define the following imported target:

The UDev library

Since 5.57.0.

FindWayland

Try to find Wayland.

This is a component-based find module, which makes use of the COMPONENTS and OPTIONAL_COMPONENTS arguments to find_module. The following components are available:

Client  Server  Cursor  Egl


If no components are specified, this module will act as though all components were passed to OPTIONAL_COMPONENTS.

This module will define the following variables, independently of the components searched for or found:

TRUE if (the requested version of) Wayland is available
Found Wayland version
A list of all targets imported by this module (note that there may be more than the components that were requested)
This can be passed to target_link_libraries() instead of the imported targets
This should be passed to target_include_directories() if the targets are not used for linking
This should be passed to target_compile_options() if the targets are not used for linking
The core wayland protocols data directory Since 5.73.0

For each searched-for components, Wayland_<component>_FOUND will be set to TRUE if the corresponding Wayland library was found, and FALSE otherwise. If Wayland_<component>_FOUND is TRUE, the imported target Wayland::<component> will be defined. This module will also attempt to determine Wayland_*_VERSION variables for each imported target, although Wayland_VERSION should normally be sufficient.

In general we recommend using the imported targets, as they are easier to use and provide more control. Bear in mind, however, that if any target is in the link interface of an exported library, it must be made available by the package config file.

Since pre-1.0.0.

FindWaylandProtocols

Try to find wayland-protocols on a Unix system.

This will define the following variables:

True if (the requested version of) wayland-protocols is available
The version of wayland-protocols
The wayland protocols data directory

FindWaylandScanner

Try to find wayland-scanner.

If the wayland-scanner executable is not in your PATH, you can provide an alternative name or full path location with the WaylandScanner_EXECUTABLE variable.

This will define the following variables:

True if wayland-scanner is available.
The wayland-scanner executable.

If WaylandScanner_FOUND is TRUE, it will also define the following imported target:

The wayland-scanner executable.

This module provides the following functions to generate C protocol implementations:

  • ecm_add_wayland_client_protocol
  • ecm_add_wayland_server_protocol



ecm_add_wayland_client_protocol(<target>

PROTOCOL <xmlfile>
BASENAME <basename>) ecm_add_wayland_client_protocol(<source_files_var>
PROTOCOL <xmlfile>
BASENAME <basename>)


Generate Wayland client protocol files from <xmlfile> XML definition for the <basename> interface and append those files to <source_files_var> or <target>.

ecm_add_wayland_server_protocol(<target>

PROTOCOL <xmlfile>
BASENAME <basename>) ecm_add_wayland_server_protocol(<source_files_var>
PROTOCOL <xmlfile>
BASENAME <basename>)


Generate Wayland server protocol files from <xmlfile> XML definition for the <basename> interface and append those files to <source_files_var> or <target>.

Since 1.4.0.

FindX11_XCB

Try to find the X11 XCB compatibility library.

This will define the following variables:

True if (the requested version of) libX11-xcb is available
The version of libX11-xcb (this is not guaranteed to be set even when X11_XCB_FOUND is true)
This can be passed to target_link_libraries() instead of the EGL::EGL target
This should be passed to target_include_directories() if the target is not used for linking
This should be passed to target_compile_options() if the target is not used for linking

If X11_XCB_FOUND is TRUE, it will also define the following imported target:

The X11 XCB compatibility library

In general we recommend using the imported target, as it is easier to use. Bear in mind, however, that if the target is in the link interface of an exported library, it must be made available by the package config file.

Since pre-1.0.0.

FindXCB

Try to find XCB.

This is a component-based find module, which makes use of the COMPONENTS and OPTIONAL_COMPONENTS arguments to find_module. The following components are available:

XCB
ATOM         AUX          COMPOSITE    CURSOR       DAMAGE
DPMS         DRI2         DRI3         EVENT        EWMH
GLX          ICCCM        IMAGE        KEYSYMS      PRESENT
RANDR        RECORD       RENDER       RENDERUTIL   RES
SCREENSAVER  SHAPE        SHM          SYNC         UTIL
XF86DRI      XFIXES       XINERAMA     XINPUT       XKB
XTEST        XV           XVMC


If no components are specified, this module will act as though all components were passed to OPTIONAL_COMPONENTS. Before 5.82 this excluded XINPUT. Since 5.82 all components are searched for.

This module will define the following variables, independently of the components searched for or found:

True if (the requestion version of) xcb is available
Found xcb version
A list of all targets imported by this module (note that there may be more than the components that were requested)
This can be passed to target_link_libraries() instead of the imported targets
This should be passed to target_include_directories() if the targets are not used for linking
This should be passed to target_compile_options() if the targets are not used for linking

For each searched-for components, XCB_<component>_FOUND will be set to true if the corresponding xcb library was found, and false otherwise. If XCB_<component>_FOUND is true, the imported target XCB::<component> will be defined. This module will also attempt to determine XCB_*_VERSION variables for each imported target, although XCB_VERSION should normally be sufficient.

In general we recommend using the imported targets, as they are easier to use and provide more control. Bear in mind, however, that if any target is in the link interface of an exported library, it must be made available by the package config file.

Since pre-1.0.0.

Findepoxy

Try to find libepoxy on a Unix system.

This will define the following variables:

True if (the requested version of) libepoxy is available
The version of libepoxy
This should be passed to target_link_libraries() if the target is not used for linking
This should be passed to target_include_directories() if the target is not used for linking
This should be passed to target_compile_options() if the target is not used for linking
True if GLX support is available

If epoxy_FOUND is TRUE, it will also define the following imported target:

The epoxy library

In general we recommend using the imported target, as it is easier to use. Bear in mind, however, that if the target is in the link interface of an exported library, it must be made available by the package config file.

Findgzip

Try to find gzip.

If the gzip executable is not in your PATH, you can provide an alternative name or full path location with the gzip_EXECUTABLE variable.

This will define the following variables:

TRUE if gzip is available
Path to gzip executable

If gzip_FOUND is TRUE, it will also define the following imported target:

Path to gzip executable

Since 5.85.0.

SEE ALSO

ecm(7), ecm-modules(7), ecm-kde-modules(7)

COPYRIGHT

KDE Developers

February 12, 2023 5.103