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:

VariableDescription
Qt5Widgets_VERSIONA string that describes the module's version.
Qt5Widgets_LIBRARIESA list of libraries for use with the target_link_libraries command.
Qt5Widgets_INCLUDE_DIRSA list of directories for use with the include_directories command.
Qt5Widgets_DEFINITIONSA list of definitions for use with the add_definitions command.
Qt5Widgets_COMPILE_DEFINITIONSA list of definitions for use with the COMPILE_DEFINITIONS target property.
Qt5Widgets_FOUNDA boolean that describes whether the module was found successfully.
Qt5Widgets_EXECUTABLE_COMPILE_FLAGSA 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.

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

© 2020 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.