diff options
author | Alexandru Croitor <alexandru.croitor@qt.io> | 2020-10-22 17:23:46 +0200 |
---|---|---|
committer | Alexandru Croitor <alexandru.croitor@qt.io> | 2020-10-26 13:46:49 +0100 |
commit | 5fa823491b3f1a3d6f8161639686a0fbc33e6f03 (patch) | |
tree | 49a9255bf2fa3e2cdbb65eadb991009fc7ce2f61 /cmake/QtQmakeHelpers.cmake | |
parent | 2096400d6e8249e49df049f9600073fb2219c97a (diff) |
CMake: Fix automatic sysrootification detection for qmake
The way we detected whether SysrootifyPrefix needs to be set was
incorrect.
We checked if extprefix == prefix => SysrootifyPrefix should be
true. But that was previously always the case for a non-prefix build,
which means it was not possible to build apps (due to qmake expecting
to find include dirs in the sysroot, despite the non-prefix Qt not
being installed anywhere into the sysroot).
Instead we should do what qmake does. Only set SysrootifyPrefix to
true if extprefix was not provided and a sysroot is available.
To make it work for iOS and Android, the sysroot detection code had to
be moved earlier than the SysrootifyPrefix detection.
Task-number: QTBUG-86053
Change-Id: Idcc1260a675fb2ef9ae27fc9dc42a68b30f763b8
Reviewed-by: Cristian Adam <cristian.adam@qt.io>
Diffstat (limited to 'cmake/QtQmakeHelpers.cmake')
-rw-r--r-- | cmake/QtQmakeHelpers.cmake | 26 |
1 files changed, 16 insertions, 10 deletions
diff --git a/cmake/QtQmakeHelpers.cmake b/cmake/QtQmakeHelpers.cmake index a75fc6f13a..dae5af8db9 100644 --- a/cmake/QtQmakeHelpers.cmake +++ b/cmake/QtQmakeHelpers.cmake @@ -112,7 +112,21 @@ function(qt_generate_qmake_wrapper_for_target) file(RELATIVE_PATH ext_prefix_relative_to_host_prefix "${host_prefix}" "${ext_prefix}") set(content "") - if(ext_prefix STREQUAL prefix) + + # On Android CMAKE_SYSROOT is set, but from qmake's point of view it should not be set, because + # then qmake generates incorrect Qt module include flags (among other things). Do the same for + # darwin uikit cross-compilation. + set(sysroot "") + if(CMAKE_SYSROOT AND NOT ANDROID AND NOT UIKIT) + set(sysroot "${CMAKE_SYSROOT}") + endif() + + # Detect if automatic sysrootification should happen. All of the following must be true: + # sysroot is set (CMAKE_SYSRROT) + # prefix is set (CMAKE_INSTALL_PREFIX) + # extprefix is explicitly NOT set (CMAKE_STAGING_PREFIX, not QT_STAGING_PREFIX because that + # always ends up having a value) + if(NOT CMAKE_STAGING_PREFIX AND sysroot) set(sysrootify_prefix true) else() set(sysrootify_prefix false) @@ -130,7 +144,7 @@ HostData=${CMAKE_CURRENT_SOURCE_DIR} # Set $$[QT_HOST_DATA/get] to avoid falling back to the source dir where it isn't explicitly # requested. - # Also make sure to specif the Prefix as well, because it doesn't get inherited from the + # Also make sure to specify the Prefix as well, because it doesn't get inherited from the # [Paths] section. string(APPEND content "[EffectivePaths] HostData=${ext_prefix} @@ -138,14 +152,6 @@ Prefix=${ext_prefix_relative_to_conf_file} ") endif() - # On Android CMAKE_SYSROOT is set, but for Qt's purposes it should not be set, because then - # qmake generates incorrect Qt module include flags (among other things). Do the same for darwin - # cross-compilation. - set(sysroot "") - if(CMAKE_SYSROOT AND NOT ANDROID AND NOT UIKIT) - set(sysroot "${CMAKE_SYSROOT}") - endif() - string(APPEND content "[Paths] Prefix=${ext_prefix_relative_to_conf_file} |