2020-11-04 13:39:52 +00:00
|
|
|
set(__qt_toolchain_used_variables
|
|
|
|
QT_CHAINLOAD_TOOLCHAIN_FILE
|
|
|
|
QT_TOOLCHAIN_INCLUDE_FILE
|
|
|
|
QT_TOOLCHAIN_RELOCATABLE_CMAKE_DIR
|
|
|
|
QT_TOOLCHAIN_RELOCATABLE_PREFIX)
|
|
|
|
@init_additional_used_variables@
|
|
|
|
|
|
|
|
# Make cache variables used by this toolchain file available to the
|
|
|
|
# try_compile command that operates on sources files.
|
|
|
|
list(APPEND CMAKE_TRY_COMPILE_PLATFORM_VARIABLES ${__qt_toolchain_used_variables})
|
|
|
|
list(REMOVE_DUPLICATES CMAKE_TRY_COMPILE_PLATFORM_VARIABLES)
|
|
|
|
|
|
|
|
# Turn the environment variables that are created at the end of this
|
|
|
|
# file into proper variables. This is needed for try_compile calls
|
|
|
|
# that operate on whole projects.
|
|
|
|
if($ENV{_QT_TOOLCHAIN_VARS_INITIALIZED})
|
|
|
|
foreach(var ${__qt_toolchain_used_variables})
|
|
|
|
set(${var} "$ENV{_QT_TOOLCHAIN_${var}}")
|
|
|
|
endforeach()
|
|
|
|
endif()
|
|
|
|
|
2019-06-21 12:58:52 +00:00
|
|
|
@init_qt_host_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
|
|
|
@init_qt_host_path_cmake_dir@
|
2019-06-21 12:58:52 +00:00
|
|
|
@init_original_toolchain_file@
|
|
|
|
@init_vcpkg@
|
2020-10-26 19:50:36 +00:00
|
|
|
|
|
|
|
@init_platform@
|
|
|
|
|
2020-10-06 13:23:05 +00:00
|
|
|
if(NOT "${QT_CHAINLOAD_TOOLCHAIN_FILE}" STREQUAL "")
|
|
|
|
set(__qt_chainload_toolchain_file "${QT_CHAINLOAD_TOOLCHAIN_FILE}")
|
|
|
|
endif()
|
2020-06-02 16:06:37 +00:00
|
|
|
if(__qt_chainload_toolchain_file)
|
|
|
|
get_filename_component(__qt_chainload_toolchain_file_real_path
|
|
|
|
"${__qt_chainload_toolchain_file}" REALPATH)
|
|
|
|
if(__qt_chainload_toolchain_file_real_path STREQUAL CMAKE_CURRENT_LIST_FILE)
|
|
|
|
message(FATAL_ERROR
|
|
|
|
"Woah, the Qt toolchain file tried to include itself recusively! '${__qt_chainload_toolchain_file}' "
|
|
|
|
"Make sure to remove qtbase/CMakeCache.txt and reconfigure qtbase with 'cmake' "
|
|
|
|
"rather than 'qt-cmake', and then you can reconfigure your own project."
|
|
|
|
)
|
2020-10-07 08:31:40 +00:00
|
|
|
elseif(NOT EXISTS "${__qt_chainload_toolchain_file_real_path}")
|
|
|
|
message(WARNING "The toolchain file to be chainloaded "
|
|
|
|
"'${__qt_chainload_toolchain_file}' does not exist.")
|
2020-06-02 16:06:37 +00:00
|
|
|
else()
|
|
|
|
include("${__qt_chainload_toolchain_file}")
|
2021-09-27 10:27:23 +00:00
|
|
|
set(__qt_chainload_toolchain_file_included TRUE)
|
2020-06-02 16:06:37 +00:00
|
|
|
endif()
|
|
|
|
unset(__qt_chainload_toolchain_file)
|
2019-06-21 12:58:52 +00:00
|
|
|
endif()
|
|
|
|
|
2021-09-27 10:27:23 +00:00
|
|
|
@init_post_chainload_toolchain@
|
|
|
|
|
CMake: Make build system of installed Qt more relocatable
Aka handle CMAKE_INSTALL_PREFIX in a more relocatable way.
The following story inspired this change.
If a user wants to build a Qt repo into a different install prefix
than the usual Qt one, this will fail configuration because we
look for various things like syncqt, qdoc, etc relative to
CMAKE_INSTALL_PREFIX, which will now point to a different location
where none of the above tools are located.
The intent for such a use case is to support building Qt packages with
Conan, which sets a random install prefix when configuring a repo.
The idea is to derive the qt prefix dynamically from the
QtBuildInternals package location. Essentially it's a reverse relative
path from the QtBuildInternalsConfig.cmake file to the install prefix
that was specified when initially configuring qtbase.
Once the dynamic prefix is computed (so we know where the possibly
relocated Qt is), we can find tools like syncqt and qdoc.
This is an initial attempt to support a use case like that.
More design work will probably needed in case if tools / libs need to
be found in a location different than the Qt install prefix (so
support for multiple install prefixes / search paths).
An example of such a case would be when building qtdeclarative and
qtquickcontrols2 as Conan packages in one go. Most likely the
qmltyperegistrar tool will be located in the random install prefix
set by Conan, so building qtquickcontrols2 might fail due to not
finding the tool in the original Qt install prefix.
As to the implementation details, the change does the following:
- Dynamically computes and sets the
QT_BUILD_INTERNALS_RELOCATABLE_INSTALL_PREFIX variable when
find_package()'ing QtBuildInternals. It's an absolute path
pointing to where the relocated Qt is.
- When building qtbase this variable is not yet available (due
to QtBuildInternalsExtra not existing), in that case we set
the variable to the absolute path of CMAKE_INSTALL_PREFIX
(but only for the initial qtbase configuration).
- Remove QT_BUILD_INTERNALS_ORIGINAL_INSTALL_PREFIX which was used
for standalone tests purposes. It's not needed now that we compute
the location of the Qt prefix dynamically.
- The Unixy qt-cmake and qt-cmake-private shell scripts now
use a relative path to find the toolchain file we created.
- The toolchain file also dynamically computes the location of the Qt
packages, and adds them to CMAKE_PREFIX_PATH.
- A lot of existing CMAKE_INSTALL_PREFIX uses are replaced with
QT_BUILD_INTERNALS_RELOCATABLE_INSTALL_PREFIX. This includes finding
tool locations, mkspecs dir, path environment setup for tools, etc.
- Some places still use CMAKE_PREFIX_PATH in the following cases
- When determining paths while configuring qtbase (valid cases)
- When I wasn't sure what the behavior should be, so I left them
as-is (an example is documentation generation, do we want to
install it into the random Conan prefix, or into the main prefix?
Currently it installs in the random prefix).
Note that relocating a Qt installation does not work for non-prefix /
non-installed builds, due to hardcoded paths to include directories
and libraries in generated FooTargets.cmake files.
Task-number: QTBUG-83999
Change-Id: I87d6558729db93121b1715771034b03ce3295923
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2020-05-05 08:30:35 +00:00
|
|
|
# Compute dynamically the Qt installation prefix from the location of this file. This allows
|
|
|
|
# the usage of the toolchain file when the Qt installation is relocated.
|
|
|
|
get_filename_component(QT_TOOLCHAIN_RELOCATABLE_INSTALL_PREFIX
|
|
|
|
${CMAKE_CURRENT_LIST_DIR}/../@qt_path_from_cmake_config_dir_to_prefix@
|
|
|
|
ABSOLUTE)
|
|
|
|
|
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
|
|
|
# Compute the path to the installed Qt lib/cmake folder.
|
|
|
|
# We assume that the Qt toolchain location is inside the CMake Qt6 package, and thus the directory
|
|
|
|
# one level higher is what we're looking for.
|
|
|
|
get_filename_component(QT_TOOLCHAIN_RELOCATABLE_CMAKE_DIR "${CMAKE_CURRENT_LIST_DIR}/.." ABSOLUTE)
|
|
|
|
|
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
|
|
|
# REROOT_PATH_ISSUE_MARKER
|
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
|
|
|
# There's a subdirectory check in cmake's cmFindCommon::RerootPaths() function, that doesn't handle
|
|
|
|
# the case of CMAKE_PREFIX_PATH == CMAKE_FIND_ROOT_PATH for a particular pair of entries.
|
|
|
|
# Instead of collapsing the search prefix (which is the case when one is a subdir of the other),
|
|
|
|
# it concatenates them creating an invalid path. Workaround it by setting the root path to the
|
|
|
|
# Qt install prefix, and the prefix path to the lib/cmake subdir.
|
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
|
|
|
list(PREPEND CMAKE_PREFIX_PATH "${QT_TOOLCHAIN_RELOCATABLE_CMAKE_DIR}")
|
|
|
|
list(PREPEND CMAKE_FIND_ROOT_PATH "${QT_TOOLCHAIN_RELOCATABLE_INSTALL_PREFIX}")
|
|
|
|
|
|
|
|
# Handle packages located in QT_ADDITIONAL_PACKAGES_PREFIX_PATH when cross-compiling. Needed for
|
|
|
|
# Conan.
|
|
|
|
# We prepend to CMAKE_PREFIX_PATH so that a find_package(Qt6Foo) call works, without having to go
|
|
|
|
# through the Qt6 umbrella package. The paths must end in lib/cmake to esnsure the package is found.
|
|
|
|
# See REROOT_PATH_ISSUE_MARKER.
|
|
|
|
# We prepend to CMAKE_FIND_ROOT_PATH, due to the bug mentioned at REROOT_PATH_ISSUE_MARKER.
|
|
|
|
set(__qt_toolchain_additional_packages_prefixes "")
|
|
|
|
if(QT_ADDITIONAL_PACKAGES_PREFIX_PATH)
|
|
|
|
list(APPEND __qt_toolchain_additional_packages_prefixes
|
|
|
|
${QT_ADDITIONAL_PACKAGES_PREFIX_PATH})
|
|
|
|
endif()
|
|
|
|
if(DEFINED ENV{QT_ADDITIONAL_PACKAGES_PREFIX_PATH}
|
|
|
|
AND NOT "$ENV{QT_ADDITIONAL_PACKAGES_PREFIX_PATH}" STREQUAL "")
|
|
|
|
list(APPEND __qt_toolchain_additional_packages_prefixes
|
|
|
|
$ENV{QT_ADDITIONAL_PACKAGES_PREFIX_PATH})
|
|
|
|
endif()
|
|
|
|
|
|
|
|
if(__qt_toolchain_additional_packages_prefixes)
|
|
|
|
set(__qt_toolchain_additional_packages_root_paths "")
|
|
|
|
set(__qt_toolchain_additional_packages_prefix_paths "")
|
|
|
|
|
|
|
|
foreach(__qt_additional_path IN LISTS __qt_toolchain_additional_packages_prefixes)
|
|
|
|
file(TO_CMAKE_PATH "${__qt_additional_path}" __qt_additional_path)
|
|
|
|
get_filename_component(__qt_additional_path "${__qt_additional_path}" ABSOLUTE)
|
|
|
|
set(__qt_additional_path_lib_cmake "${__qt_additional_path}")
|
|
|
|
if(NOT __qt_additional_path_lib_cmake MATCHES "/lib/cmake$")
|
|
|
|
string(APPEND __qt_additional_path_lib_cmake "/lib/cmake")
|
|
|
|
endif()
|
|
|
|
|
|
|
|
list(APPEND __qt_toolchain_additional_packages_root_paths
|
|
|
|
"${__qt_additional_path}")
|
|
|
|
list(APPEND __qt_toolchain_additional_packages_prefix_paths
|
|
|
|
"${__qt_additional_path_lib_cmake}")
|
|
|
|
endforeach()
|
|
|
|
list(PREPEND CMAKE_PREFIX_PATH ${__qt_toolchain_additional_packages_prefix_paths})
|
|
|
|
list(PREPEND CMAKE_FIND_ROOT_PATH ${__qt_toolchain_additional_packages_root_paths})
|
|
|
|
|
|
|
|
unset(__qt_additional_path)
|
|
|
|
unset(__qt_additional_path_lib_cmake)
|
|
|
|
unset(__qt_toolchain_additional_packages_root_paths)
|
|
|
|
unset(__qt_toolchain_additional_packages_prefix_paths)
|
|
|
|
endif()
|
|
|
|
unset(__qt_toolchain_additional_packages_prefixes)
|
2021-05-05 14:01:15 +00:00
|
|
|
|
2020-09-15 11:00:22 +00:00
|
|
|
@init_qt_host_path_checks@
|
2020-10-12 09:29:43 +00:00
|
|
|
|
|
|
|
# Allow customization of the toolchain file by placing an additional file next to it.
|
|
|
|
set(__qt_toolchain_extra_file "${CMAKE_CURRENT_LIST_DIR}/qt.toolchain.extra.cmake")
|
|
|
|
if(EXISTS "${__qt_toolchain_extra_file}")
|
|
|
|
include("${__qt_toolchain_extra_file}")
|
|
|
|
endif()
|
|
|
|
|
|
|
|
# Allow customization of the toolchain file by passing a path to an additional CMake file to be
|
|
|
|
# included.
|
|
|
|
if(QT_TOOLCHAIN_INCLUDE_FILE)
|
|
|
|
get_filename_component(__qt_toolchain_include_file_real_path
|
|
|
|
"${QT_TOOLCHAIN_INCLUDE_FILE}" REALPATH)
|
|
|
|
if(EXISTS "${__qt_toolchain_include_file_real_path}")
|
|
|
|
include("${__qt_toolchain_include_file_real_path}")
|
|
|
|
else()
|
|
|
|
message(WARNING "The passed extra toolchain file to be included does not exist: "
|
|
|
|
"${__qt_toolchain_include_file_real_path}")
|
|
|
|
endif()
|
|
|
|
endif()
|
2020-11-04 13:39:52 +00:00
|
|
|
|
|
|
|
# Compile tests only see a restricted set of variables.
|
|
|
|
# All cache variables, this toolchain file uses, must be made available to compile tests,
|
|
|
|
# because this toolchain file will be included there too.
|
|
|
|
if(NOT ENV{_QT_TOOLCHAIN_VARS_INITIALIZED})
|
|
|
|
set(ENV{_QT_TOOLCHAIN_VARS_INITIALIZED} ON)
|
|
|
|
foreach(var ${__qt_toolchain_used_variables})
|
|
|
|
set(ENV{_QT_TOOLCHAIN_${var}} "${${var}}")
|
|
|
|
endforeach()
|
|
|
|
endif()
|