summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorOliver Wolff <oliver.wolff@qt.io>2020-09-14 10:05:21 +0200
committerFriedemann Kleint <Friedemann.Kleint@qt.io>2020-09-16 13:08:47 +0000
commitcc67bbbee6386c10c8282b3ea02f6db654d60c1e (patch)
treea69bfac69bffdfaecbeaa504c72e6f9f91add27f
parent15d7a30d41b423846fc74d9dd252c1e2a84769e2 (diff)
windeployqt: Add optional qmake parameter
In a crosscompilation setup (for example Windows arm64) windeployqt will pick up the wrong Qt libraries. At the moment qmake is the only way to determine information about the Qt build even if cmake was used to build Qt. By passing the path to the proper qmake, windeployqt will deploy the correct libraries for the build. Change-Id: I14992b1c27cce774440fa16abcc2abb30bec641a Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
-rw-r--r--src/shared/winutils/utils.cpp4
-rw-r--r--src/shared/winutils/utils.h2
-rw-r--r--src/windeployqt/main.cpp33
3 files changed, 31 insertions, 8 deletions
diff --git a/src/shared/winutils/utils.cpp b/src/shared/winutils/utils.cpp
index aaad905a0..4656e0599 100644
--- a/src/shared/winutils/utils.cpp
+++ b/src/shared/winutils/utils.cpp
@@ -494,12 +494,12 @@ QString findInPath(const QString &file)
const char *qmakeInfixKey = "QT_INFIX";
-QMap<QString, QString> queryQMakeAll(QString *errorMessage)
+QMap<QString, QString> queryQMakeAll(const QString &qmakeBinary, QString *errorMessage)
{
+ const QString binary = !qmakeBinary.isEmpty() ? qmakeBinary : QStringLiteral("qmake");
QByteArray stdOut;
QByteArray stdErr;
unsigned long exitCode = 0;
- const QString binary = QStringLiteral("qmake");
if (!runProcess(binary, QStringList(QStringLiteral("-query")), QString(), &exitCode, &stdOut, &stdErr, errorMessage))
return QMap<QString, QString>();
if (exitCode) {
diff --git a/src/shared/winutils/utils.h b/src/shared/winutils/utils.h
index 951ebf773..548d5305c 100644
--- a/src/shared/winutils/utils.h
+++ b/src/shared/winutils/utils.h
@@ -173,7 +173,7 @@ QString findInPath(const QString &file);
extern const char *qmakeInfixKey; // Fake key containing the libinfix
-QMap<QString, QString> queryQMakeAll(QString *errorMessage);
+QMap<QString, QString> queryQMakeAll(const QString &qmakeBinary, QString *errorMessage);
QString queryQMake(const QString &variable, QString *errorMessage);
enum DebugMatchMode {
diff --git a/src/windeployqt/main.cpp b/src/windeployqt/main.cpp
index 3341f6152..213214576 100644
--- a/src/windeployqt/main.cpp
+++ b/src/windeployqt/main.cpp
@@ -263,6 +263,7 @@ struct Options {
QStringList qmlDirectories; // Project's QML files.
QStringList qmlImportPaths; // Custom QML module locations.
QString directory;
+ QString qmakePath;
QString translationsDirectory; // Translations target directory
QStringList languages;
QString libraryDirectory;
@@ -325,6 +326,11 @@ static inline int parseArguments(const QStringList &arguments, QCommandLineParse
QStringLiteral("directory"));
parser->addOption(dirOption);
+ QCommandLineOption qmakeOption(QStringLiteral("qmake"),
+ QStringLiteral("Use specified qmake instead of qmake from PATH."),
+ QStringLiteral("path"));
+ parser->addOption(qmakeOption);
+
QCommandLineOption libDirOption(QStringLiteral("libdir"),
QStringLiteral("Copy libraries to path."),
QStringLiteral("path"));
@@ -591,6 +597,22 @@ static inline int parseArguments(const QStringList &arguments, QCommandLineParse
if (parser->isSet(dirOption))
options->directory = parser->value(dirOption);
+ if (parser->isSet(qmakeOption)) {
+ const QString qmakePath = QDir::cleanPath(parser->value(qmakeOption));
+ const QFileInfo fi(qmakePath);
+ if (!fi.exists()) {
+ *errorMessage = msgFileDoesNotExist(qmakePath);
+ return CommandLineParseError;
+ }
+
+ if (!fi.isExecutable()) {
+ *errorMessage = QLatin1Char('"') + QDir::toNativeSeparators(qmakePath)
+ + QStringLiteral("\" is not an executable.");
+ return CommandLineParseError;
+ }
+ options->qmakePath = qmakePath;
+ }
+
if (parser->isSet(qmlDirOption))
options->qmlDirectories = parser->values(qmlDirOption);
@@ -1616,11 +1638,6 @@ int main(int argc, char **argv)
Options options;
QString errorMessage;
- const QMap<QString, QString> qmakeVariables = queryQMakeAll(&errorMessage);
- const QString xSpec = qmakeVariables.value(QStringLiteral("QMAKE_XSPEC"));
- options.platform = platformFromMkSpec(xSpec);
- if (options.platform == WindowsDesktopMinGW || options.platform == WindowsDesktopMsvc)
- options.compilerRunTime = true;
{ // Command line
QCommandLineParser parser;
@@ -1636,6 +1653,12 @@ int main(int argc, char **argv)
return 0;
}
+ const QMap<QString, QString> qmakeVariables = queryQMakeAll(options.qmakePath, &errorMessage);
+ const QString xSpec = qmakeVariables.value(QStringLiteral("QMAKE_XSPEC"));
+ options.platform = platformFromMkSpec(xSpec);
+ if (options.platform == WindowsDesktopMinGW || options.platform == WindowsDesktopMsvc)
+ options.compilerRunTime = true;
+
if (qmakeVariables.isEmpty() || xSpec.isEmpty() || !qmakeVariables.contains(QStringLiteral("QT_INSTALL_BINS"))) {
std::wcerr << "Unable to query qmake: " << errorMessage << '\n';
return 1;