CMake Variable Reference

Module variables

When you use find_package, the resulting imported targets are created for use with target_link_libraries. Some variables are populated with information required to configure the build. For each module, the name of its imported target matches the name of the module with a "Qt5::" prefix, such as "Qt5::Widgets". All of the package-specific variables have a consistent name with its package name as prefix.

For example, find_package(Qt5 COMPONENTS Widgets), when successful, makes the following variables available:

Variable Description
Qt5Widgets_VERSION A string that describes the module's version.
Qt5Widgets_LIBRARIES A list of libraries for use with the target_link_libraries command.
Qt5Widgets_INCLUDE_DIRS A list of directories for use with the include_directories command.
Qt5Widgets_DEFINITIONS A list of definitions for use with the add_definitions command.
Qt5Widgets_COMPILE_DEFINITIONS A list of definitions for use with the COMPILE_DEFINITIONS target property.
Qt5Widgets_FOUND A boolean that describes whether the module was found successfully.
Qt5Widgets_EXECUTABLE_COMPILE_FLAGS A string of flags to use when building executables.

For all packages found with find_package, equivalents of these variables are available; they are case-sensitive.

Installation variables

Additionally, there are also variables that don't relate to a particular package, but to the Qt installation itself.

Variable Description
QT_VISIBILITY_AVAILABLE On Unix, a boolean that describes whether Qt libraries and plugins were compiled with -fvisibility=hidden. This means that only selected symbols are exported.
QT_LIBINFIX A string that holds the infix used in library names, when Qt is configured with -libinfix.

© The Qt Company Ltd
Licensed under the GNU Free Documentation License, Version 1.3.
https://doc.qt.io/qt-5.14/cmake-variable-reference.html