diff options
author | Joerg Bornemann <joerg.bornemann@qt.io> | 2020-06-30 20:59:07 +0200 |
---|---|---|
committer | Joerg Bornemann <joerg.bornemann@qt.io> | 2020-07-01 17:47:58 +0200 |
commit | 389c772fd4a04933d95904e88470506a44535f92 (patch) | |
tree | 5aecf233c8be752dfee0df4d541657e5b2e88cd6 /cmake/QtBuild.cmake | |
parent | fecfa0a01460a6c37b77f7d23849a53d83045baf (diff) |
CMake: Fix qconfig.cpp for cross-builds
This patch modifies the two preprocessor definitions
QT_CONFIGURE_HOSTBINDIR_TO_HOSTPREFIX_PATH and
QT_CONFIGURE_HOSTBINDIR_TO_EXTPREFIX_PATH which are exclusively used
by qmake (and not QtCore's QLibraryInfo) to determine the ext prefix
and the host prefix.
In the qmake build of Qt, qmake considers the host prefix as "location
where qmake is installed". This is usually the same as the ext prefix
but can be modified by the user at configure time.
In the CMake build, we don't build tools for the host but always for
the target platform. The QT_HOST_PATH is an external prefix we never
install to. That means, the qmake we build is always installed into
the ext prefix (CMAKE_STAGING_PREFIX or CMAKE_INSTALL_PREFIX).
Therefore, we can calculate the path of <ext_prefix>/bin relative to
<ext_prefix> and use this value for both,
QT_CONFIGURE_HOSTBINDIR_TO_HOSTPREFIX_PATH and
QT_CONFIGURE_HOSTBINDIR_TO_EXTPREFIX_PATH.
The "path of <ext_prefix>/bin relative to <ext_prefix>" is equivalent to
just the "path <prefix>/bin relative to <prefix>", meaning we can
safely use <prefix>, which is just CMAKE_INSTALL_PREFIX.
Task-number: QTBUG-84886
Change-Id: Ie1d4628a7049ddfd0d0a56dfe4ee2f2bb4952277
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Diffstat (limited to 'cmake/QtBuild.cmake')
-rw-r--r-- | cmake/QtBuild.cmake | 30 |
1 files changed, 9 insertions, 21 deletions
diff --git a/cmake/QtBuild.cmake b/cmake/QtBuild.cmake index f0adaf9379..c3a9d0135d 100644 --- a/cmake/QtBuild.cmake +++ b/cmake/QtBuild.cmake @@ -5588,28 +5588,16 @@ function(qt_generate_qconfig_cpp) endif() file(RELATIVE_PATH from_lib_location_to_prefix "${lib_location_absolute_path}" "${QT_BUILD_INTERNALS_RELOCATABLE_INSTALL_PREFIX}") - - if(QT_HOST_PATH) - set(host_prefix "${QT_HOST_PATH}") - set(host_bin_dir_absolute_path "${QT_HOST_PATH}/${INSTALL_BINDIR}") - else() - set(host_prefix "${QT_BUILD_INTERNALS_RELOCATABLE_INSTALL_PREFIX}") - set(host_bin_dir_absolute_path - "${QT_BUILD_INTERNALS_RELOCATABLE_INSTALL_PREFIX}/${INSTALL_BINDIR}") - endif() - - file(RELATIVE_PATH from_host_bin_dir_to_host_prefix - "${host_bin_dir_absolute_path}" "${host_prefix}") - - # TODO: Fix this to use the equivalent of extprefix on CMake (CMAKE_STAGING_PREFIX?) - # For now just assume ext prefix is same as regular prefix. - file(RELATIVE_PATH from_host_bin_dir_to_ext_prefix - "${host_bin_dir_absolute_path}" "${QT_BUILD_INTERNALS_RELOCATABLE_INSTALL_PREFIX}") - - set(QT_CONFIGURE_LIBLOCATION_TO_PREFIX_PATH "${from_lib_location_to_prefix}") - set(QT_CONFIGURE_HOSTBINDIR_TO_HOSTPREFIX_PATH "${from_host_bin_dir_to_host_prefix}") - set(QT_CONFIGURE_HOSTBINDIR_TO_EXTPREFIX_PATH "${from_host_bin_dir_to_ext_prefix}") + + # The QT_CONFIGURE_HOSTBINDIR_TO_*PREFIX_PATH defines are exclusively used by qmake to determine + # the prefix from the location of the qmake executable. In our build of qmake host_prefix is + # always the same as ext_prefix, and we can just use CMAKE_INSTALL_PREFIX for the calculation of + # the relative path between <ext_prefix>/bin and <ext_prefix>. + set(bin_dir_absolute_path "${CMAKE_INSTALL_PREFIX}/${INSTALL_BINDIR}") + file(RELATIVE_PATH from_bin_dir_to_prefix "${bin_dir_absolute_path}" "${CMAKE_INSTALL_PREFIX}") + set(QT_CONFIGURE_HOSTBINDIR_TO_HOSTPREFIX_PATH "${from_bin_dir_to_prefix}") + set(QT_CONFIGURE_HOSTBINDIR_TO_EXTPREFIX_PATH "${from_bin_dir_to_prefix}") configure_file(global/qconfig.cpp.in global/qconfig.cpp @ONLY) endfunction() |