From 815f31799c996890ce0e1b7371394fb79e3dfd7c Mon Sep 17 00:00:00 2001 From: Alexandru Croitor Date: Fri, 23 Oct 2020 15:41:13 +0200 Subject: CMake: Fix tst_qmake to work for configs with cross-compiled tools When cross-building Qt with CMake to target qemu configs in the CI, we specify the -DQT_BUILD_TOOLS_WHEN_CROSSCOMPILING=ON option to also cross-build tools (like qmake). In this case, $prefix/bin/qmake points to the cross-compiled qmake, and the shell script that wraps the host qmake is called $prefix/bin/host-qmake instead. In such a scenario, tst_qmake ends up running the cross-compiled qmake, which thinks that it's being run on device (via user-space qemu emulation) and doesn't specify the sysroot when computing include paths, link paths, etc. This causes the test building to fail in various ways. To fix the test, check for the existence of the host-qmake wrapper, and if it exsists use it instead. Task-number: QTBUG-86053 Change-Id: Iaa4afdf11b17f23abef873dd15b1ed950126ab8c Reviewed-by: Joerg Bornemann Reviewed-by: Qt CI Bot --- tests/auto/tools/qmake/tst_qmake.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'tests/auto/tools/qmake/tst_qmake.cpp') diff --git a/tests/auto/tools/qmake/tst_qmake.cpp b/tests/auto/tools/qmake/tst_qmake.cpp index e524274311..716f716495 100644 --- a/tests/auto/tools/qmake/tst_qmake.cpp +++ b/tests/auto/tools/qmake/tst_qmake.cpp @@ -119,6 +119,15 @@ void tst_qmake::initTestCase() QVERIFY2(tempWorkDir.isValid(), qPrintable(tempWorkDir.errorString())); QString binpath = QLibraryInfo::path(QLibraryInfo::BinariesPath); QString cmd = QString("%1/qmake").arg(binpath); + + // If Qt is cross-compiled with CMake, we might also cross-compile qmake for the device. + // In this case we don't want to use the cross-compiled qmake, but rather the host qmake + // shell wrapper (if it's available). + const QString hostQmake = QString("%1/host-qmake").arg(binpath); + if (QFile::exists(hostQmake)) { + cmd = hostQmake; + } + #ifdef Q_CC_MSVC const QString jom = QStandardPaths::findExecutable(QLatin1String("jom.exe")); if (jom.isEmpty()) { -- cgit v1.2.3