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 <joerg.bornemann@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
This commit is contained in:
Alexandru Croitor 2020-10-23 15:41:13 +02:00
parent 1b7ee06605
commit 815f31799c

View File

@ -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()) {