2020-07-14 09:25:47 +00:00
|
|
|
# Make sure @INSTALL_CMAKE_NAMESPACE@ is found before anything else.
|
2020-09-14 07:06:58 +00:00
|
|
|
set(@INSTALL_CMAKE_NAMESPACE@@target@_FOUND FALSE)
|
2020-09-25 18:02:56 +00:00
|
|
|
|
|
|
|
set(__qt_use_no_default_path_for_qt_packages "NO_DEFAULT_PATH")
|
|
|
|
if(QT_DISABLE_NO_DEFAULT_PATH_IN_QT_PACKAGES)
|
|
|
|
set(__qt_use_no_default_path_for_qt_packages "")
|
|
|
|
endif()
|
2020-07-14 09:25:47 +00:00
|
|
|
find_dependency(@INSTALL_CMAKE_NAMESPACE@ @PROJECT_VERSION@
|
2020-09-25 18:02:56 +00:00
|
|
|
PATHS
|
|
|
|
"${CMAKE_CURRENT_LIST_DIR}/.."
|
2021-02-24 15:07:37 +00:00
|
|
|
${_qt_additional_packages_prefix_path}
|
|
|
|
${_qt_additional_packages_prefix_path_env}
|
2020-09-25 18:02:56 +00:00
|
|
|
${QT_EXAMPLES_CMAKE_PREFIX_PATH}
|
|
|
|
${__qt_use_no_default_path_for_qt_packages}
|
2020-07-14 09:25:47 +00:00
|
|
|
)
|
|
|
|
|
2020-09-14 07:37:03 +00:00
|
|
|
# note: _third_party_deps example: "ICU\\;FALSE\\;1.0\\;i18n uc data;ZLIB\\;FALSE\\;\\;"
|
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>
2019-04-24 15:14:25 +00:00
|
|
|
set(_third_party_deps "@third_party_deps@")
|
|
|
|
|
|
|
|
foreach(_target_dep ${_third_party_deps})
|
|
|
|
list(GET _target_dep 0 pkg)
|
2020-09-14 07:37:03 +00:00
|
|
|
list(GET _target_dep 1 is_optional)
|
|
|
|
list(GET _target_dep 2 version)
|
|
|
|
list(GET _target_dep 3 components)
|
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>
2019-04-24 15:14:25 +00:00
|
|
|
set(find_package_args "${pkg}")
|
|
|
|
if(version)
|
|
|
|
list(APPEND find_package_args "${version}")
|
|
|
|
endif()
|
|
|
|
if(components)
|
2019-06-25 12:44:29 +00:00
|
|
|
string(REPLACE " " ";" components "${components}")
|
2020-09-14 07:36:16 +00:00
|
|
|
list(APPEND find_package_args COMPONENTS ${components})
|
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>
2019-04-24 15:14:25 +00:00
|
|
|
endif()
|
2020-09-14 07:36:16 +00:00
|
|
|
|
2020-09-14 07:37:03 +00:00
|
|
|
if(is_optional)
|
|
|
|
if(${CMAKE_FIND_PACKAGE_NAME}_FIND_QUIETLY)
|
|
|
|
list(APPEND find_package_args QUIET)
|
|
|
|
endif()
|
|
|
|
find_package(${find_package_args})
|
|
|
|
else()
|
|
|
|
find_dependency(${find_package_args})
|
|
|
|
endif()
|
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>
2019-04-24 15:14:25 +00:00
|
|
|
endforeach()
|
|
|
|
|
2019-04-29 12:36:25 +00:00
|
|
|
# Find Qt tool package.
|
|
|
|
set(_tool_deps "@main_module_tool_deps@")
|
2019-06-24 12:56:15 +00:00
|
|
|
|
2020-12-15 17:09:32 +00:00
|
|
|
if(NOT "${QT_HOST_PATH}" STREQUAL "")
|
2020-04-27 13:04:57 +00:00
|
|
|
# Make sure that the tools find the host tools first
|
|
|
|
set(BACKUP_@target@_CMAKE_PREFIX_PATH ${CMAKE_PREFIX_PATH})
|
|
|
|
set(BACKUP_@target@_CMAKE_FIND_ROOT_PATH ${CMAKE_FIND_ROOT_PATH})
|
CMake: Fix handling of CMAKE_FIND_ROOT_PATH and CMAKE_PREFIX_PATH
While trying to implement the 'host artifact reuse' Coin instructions
change, a bug surfaced where the qemu configurations didn't find
the host tools and instead tried to use the cross-compiled tools
while building qtbase, which failed due to not finding the
runtime linker (another unsolved issue).
Before the host artifact reuse change, the host tools were found
successfully.
The difference that caused the issue is that the target install prefix
was a direct subfolder of the host prefix.
host - /home/qt/work/qt/install
target - /home/qt/work/qt/install/target
Before the host reuse change the install prefixes were as follows
host - /home/qt/work/qt/install/host
target - /home/qt/work/qt/install/target
While looking for the Qt6CoreTools package, we temporarily set
CMAKE_FIND_ROOT_PATH and CMAKE_PREFIX_PATH to contain first
'/home/qt/work/qt/install' and then '/home/qt/work/qt/install/target'.
CMake then reroots the CMAKE_PREFIX_PATH values onto values in
CMAKE_FIND_ROOT_PATH, making an MxN list of prefixes to search.
Rerooting essentially means concatenating 2 paths, unless the
considered prefix is a subfolder of the root path.
What happened was that the first considered value was
'/home/qt/work/qt/install/home/qt/work/qt/install', a non-existent
location that gets discarded.
The second considered value was '/home/qt/work/qt/install/target.
The second value is the result of seeing that
'/home/qt/work/qt/install/target' is a subfolder of
'/home/qt/work/qt/install' and thus the root path is stripped.
All of this is done in cmFindPackageCommand::FindConfig() ->
cmFindCommon::RerootPaths.
The behavior above caused the target tools be found instead of the
host ones.
Before the host reuse change, both of the initial constructed prefixes
were discared due to them not existing, e.g.
'/home/qt/work/qt/install/target/home/qt/work/qt/install/target'
and '/home/qt/work/qt/install/host/home/qt/work/qt/install/host'
One of the later prefixes combined CMAKE_FIND_ROOT_PATH ==
'/home/qt/work/qt/install/host' + CMAKE_PREFIX_PATH == '/' resulting
in '/home/qt/work/qt/install/host/' and this accidentally found the
host tools package.
We actually stumbled upon this issue a while ago when implementing Qt
5.14 Android CMake support in 52c799ed4425076df4353c02950ea1444fe5f102
That commit message mentions the fix is to add a "lib/cmake"
suffix to the PATHS option of find_package().
This would cause the subfolder => strip root behavior mentioned
above.
So finally the fix.
First, make sure not to append QT_HOST_PATH in the toolchain file,
there shouldn't be any need to do that, give that we temporarily set
it when looking for Tools packages.
Second, recreate the subdir scenario in the Qt toolchain file by
setting CMAKE_FIND_ROOT_PATH to the current (relocated) install
prefix as usual, but also setting CMAKE_PREFIX_PATH to a new value
poining to the CMake directory.
Aka '/home/alex/qt' and '/home/alex/qt/lib/cmake'.
Third, when a QT_HOST_PATH is given, save 2 paths in the generated Qt
toolchain: QT_HOST_PATH and QT_HOST_PATH_CMAKE_DIR. There are the host
equivalents of the target ones above. Use these values when looking
for host tools in Qt6CoreModuleDependencies.cmake, again facilitaing
the subdir behavior.
Note these are currently absolute paths and are not relocatable.
We'll have to figure out if it's even possible to make the host path
relocatable.
Finally as a cleanup, look for the Qt6HostInfo package in QtSetup
strictly in the given QT_HOST_PATH, so CMake doesn't accidentally find
a system Qt package.
Change-Id: Iefbcfbbcedd35f1c33417ab7e9f44eaf35ff6337
Reviewed-by: Cristian Adam <cristian.adam@qt.io>
2020-07-21 15:34:40 +00:00
|
|
|
list(PREPEND CMAKE_PREFIX_PATH "${QT_HOST_PATH_CMAKE_DIR}")
|
2020-04-27 13:04:57 +00:00
|
|
|
list(PREPEND CMAKE_FIND_ROOT_PATH "${QT_HOST_PATH}")
|
|
|
|
endif()
|
|
|
|
|
2019-04-29 12:36:25 +00:00
|
|
|
foreach(_target_dep ${_tool_deps})
|
|
|
|
list(GET _target_dep 0 pkg)
|
|
|
|
list(GET _target_dep 1 version)
|
|
|
|
|
2020-09-14 07:06:58 +00:00
|
|
|
unset(find_package_args)
|
|
|
|
if(${CMAKE_FIND_PACKAGE_NAME}_FIND_QUIETLY)
|
|
|
|
list(APPEND find_package_args QUIET)
|
|
|
|
endif()
|
|
|
|
if(${CMAKE_FIND_PACKAGE_NAME}_FIND_REQUIRED)
|
|
|
|
list(APPEND find_package_args REQUIRED)
|
|
|
|
endif()
|
2021-05-07 14:10:29 +00:00
|
|
|
find_package(${pkg} ${version} ${find_package_args}
|
|
|
|
PATHS
|
|
|
|
${_qt_additional_packages_prefix_path}
|
|
|
|
${_qt_additional_packages_prefix_path_env}
|
|
|
|
)
|
2019-04-29 12:36:25 +00:00
|
|
|
if (NOT ${pkg}_FOUND)
|
2020-12-15 17:09:32 +00:00
|
|
|
if(NOT "${QT_HOST_PATH}" STREQUAL "")
|
2020-04-27 13:04:57 +00:00
|
|
|
set(CMAKE_PREFIX_PATH ${BACKUP_@target@_CMAKE_PREFIX_PATH})
|
|
|
|
set(CMAKE_FIND_ROOT_PATH ${BACKUP_@target@_CMAKE_FIND_ROOT_PATH})
|
|
|
|
endif()
|
2019-04-29 12:36:25 +00:00
|
|
|
return()
|
|
|
|
endif()
|
|
|
|
endforeach()
|
2020-12-15 17:09:32 +00:00
|
|
|
if(NOT "${QT_HOST_PATH}" STREQUAL "")
|
2020-04-27 13:04:57 +00:00
|
|
|
set(CMAKE_PREFIX_PATH ${BACKUP_@target@_CMAKE_PREFIX_PATH})
|
|
|
|
set(CMAKE_FIND_ROOT_PATH ${BACKUP_@target@_CMAKE_FIND_ROOT_PATH})
|
|
|
|
endif()
|
2019-04-29 12:36:25 +00:00
|
|
|
|
2021-04-06 16:57:11 +00:00
|
|
|
# TODO: The dependencies lookup mechanism is common for Modules and Plugins.
|
|
|
|
# It should be moved to the common public helper file.
|
|
|
|
#
|
2019-06-14 10:59:07 +00:00
|
|
|
# note: target_deps example: "Qt6Core\;5.12.0;Qt6Gui\;5.12.0"
|
2019-05-03 09:38:41 +00:00
|
|
|
set(_target_deps "@target_deps@")
|
|
|
|
foreach(_target_dep ${_target_deps})
|
|
|
|
list(GET _target_dep 0 pkg)
|
|
|
|
list(GET _target_dep 1 version)
|
|
|
|
|
2021-04-06 16:57:11 +00:00
|
|
|
if(NOT ${pkg}_FOUND)
|
|
|
|
set(pkg_names ${pkg})
|
|
|
|
if(pkg MATCHES "(.*)Private$")
|
|
|
|
set(pkg_names "${CMAKE_MATCH_1};${pkg}")
|
|
|
|
endif()
|
2019-05-03 09:38:41 +00:00
|
|
|
find_dependency(${pkg} ${version}
|
2021-04-06 16:57:11 +00:00
|
|
|
NAMES
|
|
|
|
${pkg_names}
|
2020-09-25 18:02:56 +00:00
|
|
|
PATHS
|
|
|
|
"${CMAKE_CURRENT_LIST_DIR}/.."
|
2021-02-24 15:07:37 +00:00
|
|
|
${_qt_additional_packages_prefix_path}
|
|
|
|
${_qt_additional_packages_prefix_path_env}
|
2020-09-25 18:02:56 +00:00
|
|
|
${QT_EXAMPLES_CMAKE_PREFIX_PATH}
|
|
|
|
${__qt_use_no_default_path_for_qt_packages}
|
2019-05-03 09:38:41 +00:00
|
|
|
)
|
|
|
|
endif()
|
|
|
|
endforeach()
|
|
|
|
|
2020-07-14 16:08:07 +00:00
|
|
|
set(_@QT_CMAKE_EXPORT_NAMESPACE@@target@_MODULE_DEPENDENCIES "@qt_module_dependencies@")
|
2020-09-14 07:06:58 +00:00
|
|
|
set(@INSTALL_CMAKE_NAMESPACE@@target@_FOUND TRUE)
|