2018-10-24 13:20:27 +00:00
|
|
|
@PACKAGE_INIT@
|
|
|
|
|
2020-11-30 07:46:49 +00:00
|
|
|
cmake_minimum_required(VERSION @min_new_policy_version@...@max_new_policy_version@)
|
2018-10-24 13:20:27 +00:00
|
|
|
|
2021-07-22 14:23:51 +00:00
|
|
|
include("${CMAKE_CURRENT_LIST_DIR}/@INSTALL_CMAKE_NAMESPACE@ConfigExtras.cmake")
|
|
|
|
include("${CMAKE_CURRENT_LIST_DIR}/QtPublicCMakeVersionHelpers.cmake")
|
|
|
|
__qt_internal_require_suitable_cmake_version_for_using_qt()
|
|
|
|
|
2019-02-11 10:34:35 +00:00
|
|
|
get_filename_component(_qt_cmake_dir "${CMAKE_CURRENT_LIST_DIR}/.." ABSOLUTE)
|
2019-09-19 11:46:37 +00:00
|
|
|
set(_qt_@PROJECT_VERSION_MAJOR@_config_cmake_dir "${CMAKE_CURRENT_LIST_DIR}")
|
2018-10-24 13:20:27 +00:00
|
|
|
|
2019-06-04 15:08:47 +00:00
|
|
|
if (NOT QT_NO_CREATE_TARGETS)
|
|
|
|
include("${CMAKE_CURRENT_LIST_DIR}/@INSTALL_CMAKE_NAMESPACE@Targets.cmake")
|
2019-12-05 12:54:07 +00:00
|
|
|
if(NOT QT_NO_CREATE_VERSIONLESS_TARGETS)
|
|
|
|
include("${CMAKE_CURRENT_LIST_DIR}/@INSTALL_CMAKE_NAMESPACE@VersionlessTargets.cmake")
|
|
|
|
endif()
|
2019-06-04 15:08:47 +00:00
|
|
|
else()
|
|
|
|
# For examples using `find_package(...)` inside their CMakeLists.txt files:
|
|
|
|
# Make CMake's AUTOGEN detect this Qt version properly
|
|
|
|
set_directory_properties(PROPERTIES
|
|
|
|
QT_VERSION_MAJOR @PROJECT_VERSION_MAJOR@
|
2019-12-11 15:14:22 +00:00
|
|
|
QT_VERSION_MINOR @PROJECT_VERSION_MINOR@
|
|
|
|
QT_VERSION_PATCH @PROJECT_VERSION_PATCH@)
|
2019-06-04 15:08:47 +00:00
|
|
|
endif()
|
2019-05-03 10:30:09 +00:00
|
|
|
|
2019-09-30 11:22:15 +00:00
|
|
|
get_filename_component(_qt_import_prefix "${CMAKE_CURRENT_LIST_FILE}" PATH)
|
|
|
|
get_filename_component(_qt_import_prefix "${_qt_import_prefix}" REALPATH)
|
|
|
|
list(APPEND CMAKE_MODULE_PATH "${_qt_import_prefix}")
|
|
|
|
list(APPEND CMAKE_MODULE_PATH "${_qt_import_prefix}/3rdparty/extra-cmake-modules/find-modules")
|
|
|
|
list(APPEND CMAKE_MODULE_PATH "${_qt_import_prefix}/3rdparty/kwin")
|
|
|
|
|
2020-06-25 15:53:53 +00:00
|
|
|
if(APPLE AND (NOT CMAKE_SYSTEM_NAME OR CMAKE_SYSTEM_NAME STREQUAL "Darwin"))
|
|
|
|
# Add module directory to pick up custom Info.plist template for macOS
|
cmake: Add default Info.plist for macOS with some important keys
The default Info.plist shipped with CMake lacks an NSPrincipalClass
entry, which is crucial for making macOS apps run in full resolution
on retina screens.
We make sure the file is only picked up on macOS, not iOS and friends,
since those platforms require another principal class. If needed we can
extract the value out as a CMake variable and use the same file for all
Apple platforms. Doing so would assume all keys are single-platform
only, so if that's not the case we need platform-specific files.
We should probably extract the package type out as a variable too,
so that the file can be used for both apps, plugins, and frameworks,
but doing so requires setting up that variable somewhere based on
the target type, which CMake doesn't allow in an easy way.
The file itself is based on the file CMake ships, combined with
keys inherited from Qt's existing plist templates for qmake, and
adjusted to match what Xcode generates by default these days.
Change-Id: I3f5109e5fff63cdbd109a99d4008948d4bd2102b
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2020-03-11 20:45:50 +00:00
|
|
|
list(APPEND CMAKE_MODULE_PATH "${_qt_import_prefix}/macos")
|
2021-04-14 16:16:44 +00:00
|
|
|
elseif(APPLE AND CMAKE_SYSTEM_NAME STREQUAL "iOS")
|
|
|
|
# Add module directory to pick up custom Info.plist template for iOS
|
2021-07-15 14:20:20 +00:00
|
|
|
set(__qt_internal_cmake_ios_support_files_path "${_qt_import_prefix}/ios")
|
|
|
|
list(APPEND CMAKE_MODULE_PATH "${__qt_internal_cmake_ios_support_files_path}")
|
cmake: Add default Info.plist for macOS with some important keys
The default Info.plist shipped with CMake lacks an NSPrincipalClass
entry, which is crucial for making macOS apps run in full resolution
on retina screens.
We make sure the file is only picked up on macOS, not iOS and friends,
since those platforms require another principal class. If needed we can
extract the value out as a CMake variable and use the same file for all
Apple platforms. Doing so would assume all keys are single-platform
only, so if that's not the case we need platform-specific files.
We should probably extract the package type out as a variable too,
so that the file can be used for both apps, plugins, and frameworks,
but doing so requires setting up that variable somewhere based on
the target type, which CMake doesn't allow in an easy way.
The file itself is based on the file CMake ships, combined with
keys inherited from Qt's existing plist templates for qmake, and
adjusted to match what Xcode generates by default these days.
Change-Id: I3f5109e5fff63cdbd109a99d4008948d4bd2102b
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2020-03-11 20:45:50 +00:00
|
|
|
endif()
|
|
|
|
|
CMake: Fix QT_ADDITIONAL_PACKAGES_PREFIX_PATH for cross-builds
The QT_ADDITIONAL_PACKAGES_PREFIX_PATH variable was introduced to
allow specifying extra locations to find Qt packages.
The reason it was introduced instead of just using CMAKE_PREFIX_PATH
is because the Qt6 component find_package call uses NO_DEFAULT_PATH
which means CMAKE_PREFIX_PATH is ignored.
We use NO_DEFAULT_PATH to ensure we don't accidentally pick up
system / distro Qt packages.
The paths from QT_ADDITIONAL_PACKAGES_PREFIX_PATH are added to the
find_package PATHS option in the Qt6 package, each
ModuleDependencies.cmake file and some other places.
Unfortunately that's not enough to make it work for cross-builds.
Imagine the following scenario.
host qtbase, qtdeclarative installed in /host_qt
target qtbase installed in /target_qtbase
target qtdeclarative installed in /target_qtdeclarative
We want to cross-build qtlottie.
We configure qtlottie as follows
/target_qtbase/bin/qt-configure-module /qtlottie_src -- -DQT_ADDITIONAL_PACKAGES_PREFIX_PATH=/target_qtdeclarative
We expect the target QtQuick package to be found, but it won't be.
The reason is that QT_ADDITIONAL_PACKAGES_PREFIX_PATH is added to the
PATHs option, but we don't adjust CMAKE_FIND_ROOT_PATH.
Without adding the new paths in CMAKE_FIND_ROOT_PATH, CMake will
re-root the passed PATHs under the existing CMAKE_FIND_ROOT_PATH,
which is QT_TOOLCHAIN_RELOCATABLE_INSTALL_PREFIX, which evaluates to
/target_qtbase. There is no QtQuick package there.
To fix this, prepend the values of QT_ADDITIONAL_PACKAGES_PREFIX_PATH
to CMAKE_FIND_ROOT_PATH.
The location where we currently do CMAKE_FIND_ROOT_PATH manipulations
is in the qt.toolchain.cmake file, so to be consistent, we prepend the
new prefixes there as well.
We need to adjust both CMAKE_FIND_ROOT_PATH and CMAKE_PREFIX_PATH,
due the path re-rooting bug in CMake.
See https://gitlab.kitware.com/cmake/cmake/-/issues/21937 as well as
the existing comment in qt.toolchain.cmake marked with
REROOT_PATH_ISSUE_MARKER.
We also need to do a few more things to make the setup work
Because Qt6Config uses NO_DEFAULT_PATH, the CMAKE_PREFIX_PATH
adjustments we do in the toolchain file are not enough, so we still need
to add the same prefixes to the Qt6Config find_package PATHS option.
One would ask why do we need to adjust CMAKE_PREFIX_PATH at all then.
It's for find_package(Qt6Foo) calls to work which don't go through
the Qt6Config umbrella package.
To make the CMake re-rooting behavior happy, we need to ensure the
provided paths are absolute.
So we iterate over the values of QT_ADDITIONAL_PACKAGES_PREFIX_PATH,
to make them absolute. We do the same for the environment variable.
We need to append lib/cmake to the prefixes which are added to
CMAKE_PREFIX_PATH, otherwise the CMake re-rooting bug is hit.
We need to specify the Qt6 package location (${_qt_cmake_dir}) to the
PATHS option in the various Dependencies.cmake.in files, to ensure
that dependency resolution can jump around between the Qt6 dir and
the additional prefixes. Previously the dependency lookup code assumed
that all dependencies would be within the same prefix.
The same is needed for qt and qml plugin dependency lookup.
Amends 7bb91398f25cb2016c0558fd397b376f413e3e96
Amends 60c87c68016c6f02b0eddd4002f75a49ab51d4a8
Amends 5bbd700124d13a292ff8bae6045316112500e230
Pick-to: 6.2
Fixes: QTBUG-95854
Change-Id: I35ae82330fec427d0d38fc9a0542ffafff52556a
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2021-08-17 15:03:02 +00:00
|
|
|
set(QT_ADDITIONAL_PACKAGES_PREFIX_PATH "" CACHE STRING
|
|
|
|
"Additional directories where find(Qt6 ...) components are searched")
|
2022-01-11 16:44:10 +00:00
|
|
|
set(QT_ADDITIONAL_HOST_PACKAGES_PREFIX_PATH "" CACHE STRING
|
|
|
|
"Additional directories where find(Qt6 ...) host Qt components are searched")
|
CMake: Fix QT_ADDITIONAL_PACKAGES_PREFIX_PATH for cross-builds
The QT_ADDITIONAL_PACKAGES_PREFIX_PATH variable was introduced to
allow specifying extra locations to find Qt packages.
The reason it was introduced instead of just using CMAKE_PREFIX_PATH
is because the Qt6 component find_package call uses NO_DEFAULT_PATH
which means CMAKE_PREFIX_PATH is ignored.
We use NO_DEFAULT_PATH to ensure we don't accidentally pick up
system / distro Qt packages.
The paths from QT_ADDITIONAL_PACKAGES_PREFIX_PATH are added to the
find_package PATHS option in the Qt6 package, each
ModuleDependencies.cmake file and some other places.
Unfortunately that's not enough to make it work for cross-builds.
Imagine the following scenario.
host qtbase, qtdeclarative installed in /host_qt
target qtbase installed in /target_qtbase
target qtdeclarative installed in /target_qtdeclarative
We want to cross-build qtlottie.
We configure qtlottie as follows
/target_qtbase/bin/qt-configure-module /qtlottie_src -- -DQT_ADDITIONAL_PACKAGES_PREFIX_PATH=/target_qtdeclarative
We expect the target QtQuick package to be found, but it won't be.
The reason is that QT_ADDITIONAL_PACKAGES_PREFIX_PATH is added to the
PATHs option, but we don't adjust CMAKE_FIND_ROOT_PATH.
Without adding the new paths in CMAKE_FIND_ROOT_PATH, CMake will
re-root the passed PATHs under the existing CMAKE_FIND_ROOT_PATH,
which is QT_TOOLCHAIN_RELOCATABLE_INSTALL_PREFIX, which evaluates to
/target_qtbase. There is no QtQuick package there.
To fix this, prepend the values of QT_ADDITIONAL_PACKAGES_PREFIX_PATH
to CMAKE_FIND_ROOT_PATH.
The location where we currently do CMAKE_FIND_ROOT_PATH manipulations
is in the qt.toolchain.cmake file, so to be consistent, we prepend the
new prefixes there as well.
We need to adjust both CMAKE_FIND_ROOT_PATH and CMAKE_PREFIX_PATH,
due the path re-rooting bug in CMake.
See https://gitlab.kitware.com/cmake/cmake/-/issues/21937 as well as
the existing comment in qt.toolchain.cmake marked with
REROOT_PATH_ISSUE_MARKER.
We also need to do a few more things to make the setup work
Because Qt6Config uses NO_DEFAULT_PATH, the CMAKE_PREFIX_PATH
adjustments we do in the toolchain file are not enough, so we still need
to add the same prefixes to the Qt6Config find_package PATHS option.
One would ask why do we need to adjust CMAKE_PREFIX_PATH at all then.
It's for find_package(Qt6Foo) calls to work which don't go through
the Qt6Config umbrella package.
To make the CMake re-rooting behavior happy, we need to ensure the
provided paths are absolute.
So we iterate over the values of QT_ADDITIONAL_PACKAGES_PREFIX_PATH,
to make them absolute. We do the same for the environment variable.
We need to append lib/cmake to the prefixes which are added to
CMAKE_PREFIX_PATH, otherwise the CMake re-rooting bug is hit.
We need to specify the Qt6 package location (${_qt_cmake_dir}) to the
PATHS option in the various Dependencies.cmake.in files, to ensure
that dependency resolution can jump around between the Qt6 dir and
the additional prefixes. Previously the dependency lookup code assumed
that all dependencies would be within the same prefix.
The same is needed for qt and qml plugin dependency lookup.
Amends 7bb91398f25cb2016c0558fd397b376f413e3e96
Amends 60c87c68016c6f02b0eddd4002f75a49ab51d4a8
Amends 5bbd700124d13a292ff8bae6045316112500e230
Pick-to: 6.2
Fixes: QTBUG-95854
Change-Id: I35ae82330fec427d0d38fc9a0542ffafff52556a
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2021-08-17 15:03:02 +00:00
|
|
|
|
|
|
|
# Collect additional package prefix paths to look for Qt packages, both from command line and the
|
2022-01-11 16:44:10 +00:00
|
|
|
# env variable ${prefixes_var}. The result is stored in ${out_var} and is a list of paths ending
|
|
|
|
# with "/lib/cmake".
|
|
|
|
function(__qt_internal_collect_additional_prefix_paths out_var prefixes_var)
|
|
|
|
if(DEFINED "${out_var}")
|
|
|
|
return()
|
|
|
|
endif()
|
|
|
|
|
|
|
|
set(additional_packages_prefix_paths "")
|
CMake: Fix QT_ADDITIONAL_PACKAGES_PREFIX_PATH for cross-builds
The QT_ADDITIONAL_PACKAGES_PREFIX_PATH variable was introduced to
allow specifying extra locations to find Qt packages.
The reason it was introduced instead of just using CMAKE_PREFIX_PATH
is because the Qt6 component find_package call uses NO_DEFAULT_PATH
which means CMAKE_PREFIX_PATH is ignored.
We use NO_DEFAULT_PATH to ensure we don't accidentally pick up
system / distro Qt packages.
The paths from QT_ADDITIONAL_PACKAGES_PREFIX_PATH are added to the
find_package PATHS option in the Qt6 package, each
ModuleDependencies.cmake file and some other places.
Unfortunately that's not enough to make it work for cross-builds.
Imagine the following scenario.
host qtbase, qtdeclarative installed in /host_qt
target qtbase installed in /target_qtbase
target qtdeclarative installed in /target_qtdeclarative
We want to cross-build qtlottie.
We configure qtlottie as follows
/target_qtbase/bin/qt-configure-module /qtlottie_src -- -DQT_ADDITIONAL_PACKAGES_PREFIX_PATH=/target_qtdeclarative
We expect the target QtQuick package to be found, but it won't be.
The reason is that QT_ADDITIONAL_PACKAGES_PREFIX_PATH is added to the
PATHs option, but we don't adjust CMAKE_FIND_ROOT_PATH.
Without adding the new paths in CMAKE_FIND_ROOT_PATH, CMake will
re-root the passed PATHs under the existing CMAKE_FIND_ROOT_PATH,
which is QT_TOOLCHAIN_RELOCATABLE_INSTALL_PREFIX, which evaluates to
/target_qtbase. There is no QtQuick package there.
To fix this, prepend the values of QT_ADDITIONAL_PACKAGES_PREFIX_PATH
to CMAKE_FIND_ROOT_PATH.
The location where we currently do CMAKE_FIND_ROOT_PATH manipulations
is in the qt.toolchain.cmake file, so to be consistent, we prepend the
new prefixes there as well.
We need to adjust both CMAKE_FIND_ROOT_PATH and CMAKE_PREFIX_PATH,
due the path re-rooting bug in CMake.
See https://gitlab.kitware.com/cmake/cmake/-/issues/21937 as well as
the existing comment in qt.toolchain.cmake marked with
REROOT_PATH_ISSUE_MARKER.
We also need to do a few more things to make the setup work
Because Qt6Config uses NO_DEFAULT_PATH, the CMAKE_PREFIX_PATH
adjustments we do in the toolchain file are not enough, so we still need
to add the same prefixes to the Qt6Config find_package PATHS option.
One would ask why do we need to adjust CMAKE_PREFIX_PATH at all then.
It's for find_package(Qt6Foo) calls to work which don't go through
the Qt6Config umbrella package.
To make the CMake re-rooting behavior happy, we need to ensure the
provided paths are absolute.
So we iterate over the values of QT_ADDITIONAL_PACKAGES_PREFIX_PATH,
to make them absolute. We do the same for the environment variable.
We need to append lib/cmake to the prefixes which are added to
CMAKE_PREFIX_PATH, otherwise the CMake re-rooting bug is hit.
We need to specify the Qt6 package location (${_qt_cmake_dir}) to the
PATHS option in the various Dependencies.cmake.in files, to ensure
that dependency resolution can jump around between the Qt6 dir and
the additional prefixes. Previously the dependency lookup code assumed
that all dependencies would be within the same prefix.
The same is needed for qt and qml plugin dependency lookup.
Amends 7bb91398f25cb2016c0558fd397b376f413e3e96
Amends 60c87c68016c6f02b0eddd4002f75a49ab51d4a8
Amends 5bbd700124d13a292ff8bae6045316112500e230
Pick-to: 6.2
Fixes: QTBUG-95854
Change-Id: I35ae82330fec427d0d38fc9a0542ffafff52556a
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2021-08-17 15:03:02 +00:00
|
|
|
|
2022-01-11 16:44:10 +00:00
|
|
|
set(additional_packages_prefixes "")
|
|
|
|
if(${prefixes_var})
|
|
|
|
list(APPEND additional_packages_prefixes ${${prefixes_var}})
|
CMake: Fix QT_ADDITIONAL_PACKAGES_PREFIX_PATH for cross-builds
The QT_ADDITIONAL_PACKAGES_PREFIX_PATH variable was introduced to
allow specifying extra locations to find Qt packages.
The reason it was introduced instead of just using CMAKE_PREFIX_PATH
is because the Qt6 component find_package call uses NO_DEFAULT_PATH
which means CMAKE_PREFIX_PATH is ignored.
We use NO_DEFAULT_PATH to ensure we don't accidentally pick up
system / distro Qt packages.
The paths from QT_ADDITIONAL_PACKAGES_PREFIX_PATH are added to the
find_package PATHS option in the Qt6 package, each
ModuleDependencies.cmake file and some other places.
Unfortunately that's not enough to make it work for cross-builds.
Imagine the following scenario.
host qtbase, qtdeclarative installed in /host_qt
target qtbase installed in /target_qtbase
target qtdeclarative installed in /target_qtdeclarative
We want to cross-build qtlottie.
We configure qtlottie as follows
/target_qtbase/bin/qt-configure-module /qtlottie_src -- -DQT_ADDITIONAL_PACKAGES_PREFIX_PATH=/target_qtdeclarative
We expect the target QtQuick package to be found, but it won't be.
The reason is that QT_ADDITIONAL_PACKAGES_PREFIX_PATH is added to the
PATHs option, but we don't adjust CMAKE_FIND_ROOT_PATH.
Without adding the new paths in CMAKE_FIND_ROOT_PATH, CMake will
re-root the passed PATHs under the existing CMAKE_FIND_ROOT_PATH,
which is QT_TOOLCHAIN_RELOCATABLE_INSTALL_PREFIX, which evaluates to
/target_qtbase. There is no QtQuick package there.
To fix this, prepend the values of QT_ADDITIONAL_PACKAGES_PREFIX_PATH
to CMAKE_FIND_ROOT_PATH.
The location where we currently do CMAKE_FIND_ROOT_PATH manipulations
is in the qt.toolchain.cmake file, so to be consistent, we prepend the
new prefixes there as well.
We need to adjust both CMAKE_FIND_ROOT_PATH and CMAKE_PREFIX_PATH,
due the path re-rooting bug in CMake.
See https://gitlab.kitware.com/cmake/cmake/-/issues/21937 as well as
the existing comment in qt.toolchain.cmake marked with
REROOT_PATH_ISSUE_MARKER.
We also need to do a few more things to make the setup work
Because Qt6Config uses NO_DEFAULT_PATH, the CMAKE_PREFIX_PATH
adjustments we do in the toolchain file are not enough, so we still need
to add the same prefixes to the Qt6Config find_package PATHS option.
One would ask why do we need to adjust CMAKE_PREFIX_PATH at all then.
It's for find_package(Qt6Foo) calls to work which don't go through
the Qt6Config umbrella package.
To make the CMake re-rooting behavior happy, we need to ensure the
provided paths are absolute.
So we iterate over the values of QT_ADDITIONAL_PACKAGES_PREFIX_PATH,
to make them absolute. We do the same for the environment variable.
We need to append lib/cmake to the prefixes which are added to
CMAKE_PREFIX_PATH, otherwise the CMake re-rooting bug is hit.
We need to specify the Qt6 package location (${_qt_cmake_dir}) to the
PATHS option in the various Dependencies.cmake.in files, to ensure
that dependency resolution can jump around between the Qt6 dir and
the additional prefixes. Previously the dependency lookup code assumed
that all dependencies would be within the same prefix.
The same is needed for qt and qml plugin dependency lookup.
Amends 7bb91398f25cb2016c0558fd397b376f413e3e96
Amends 60c87c68016c6f02b0eddd4002f75a49ab51d4a8
Amends 5bbd700124d13a292ff8bae6045316112500e230
Pick-to: 6.2
Fixes: QTBUG-95854
Change-Id: I35ae82330fec427d0d38fc9a0542ffafff52556a
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2021-08-17 15:03:02 +00:00
|
|
|
endif()
|
2022-01-11 16:44:10 +00:00
|
|
|
if(DEFINED ENV{${prefixes_var}}
|
|
|
|
AND NOT "$ENV{${prefixes_var}}" STREQUAL "")
|
2022-02-22 13:14:26 +00:00
|
|
|
set(prefixes_from_env "$ENV{${prefixes_var}}")
|
|
|
|
if(NOT CMAKE_HOST_WIN32)
|
|
|
|
string(REPLACE ":" ";" prefixes_from_env "${prefixes_from_env}")
|
|
|
|
endif()
|
|
|
|
list(APPEND additional_packages_prefixes ${prefixes_from_env})
|
CMake: Fix QT_ADDITIONAL_PACKAGES_PREFIX_PATH for cross-builds
The QT_ADDITIONAL_PACKAGES_PREFIX_PATH variable was introduced to
allow specifying extra locations to find Qt packages.
The reason it was introduced instead of just using CMAKE_PREFIX_PATH
is because the Qt6 component find_package call uses NO_DEFAULT_PATH
which means CMAKE_PREFIX_PATH is ignored.
We use NO_DEFAULT_PATH to ensure we don't accidentally pick up
system / distro Qt packages.
The paths from QT_ADDITIONAL_PACKAGES_PREFIX_PATH are added to the
find_package PATHS option in the Qt6 package, each
ModuleDependencies.cmake file and some other places.
Unfortunately that's not enough to make it work for cross-builds.
Imagine the following scenario.
host qtbase, qtdeclarative installed in /host_qt
target qtbase installed in /target_qtbase
target qtdeclarative installed in /target_qtdeclarative
We want to cross-build qtlottie.
We configure qtlottie as follows
/target_qtbase/bin/qt-configure-module /qtlottie_src -- -DQT_ADDITIONAL_PACKAGES_PREFIX_PATH=/target_qtdeclarative
We expect the target QtQuick package to be found, but it won't be.
The reason is that QT_ADDITIONAL_PACKAGES_PREFIX_PATH is added to the
PATHs option, but we don't adjust CMAKE_FIND_ROOT_PATH.
Without adding the new paths in CMAKE_FIND_ROOT_PATH, CMake will
re-root the passed PATHs under the existing CMAKE_FIND_ROOT_PATH,
which is QT_TOOLCHAIN_RELOCATABLE_INSTALL_PREFIX, which evaluates to
/target_qtbase. There is no QtQuick package there.
To fix this, prepend the values of QT_ADDITIONAL_PACKAGES_PREFIX_PATH
to CMAKE_FIND_ROOT_PATH.
The location where we currently do CMAKE_FIND_ROOT_PATH manipulations
is in the qt.toolchain.cmake file, so to be consistent, we prepend the
new prefixes there as well.
We need to adjust both CMAKE_FIND_ROOT_PATH and CMAKE_PREFIX_PATH,
due the path re-rooting bug in CMake.
See https://gitlab.kitware.com/cmake/cmake/-/issues/21937 as well as
the existing comment in qt.toolchain.cmake marked with
REROOT_PATH_ISSUE_MARKER.
We also need to do a few more things to make the setup work
Because Qt6Config uses NO_DEFAULT_PATH, the CMAKE_PREFIX_PATH
adjustments we do in the toolchain file are not enough, so we still need
to add the same prefixes to the Qt6Config find_package PATHS option.
One would ask why do we need to adjust CMAKE_PREFIX_PATH at all then.
It's for find_package(Qt6Foo) calls to work which don't go through
the Qt6Config umbrella package.
To make the CMake re-rooting behavior happy, we need to ensure the
provided paths are absolute.
So we iterate over the values of QT_ADDITIONAL_PACKAGES_PREFIX_PATH,
to make them absolute. We do the same for the environment variable.
We need to append lib/cmake to the prefixes which are added to
CMAKE_PREFIX_PATH, otherwise the CMake re-rooting bug is hit.
We need to specify the Qt6 package location (${_qt_cmake_dir}) to the
PATHS option in the various Dependencies.cmake.in files, to ensure
that dependency resolution can jump around between the Qt6 dir and
the additional prefixes. Previously the dependency lookup code assumed
that all dependencies would be within the same prefix.
The same is needed for qt and qml plugin dependency lookup.
Amends 7bb91398f25cb2016c0558fd397b376f413e3e96
Amends 60c87c68016c6f02b0eddd4002f75a49ab51d4a8
Amends 5bbd700124d13a292ff8bae6045316112500e230
Pick-to: 6.2
Fixes: QTBUG-95854
Change-Id: I35ae82330fec427d0d38fc9a0542ffafff52556a
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2021-08-17 15:03:02 +00:00
|
|
|
endif()
|
|
|
|
|
2022-01-11 16:44:10 +00:00
|
|
|
foreach(additional_path IN LISTS additional_packages_prefixes)
|
|
|
|
file(TO_CMAKE_PATH "${additional_path}" additional_path)
|
CMake: Fix QT_ADDITIONAL_PACKAGES_PREFIX_PATH for cross-builds
The QT_ADDITIONAL_PACKAGES_PREFIX_PATH variable was introduced to
allow specifying extra locations to find Qt packages.
The reason it was introduced instead of just using CMAKE_PREFIX_PATH
is because the Qt6 component find_package call uses NO_DEFAULT_PATH
which means CMAKE_PREFIX_PATH is ignored.
We use NO_DEFAULT_PATH to ensure we don't accidentally pick up
system / distro Qt packages.
The paths from QT_ADDITIONAL_PACKAGES_PREFIX_PATH are added to the
find_package PATHS option in the Qt6 package, each
ModuleDependencies.cmake file and some other places.
Unfortunately that's not enough to make it work for cross-builds.
Imagine the following scenario.
host qtbase, qtdeclarative installed in /host_qt
target qtbase installed in /target_qtbase
target qtdeclarative installed in /target_qtdeclarative
We want to cross-build qtlottie.
We configure qtlottie as follows
/target_qtbase/bin/qt-configure-module /qtlottie_src -- -DQT_ADDITIONAL_PACKAGES_PREFIX_PATH=/target_qtdeclarative
We expect the target QtQuick package to be found, but it won't be.
The reason is that QT_ADDITIONAL_PACKAGES_PREFIX_PATH is added to the
PATHs option, but we don't adjust CMAKE_FIND_ROOT_PATH.
Without adding the new paths in CMAKE_FIND_ROOT_PATH, CMake will
re-root the passed PATHs under the existing CMAKE_FIND_ROOT_PATH,
which is QT_TOOLCHAIN_RELOCATABLE_INSTALL_PREFIX, which evaluates to
/target_qtbase. There is no QtQuick package there.
To fix this, prepend the values of QT_ADDITIONAL_PACKAGES_PREFIX_PATH
to CMAKE_FIND_ROOT_PATH.
The location where we currently do CMAKE_FIND_ROOT_PATH manipulations
is in the qt.toolchain.cmake file, so to be consistent, we prepend the
new prefixes there as well.
We need to adjust both CMAKE_FIND_ROOT_PATH and CMAKE_PREFIX_PATH,
due the path re-rooting bug in CMake.
See https://gitlab.kitware.com/cmake/cmake/-/issues/21937 as well as
the existing comment in qt.toolchain.cmake marked with
REROOT_PATH_ISSUE_MARKER.
We also need to do a few more things to make the setup work
Because Qt6Config uses NO_DEFAULT_PATH, the CMAKE_PREFIX_PATH
adjustments we do in the toolchain file are not enough, so we still need
to add the same prefixes to the Qt6Config find_package PATHS option.
One would ask why do we need to adjust CMAKE_PREFIX_PATH at all then.
It's for find_package(Qt6Foo) calls to work which don't go through
the Qt6Config umbrella package.
To make the CMake re-rooting behavior happy, we need to ensure the
provided paths are absolute.
So we iterate over the values of QT_ADDITIONAL_PACKAGES_PREFIX_PATH,
to make them absolute. We do the same for the environment variable.
We need to append lib/cmake to the prefixes which are added to
CMAKE_PREFIX_PATH, otherwise the CMake re-rooting bug is hit.
We need to specify the Qt6 package location (${_qt_cmake_dir}) to the
PATHS option in the various Dependencies.cmake.in files, to ensure
that dependency resolution can jump around between the Qt6 dir and
the additional prefixes. Previously the dependency lookup code assumed
that all dependencies would be within the same prefix.
The same is needed for qt and qml plugin dependency lookup.
Amends 7bb91398f25cb2016c0558fd397b376f413e3e96
Amends 60c87c68016c6f02b0eddd4002f75a49ab51d4a8
Amends 5bbd700124d13a292ff8bae6045316112500e230
Pick-to: 6.2
Fixes: QTBUG-95854
Change-Id: I35ae82330fec427d0d38fc9a0542ffafff52556a
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2021-08-17 15:03:02 +00:00
|
|
|
|
|
|
|
# The prefix paths need to end with lib/cmake to ensure the packages are found when
|
|
|
|
# cross compiling. Search for REROOT_PATH_ISSUE_MARKER in the qt.toolchain.cmake file for
|
|
|
|
# details.
|
|
|
|
# We must pass the values via the PATHS options because the main find_package call uses
|
|
|
|
# NO_DEFAULT_PATH, and thus CMAKE_PREFIX_PATH values are discarded.
|
|
|
|
# CMAKE_FIND_ROOT_PATH values are not discarded and togegher with the PATHS option, it
|
|
|
|
# ensures packages from additional prefixes are found.
|
2022-01-11 16:44:10 +00:00
|
|
|
if(NOT additional_path MATCHES "/lib/cmake$")
|
|
|
|
string(APPEND additional_path "/lib/cmake")
|
CMake: Fix QT_ADDITIONAL_PACKAGES_PREFIX_PATH for cross-builds
The QT_ADDITIONAL_PACKAGES_PREFIX_PATH variable was introduced to
allow specifying extra locations to find Qt packages.
The reason it was introduced instead of just using CMAKE_PREFIX_PATH
is because the Qt6 component find_package call uses NO_DEFAULT_PATH
which means CMAKE_PREFIX_PATH is ignored.
We use NO_DEFAULT_PATH to ensure we don't accidentally pick up
system / distro Qt packages.
The paths from QT_ADDITIONAL_PACKAGES_PREFIX_PATH are added to the
find_package PATHS option in the Qt6 package, each
ModuleDependencies.cmake file and some other places.
Unfortunately that's not enough to make it work for cross-builds.
Imagine the following scenario.
host qtbase, qtdeclarative installed in /host_qt
target qtbase installed in /target_qtbase
target qtdeclarative installed in /target_qtdeclarative
We want to cross-build qtlottie.
We configure qtlottie as follows
/target_qtbase/bin/qt-configure-module /qtlottie_src -- -DQT_ADDITIONAL_PACKAGES_PREFIX_PATH=/target_qtdeclarative
We expect the target QtQuick package to be found, but it won't be.
The reason is that QT_ADDITIONAL_PACKAGES_PREFIX_PATH is added to the
PATHs option, but we don't adjust CMAKE_FIND_ROOT_PATH.
Without adding the new paths in CMAKE_FIND_ROOT_PATH, CMake will
re-root the passed PATHs under the existing CMAKE_FIND_ROOT_PATH,
which is QT_TOOLCHAIN_RELOCATABLE_INSTALL_PREFIX, which evaluates to
/target_qtbase. There is no QtQuick package there.
To fix this, prepend the values of QT_ADDITIONAL_PACKAGES_PREFIX_PATH
to CMAKE_FIND_ROOT_PATH.
The location where we currently do CMAKE_FIND_ROOT_PATH manipulations
is in the qt.toolchain.cmake file, so to be consistent, we prepend the
new prefixes there as well.
We need to adjust both CMAKE_FIND_ROOT_PATH and CMAKE_PREFIX_PATH,
due the path re-rooting bug in CMake.
See https://gitlab.kitware.com/cmake/cmake/-/issues/21937 as well as
the existing comment in qt.toolchain.cmake marked with
REROOT_PATH_ISSUE_MARKER.
We also need to do a few more things to make the setup work
Because Qt6Config uses NO_DEFAULT_PATH, the CMAKE_PREFIX_PATH
adjustments we do in the toolchain file are not enough, so we still need
to add the same prefixes to the Qt6Config find_package PATHS option.
One would ask why do we need to adjust CMAKE_PREFIX_PATH at all then.
It's for find_package(Qt6Foo) calls to work which don't go through
the Qt6Config umbrella package.
To make the CMake re-rooting behavior happy, we need to ensure the
provided paths are absolute.
So we iterate over the values of QT_ADDITIONAL_PACKAGES_PREFIX_PATH,
to make them absolute. We do the same for the environment variable.
We need to append lib/cmake to the prefixes which are added to
CMAKE_PREFIX_PATH, otherwise the CMake re-rooting bug is hit.
We need to specify the Qt6 package location (${_qt_cmake_dir}) to the
PATHS option in the various Dependencies.cmake.in files, to ensure
that dependency resolution can jump around between the Qt6 dir and
the additional prefixes. Previously the dependency lookup code assumed
that all dependencies would be within the same prefix.
The same is needed for qt and qml plugin dependency lookup.
Amends 7bb91398f25cb2016c0558fd397b376f413e3e96
Amends 60c87c68016c6f02b0eddd4002f75a49ab51d4a8
Amends 5bbd700124d13a292ff8bae6045316112500e230
Pick-to: 6.2
Fixes: QTBUG-95854
Change-Id: I35ae82330fec427d0d38fc9a0542ffafff52556a
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2021-08-17 15:03:02 +00:00
|
|
|
endif()
|
2022-01-11 16:44:10 +00:00
|
|
|
list(APPEND additional_packages_prefix_paths "${additional_path}")
|
CMake: Fix QT_ADDITIONAL_PACKAGES_PREFIX_PATH for cross-builds
The QT_ADDITIONAL_PACKAGES_PREFIX_PATH variable was introduced to
allow specifying extra locations to find Qt packages.
The reason it was introduced instead of just using CMAKE_PREFIX_PATH
is because the Qt6 component find_package call uses NO_DEFAULT_PATH
which means CMAKE_PREFIX_PATH is ignored.
We use NO_DEFAULT_PATH to ensure we don't accidentally pick up
system / distro Qt packages.
The paths from QT_ADDITIONAL_PACKAGES_PREFIX_PATH are added to the
find_package PATHS option in the Qt6 package, each
ModuleDependencies.cmake file and some other places.
Unfortunately that's not enough to make it work for cross-builds.
Imagine the following scenario.
host qtbase, qtdeclarative installed in /host_qt
target qtbase installed in /target_qtbase
target qtdeclarative installed in /target_qtdeclarative
We want to cross-build qtlottie.
We configure qtlottie as follows
/target_qtbase/bin/qt-configure-module /qtlottie_src -- -DQT_ADDITIONAL_PACKAGES_PREFIX_PATH=/target_qtdeclarative
We expect the target QtQuick package to be found, but it won't be.
The reason is that QT_ADDITIONAL_PACKAGES_PREFIX_PATH is added to the
PATHs option, but we don't adjust CMAKE_FIND_ROOT_PATH.
Without adding the new paths in CMAKE_FIND_ROOT_PATH, CMake will
re-root the passed PATHs under the existing CMAKE_FIND_ROOT_PATH,
which is QT_TOOLCHAIN_RELOCATABLE_INSTALL_PREFIX, which evaluates to
/target_qtbase. There is no QtQuick package there.
To fix this, prepend the values of QT_ADDITIONAL_PACKAGES_PREFIX_PATH
to CMAKE_FIND_ROOT_PATH.
The location where we currently do CMAKE_FIND_ROOT_PATH manipulations
is in the qt.toolchain.cmake file, so to be consistent, we prepend the
new prefixes there as well.
We need to adjust both CMAKE_FIND_ROOT_PATH and CMAKE_PREFIX_PATH,
due the path re-rooting bug in CMake.
See https://gitlab.kitware.com/cmake/cmake/-/issues/21937 as well as
the existing comment in qt.toolchain.cmake marked with
REROOT_PATH_ISSUE_MARKER.
We also need to do a few more things to make the setup work
Because Qt6Config uses NO_DEFAULT_PATH, the CMAKE_PREFIX_PATH
adjustments we do in the toolchain file are not enough, so we still need
to add the same prefixes to the Qt6Config find_package PATHS option.
One would ask why do we need to adjust CMAKE_PREFIX_PATH at all then.
It's for find_package(Qt6Foo) calls to work which don't go through
the Qt6Config umbrella package.
To make the CMake re-rooting behavior happy, we need to ensure the
provided paths are absolute.
So we iterate over the values of QT_ADDITIONAL_PACKAGES_PREFIX_PATH,
to make them absolute. We do the same for the environment variable.
We need to append lib/cmake to the prefixes which are added to
CMAKE_PREFIX_PATH, otherwise the CMake re-rooting bug is hit.
We need to specify the Qt6 package location (${_qt_cmake_dir}) to the
PATHS option in the various Dependencies.cmake.in files, to ensure
that dependency resolution can jump around between the Qt6 dir and
the additional prefixes. Previously the dependency lookup code assumed
that all dependencies would be within the same prefix.
The same is needed for qt and qml plugin dependency lookup.
Amends 7bb91398f25cb2016c0558fd397b376f413e3e96
Amends 60c87c68016c6f02b0eddd4002f75a49ab51d4a8
Amends 5bbd700124d13a292ff8bae6045316112500e230
Pick-to: 6.2
Fixes: QTBUG-95854
Change-Id: I35ae82330fec427d0d38fc9a0542ffafff52556a
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2021-08-17 15:03:02 +00:00
|
|
|
endforeach()
|
2022-01-11 16:44:10 +00:00
|
|
|
|
|
|
|
set("${out_var}" "${additional_packages_prefix_paths}" PARENT_SCOPE)
|
|
|
|
endfunction()
|
|
|
|
|
|
|
|
__qt_internal_collect_additional_prefix_paths(_qt_additional_packages_prefix_paths
|
|
|
|
QT_ADDITIONAL_PACKAGES_PREFIX_PATH)
|
|
|
|
__qt_internal_collect_additional_prefix_paths(_qt_additional_host_packages_prefix_paths
|
|
|
|
QT_ADDITIONAL_HOST_PACKAGES_PREFIX_PATH)
|
|
|
|
|
|
|
|
# Take a list of prefix paths ending with "/lib/cmake", and return a list of absolute paths with
|
|
|
|
# "/lib/cmake" removed.
|
|
|
|
function(__qt_internal_prefix_paths_to_roots out_var prefix_paths)
|
|
|
|
set(result "")
|
|
|
|
foreach(path IN LISTS prefix_paths)
|
|
|
|
if(path MATCHES "/lib/cmake$")
|
|
|
|
string(APPEND path "/../..")
|
|
|
|
endif()
|
|
|
|
get_filename_component(path "${path}" ABSOLUTE)
|
|
|
|
list(APPEND result "${path}")
|
|
|
|
endforeach()
|
|
|
|
set("${out_var}" "${result}" PARENT_SCOPE)
|
|
|
|
endfunction()
|
|
|
|
|
|
|
|
__qt_internal_prefix_paths_to_roots(_qt_additional_host_packages_root_paths
|
|
|
|
"${_qt_additional_host_packages_prefix_paths}")
|
2021-02-24 15:07:37 +00:00
|
|
|
|
2021-04-28 13:25:18 +00:00
|
|
|
# Public helpers available to all Qt packages.
|
|
|
|
include("${CMAKE_CURRENT_LIST_DIR}/QtFeature.cmake")
|
2021-05-19 17:46:24 +00:00
|
|
|
include("${CMAKE_CURRENT_LIST_DIR}/QtPublicFinalizerHelpers.cmake")
|
2021-04-28 13:25:18 +00:00
|
|
|
include("${CMAKE_CURRENT_LIST_DIR}/QtPublicPluginHelpers.cmake")
|
2021-04-29 10:47:52 +00:00
|
|
|
include("${CMAKE_CURRENT_LIST_DIR}/QtPublicTargetHelpers.cmake")
|
|
|
|
include("${CMAKE_CURRENT_LIST_DIR}/QtPublicWalkLibsHelpers.cmake")
|
2021-06-14 14:24:57 +00:00
|
|
|
include("${CMAKE_CURRENT_LIST_DIR}/QtPublicFindPackageHelpers.cmake")
|
2021-06-17 14:18:59 +00:00
|
|
|
include("${CMAKE_CURRENT_LIST_DIR}/QtPublicDependencyHelpers.cmake")
|
2022-01-27 15:28:47 +00:00
|
|
|
include("${CMAKE_CURRENT_LIST_DIR}/QtPublicToolHelpers.cmake")
|
2021-12-29 17:00:52 +00:00
|
|
|
include("${CMAKE_CURRENT_LIST_DIR}/QtPublicCMakeHelpers.cmake")
|
2021-04-28 13:25:18 +00:00
|
|
|
|
2021-06-10 17:01:35 +00:00
|
|
|
if(NOT DEFINED QT_CMAKE_EXPORT_NAMESPACE)
|
|
|
|
set(QT_CMAKE_EXPORT_NAMESPACE @QT_CMAKE_EXPORT_NAMESPACE@)
|
|
|
|
endif()
|
|
|
|
|
2021-06-24 10:30:32 +00:00
|
|
|
# Propagate sanitizer flags to both internal Qt builds and user projects.
|
|
|
|
# Allow opt-out in case if downstream projects handle it in a different way.
|
|
|
|
set(QT_CONFIGURED_SANITIZER_OPTIONS "@ECM_ENABLE_SANITIZERS@")
|
|
|
|
|
|
|
|
if(QT_CONFIGURED_SANITIZER_OPTIONS
|
|
|
|
AND NOT __qt_sanitizer_options_set
|
|
|
|
AND NOT QT_NO_ADD_SANITIZER_OPTIONS)
|
|
|
|
set(ECM_ENABLE_SANITIZERS "${QT_CONFIGURED_SANITIZER_OPTIONS}")
|
|
|
|
include(
|
|
|
|
"${CMAKE_CURRENT_LIST_DIR}/3rdparty/extra-cmake-modules/modules/ECMEnableSanitizers.cmake")
|
|
|
|
endif()
|
|
|
|
# Mark that the current directory scope has its sanitizer flags set.
|
|
|
|
set(__qt_sanitizer_options_set TRUE)
|
|
|
|
|
2020-08-03 14:28:16 +00:00
|
|
|
# Find required dependencies, if any.
|
|
|
|
include(CMakeFindDependencyMacro)
|
|
|
|
if(EXISTS "${CMAKE_CURRENT_LIST_DIR}/@INSTALL_CMAKE_NAMESPACE@Dependencies.cmake")
|
|
|
|
include("${CMAKE_CURRENT_LIST_DIR}/@INSTALL_CMAKE_NAMESPACE@Dependencies.cmake")
|
2022-07-14 13:28:12 +00:00
|
|
|
|
2022-07-14 15:00:56 +00:00
|
|
|
_qt_internal_suggest_dependency_debugging(@INSTALL_CMAKE_NAMESPACE@
|
2022-07-14 13:28:12 +00:00
|
|
|
__qt_@INSTALL_CMAKE_NAMESPACE@_pkg ${CMAKE_FIND_PACKAGE_NAME}_NOT_FOUND_MESSAGE)
|
|
|
|
|
2022-07-13 15:44:55 +00:00
|
|
|
if(NOT @INSTALL_CMAKE_NAMESPACE@_FOUND)
|
|
|
|
# Clear the components, no need to look for them if dependencies were not found, otherwise
|
|
|
|
# you get a wall of recursive error messages.
|
|
|
|
set(@INSTALL_CMAKE_NAMESPACE@_FIND_COMPONENTS "")
|
2020-09-14 07:06:58 +00:00
|
|
|
endif()
|
2020-08-03 14:28:16 +00:00
|
|
|
endif()
|
|
|
|
|
2021-08-04 10:23:14 +00:00
|
|
|
set(_@INSTALL_CMAKE_NAMESPACE@_FIND_PARTS_QUIET)
|
|
|
|
if(@INSTALL_CMAKE_NAMESPACE@_FIND_QUIETLY)
|
|
|
|
set(_@INSTALL_CMAKE_NAMESPACE@_FIND_PARTS_QUIET QUIET)
|
|
|
|
endif()
|
|
|
|
|
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()
|
|
|
|
|
2019-02-11 10:34:35 +00:00
|
|
|
foreach(module ${@INSTALL_CMAKE_NAMESPACE@_FIND_COMPONENTS})
|
2021-08-04 15:36:22 +00:00
|
|
|
if(NOT "${QT_HOST_PATH}" STREQUAL ""
|
|
|
|
AND "${module}" MATCHES "Tools$"
|
2022-01-26 13:33:31 +00:00
|
|
|
AND NOT "${module}" MATCHES "UiTools$"
|
2021-08-04 15:36:22 +00:00
|
|
|
AND NOT "${module}" MATCHES "ShaderTools$"
|
|
|
|
AND NOT "${module}" MATCHES "^Tools$"
|
|
|
|
AND NOT QT_NO_FIND_HOST_TOOLS_PATH_MANIPULATION)
|
|
|
|
# Make sure that a Qt*Tools package is also looked up in QT_HOST_PATH.
|
|
|
|
# But don't match QtShaderTools and QtTools which are cross-compiled target package names.
|
|
|
|
# Allow opt out just in case.
|
2021-10-20 15:52:00 +00:00
|
|
|
get_filename_component(__qt_find_package_host_qt_path
|
|
|
|
"${Qt@PROJECT_VERSION_MAJOR@HostInfo_DIR}/.." ABSOLUTE)
|
2021-08-04 15:36:22 +00:00
|
|
|
set(__qt_backup_cmake_prefix_path "${CMAKE_PREFIX_PATH}")
|
|
|
|
set(__qt_backup_cmake_find_root_path "${CMAKE_FIND_ROOT_PATH}")
|
2022-01-11 16:44:10 +00:00
|
|
|
list(PREPEND CMAKE_PREFIX_PATH "${__qt_find_package_host_qt_path}"
|
|
|
|
${_qt_additional_host_packages_prefix_paths})
|
|
|
|
list(PREPEND CMAKE_FIND_ROOT_PATH "${QT_HOST_PATH}"
|
|
|
|
${_qt_additional_host_packages_root_paths})
|
2021-08-04 15:36:22 +00:00
|
|
|
endif()
|
|
|
|
|
2022-07-14 15:00:56 +00:00
|
|
|
_qt_internal_save_find_package_context_for_debugging(@INSTALL_CMAKE_NAMESPACE@${module})
|
|
|
|
|
2019-02-11 10:34:35 +00:00
|
|
|
find_package(@INSTALL_CMAKE_NAMESPACE@${module}
|
2021-08-18 16:41:18 +00:00
|
|
|
${@INSTALL_CMAKE_NAMESPACE@_FIND_VERSION}
|
2019-02-11 10:34:35 +00:00
|
|
|
${_@INSTALL_CMAKE_NAMESPACE@_FIND_PARTS_QUIET}
|
2020-09-25 18:02:56 +00:00
|
|
|
PATHS
|
|
|
|
${_qt_cmake_dir}
|
CMake: Fix QT_ADDITIONAL_PACKAGES_PREFIX_PATH for cross-builds
The QT_ADDITIONAL_PACKAGES_PREFIX_PATH variable was introduced to
allow specifying extra locations to find Qt packages.
The reason it was introduced instead of just using CMAKE_PREFIX_PATH
is because the Qt6 component find_package call uses NO_DEFAULT_PATH
which means CMAKE_PREFIX_PATH is ignored.
We use NO_DEFAULT_PATH to ensure we don't accidentally pick up
system / distro Qt packages.
The paths from QT_ADDITIONAL_PACKAGES_PREFIX_PATH are added to the
find_package PATHS option in the Qt6 package, each
ModuleDependencies.cmake file and some other places.
Unfortunately that's not enough to make it work for cross-builds.
Imagine the following scenario.
host qtbase, qtdeclarative installed in /host_qt
target qtbase installed in /target_qtbase
target qtdeclarative installed in /target_qtdeclarative
We want to cross-build qtlottie.
We configure qtlottie as follows
/target_qtbase/bin/qt-configure-module /qtlottie_src -- -DQT_ADDITIONAL_PACKAGES_PREFIX_PATH=/target_qtdeclarative
We expect the target QtQuick package to be found, but it won't be.
The reason is that QT_ADDITIONAL_PACKAGES_PREFIX_PATH is added to the
PATHs option, but we don't adjust CMAKE_FIND_ROOT_PATH.
Without adding the new paths in CMAKE_FIND_ROOT_PATH, CMake will
re-root the passed PATHs under the existing CMAKE_FIND_ROOT_PATH,
which is QT_TOOLCHAIN_RELOCATABLE_INSTALL_PREFIX, which evaluates to
/target_qtbase. There is no QtQuick package there.
To fix this, prepend the values of QT_ADDITIONAL_PACKAGES_PREFIX_PATH
to CMAKE_FIND_ROOT_PATH.
The location where we currently do CMAKE_FIND_ROOT_PATH manipulations
is in the qt.toolchain.cmake file, so to be consistent, we prepend the
new prefixes there as well.
We need to adjust both CMAKE_FIND_ROOT_PATH and CMAKE_PREFIX_PATH,
due the path re-rooting bug in CMake.
See https://gitlab.kitware.com/cmake/cmake/-/issues/21937 as well as
the existing comment in qt.toolchain.cmake marked with
REROOT_PATH_ISSUE_MARKER.
We also need to do a few more things to make the setup work
Because Qt6Config uses NO_DEFAULT_PATH, the CMAKE_PREFIX_PATH
adjustments we do in the toolchain file are not enough, so we still need
to add the same prefixes to the Qt6Config find_package PATHS option.
One would ask why do we need to adjust CMAKE_PREFIX_PATH at all then.
It's for find_package(Qt6Foo) calls to work which don't go through
the Qt6Config umbrella package.
To make the CMake re-rooting behavior happy, we need to ensure the
provided paths are absolute.
So we iterate over the values of QT_ADDITIONAL_PACKAGES_PREFIX_PATH,
to make them absolute. We do the same for the environment variable.
We need to append lib/cmake to the prefixes which are added to
CMAKE_PREFIX_PATH, otherwise the CMake re-rooting bug is hit.
We need to specify the Qt6 package location (${_qt_cmake_dir}) to the
PATHS option in the various Dependencies.cmake.in files, to ensure
that dependency resolution can jump around between the Qt6 dir and
the additional prefixes. Previously the dependency lookup code assumed
that all dependencies would be within the same prefix.
The same is needed for qt and qml plugin dependency lookup.
Amends 7bb91398f25cb2016c0558fd397b376f413e3e96
Amends 60c87c68016c6f02b0eddd4002f75a49ab51d4a8
Amends 5bbd700124d13a292ff8bae6045316112500e230
Pick-to: 6.2
Fixes: QTBUG-95854
Change-Id: I35ae82330fec427d0d38fc9a0542ffafff52556a
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2021-08-17 15:03:02 +00:00
|
|
|
${_qt_additional_packages_prefix_paths}
|
2020-09-25 18:02:56 +00:00
|
|
|
${QT_EXAMPLES_CMAKE_PREFIX_PATH}
|
2021-08-04 15:36:22 +00:00
|
|
|
${__qt_find_package_host_qt_path}
|
2022-01-11 16:44:10 +00:00
|
|
|
${_qt_additional_host_packages_prefix_paths}
|
2020-09-25 18:02:56 +00:00
|
|
|
${__qt_use_no_default_path_for_qt_packages}
|
2018-10-24 13:20:27 +00:00
|
|
|
)
|
2021-08-04 15:36:22 +00:00
|
|
|
|
|
|
|
if(NOT "${__qt_find_package_host_qt_path}" STREQUAL "")
|
|
|
|
set(CMAKE_PREFIX_PATH "${__qt_backup_cmake_prefix_path}")
|
|
|
|
set(CMAKE_FIND_ROOT_PATH "${__qt_backup_cmake_find_root_path}")
|
|
|
|
unset(__qt_backup_cmake_prefix_path)
|
|
|
|
unset(__qt_backup_cmake_find_root_path)
|
|
|
|
unset(__qt_find_package_host_qt_path)
|
|
|
|
endif()
|
|
|
|
|
2019-02-11 10:34:35 +00:00
|
|
|
if (NOT @INSTALL_CMAKE_NAMESPACE@${module}_FOUND)
|
2021-08-02 14:02:04 +00:00
|
|
|
set(_qt_expected_component_config_path
|
|
|
|
"${_qt_cmake_dir}/@INSTALL_CMAKE_NAMESPACE@${module}/@INSTALL_CMAKE_NAMESPACE@${module}Config.cmake")
|
|
|
|
get_filename_component(
|
|
|
|
_qt_expected_component_dir_path "${_qt_expected_component_config_path}" DIRECTORY)
|
|
|
|
|
|
|
|
set(_qt_component_not_found_msg
|
|
|
|
"\nExpected Config file at \"${_qt_expected_component_config_path}\"")
|
|
|
|
|
|
|
|
if(EXISTS "${_qt_expected_component_config_path}")
|
|
|
|
string(APPEND _qt_component_not_found_msg " exists \n")
|
|
|
|
else()
|
|
|
|
string(APPEND _qt_component_not_found_msg " does NOT exist\n")
|
|
|
|
endif()
|
|
|
|
|
|
|
|
set(_qt_candidate_component_dir_path "${@INSTALL_CMAKE_NAMESPACE@${module}_DIR}")
|
|
|
|
|
|
|
|
if(_qt_candidate_component_dir_path AND
|
|
|
|
NOT _qt_expected_component_dir_path STREQUAL _qt_candidate_component_dir_path)
|
|
|
|
string(APPEND _qt_component_not_found_msg
|
|
|
|
"\n@INSTALL_CMAKE_NAMESPACE@${module}_DIR was computed by CMake or specified on the "
|
|
|
|
"command line by the user: \"${_qt_candidate_component_dir_path}\" "
|
|
|
|
"\nThe expected and computed paths are different, which might be the reason for "
|
|
|
|
"the package not to be found.")
|
|
|
|
endif()
|
2018-10-24 13:20:27 +00:00
|
|
|
|
2021-08-02 14:02:04 +00:00
|
|
|
if(@INSTALL_CMAKE_NAMESPACE@_FIND_REQUIRED_${module})
|
2022-07-14 13:28:12 +00:00
|
|
|
set(@INSTALL_CMAKE_NAMESPACE@_FOUND False)
|
2021-08-02 14:02:04 +00:00
|
|
|
set(_Qt_NOTFOUND_MESSAGE
|
2022-07-13 17:24:52 +00:00
|
|
|
"${_Qt_NOTFOUND_MESSAGE}Failed to find required Qt component \"${module}\". ${_qt_component_not_found_msg}")
|
2022-07-14 13:28:12 +00:00
|
|
|
set(_qt_full_component_name "@INSTALL_CMAKE_NAMESPACE@${module}")
|
2022-07-14 15:00:56 +00:00
|
|
|
_qt_internal_suggest_dependency_debugging(${_qt_full_component_name}
|
|
|
|
_qt_full_component_name _Qt_NOTFOUND_MESSAGE)
|
2022-07-14 13:28:12 +00:00
|
|
|
unset(_qt_full_component_name)
|
2022-07-13 16:11:54 +00:00
|
|
|
break()
|
2019-06-03 18:47:37 +00:00
|
|
|
elseif(NOT @INSTALL_CMAKE_NAMESPACE@_FIND_QUIETLY)
|
2021-08-02 14:02:04 +00:00
|
|
|
message(WARNING
|
2022-07-13 17:24:52 +00:00
|
|
|
"Failed to find optional Qt component \"${module}\". ${_qt_component_not_found_msg}")
|
2018-10-24 13:20:27 +00:00
|
|
|
endif()
|
|
|
|
|
2021-08-02 14:02:04 +00:00
|
|
|
unset(_qt_expected_component_config_path)
|
|
|
|
unset(_qt_expected_component_dir_path)
|
|
|
|
unset(_qt_candidate_component_dir_path)
|
|
|
|
unset(_qt_component_not_found_msg)
|
2018-10-24 13:20:27 +00:00
|
|
|
endif()
|
|
|
|
endforeach()
|
|
|
|
|
2021-08-02 14:02:04 +00:00
|
|
|
if(@INSTALL_CMAKE_NAMESPACE@_FIND_COMPONENTS AND _Qt_NOTFOUND_MESSAGE)
|
2019-02-11 10:34:35 +00:00
|
|
|
set(@INSTALL_CMAKE_NAMESPACE@_NOT_FOUND_MESSAGE "${_Qt_NOTFOUND_MESSAGE}")
|
2021-08-02 14:02:04 +00:00
|
|
|
unset(_Qt_NOTFOUND_MESSAGE)
|
2018-10-24 13:20:27 +00:00
|
|
|
endif()
|
2021-06-11 07:54:47 +00:00
|
|
|
|
|
|
|
__qt_internal_defer_promote_targets_in_dir_scope_to_global()
|
2021-06-29 16:00:39 +00:00
|
|
|
if(CMAKE_VERSION VERSION_LESS 3.21)
|
|
|
|
__qt_internal_check_link_order_matters()
|
|
|
|
__qt_internal_check_cmp0099_available()
|
|
|
|
endif()
|