diff options
author | Alexandru Croitor <alexandru.croitor@qt.io> | 2019-04-24 17:14:25 +0200 |
---|---|---|
committer | Alexandru Croitor <alexandru.croitor@qt.io> | 2019-05-02 07:30:42 +0000 |
commit | 9b0b464e82071338134700edfa190bf998846e4e (patch) | |
tree | 4c0390bb52624fdd063f9495bd939c1c4c7d498f /src/corelib/configure.cmake | |
parent | 42d3b21c92525ea6a430c67e577a5991d679fa1d (diff) |
Write find_dependency() calls in Qt Module config files
This change introduces a new function called qt_find_package()
which can take an extra option called PROVIDED_TARGETS, which
associates targets with the package that defines those targets.
This is done by setting the INTERFACE_QT_PACKAGE_NAME and
INTERFACE_QT_PACKAGE_VERSION properties on the imported targets.
This information allows us to generate appropriate find_dependency()
calls in a module's Config file for third party libraries.
For example when an application links against QtCore, it should also
link against zlib and atomic libraries. In order to do that, the
library locations first have to be found by CMake. This is achieved by
embedding find_dependency(ZLIB) and find_dependency(Atomic) in
Qt5CoreDependencies.cmake which is included by Qt5CoreConfig.cmake.
The latter is picked up when an application project contains
find_package(Qt5Core), and thus all linking dependencies are resolved.
The information 'which package provides which targets' is contained
in the python json2cmake conversion script. The generated output of
the script contains qt_find_package() calls that represent that
information.
The Qt5CoreDependencies.cmake file and which which dependencies it
contains is generated at the QtPostProcess stop.
Note that for non-static Qt builds, we only need to propagate public
3rd party libraries. For static builds, we need all third party
libraries.
In order for the INTERFACE_QT_PACKAGE_NAME property to be read in any
scope, the targets on which the property is set, have to be GLOBAL.
Also for applications and other modules to find all required third
party libraries, we have to install all our custom Find modules, and
make sure they define INTERFACE IMPORTED libraries, and not just
IMPORTED libraries.
Change-Id: I694d6e32d05b96d5e241df0156fc79d0029426aa
Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
Diffstat (limited to 'src/corelib/configure.cmake')
-rw-r--r-- | src/corelib/configure.cmake | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/src/corelib/configure.cmake b/src/corelib/configure.cmake index 10d2ea60de..e9794dc2a4 100644 --- a/src/corelib/configure.cmake +++ b/src/corelib/configure.cmake @@ -10,23 +10,23 @@ set_property(CACHE INPUT_iconv PROPERTY STRINGS undefined no yes posix sun gnu) #### Libraries -find_package(GLIB2) +qt_find_package(GLIB2 PROVIDED_TARGETS GLIB2::GLIB2) set_package_properties(GLIB2 PROPERTIES TYPE OPTIONAL) -find_package(ICU COMPONENTS i18n uc data) +qt_find_package(ICU COMPONENTS i18n uc data PROVIDED_TARGETS ICU::i18n ICU::uc ICU::data) set_package_properties(ICU PROPERTIES TYPE OPTIONAL) -find_package(Libsystemd) +qt_find_package(Libsystemd) set_package_properties(Libsystemd PROPERTIES TYPE OPTIONAL) -find_package(Atomic) +qt_find_package(Atomic PROVIDED_TARGETS Atomic) set_package_properties(Atomic PROPERTIES TYPE OPTIONAL) -find_package(WrapRt) +qt_find_package(WrapRt PROVIDED_TARGETS WrapRt) set_package_properties(WrapRt PROPERTIES TYPE OPTIONAL) -find_package(LTTngUST) +qt_find_package(LTTngUST) set_package_properties(LTTngUST PROPERTIES TYPE OPTIONAL) -find_package(PCRE2) +qt_find_package(PCRE2 PROVIDED_TARGETS PCRE2) set_package_properties(PCRE2 PROPERTIES TYPE REQUIRED) -find_package(PPS) +qt_find_package(PPS) set_package_properties(PPS PROPERTIES TYPE OPTIONAL) -find_package(Slog2) +qt_find_package(Slog2) set_package_properties(Slog2 PROPERTIES TYPE OPTIONAL) |