summaryrefslogtreecommitdiffstats
path: root/qmake
diff options
context:
space:
mode:
authorJoerg Bornemann <joerg.bornemann@theqtcompany.com>2014-12-22 16:45:09 +0100
committerJoerg Bornemann <joerg.bornemann@theqtcompany.com>2015-01-16 12:07:03 +0100
commite01c8103e14371dab7660343aff058528a11d763 (patch)
tree962888afb7a2c724c5c419e204948dce3ee8c38f /qmake
parent5884160db62f32bed91f8449c4ca1204b8ba5dbd (diff)
fix MSVC target architecture detection for amd64_x86
When using the cross-compiler toolchain for 32 bit on a 64 bit machine, qmake generated a 64 bit VS project. This was because qmake didn't know about the amd64_x86 cross-compiler, and qmake did not use the first MSVC bin directory it found in PATH. Task-number: QTBUG-43457 Change-Id: I50c6f7bb9afe44a58321c670d680dbcc7cd07223 Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@theqtcompany.com>
Diffstat (limited to 'qmake')
-rw-r--r--qmake/library/qmakeevaluator.cpp57
1 files changed, 42 insertions, 15 deletions
diff --git a/qmake/library/qmakeevaluator.cpp b/qmake/library/qmakeevaluator.cpp
index 4eb624aa87..fe089c1059 100644
--- a/qmake/library/qmakeevaluator.cpp
+++ b/qmake/library/qmakeevaluator.cpp
@@ -944,6 +944,45 @@ void QMakeEvaluator::setTemplate()
}
}
+#if defined(Q_CC_MSVC)
+static ProString msvcBinDirToQMakeArch(QString subdir)
+{
+ int idx = subdir.indexOf(QLatin1Char('\\'));
+ if (idx == -1)
+ return ProString("x86");
+ subdir.remove(0, idx + 1);
+ idx = subdir.indexOf(QLatin1Char('_'));
+ if (idx >= 0)
+ subdir.remove(0, idx + 1);
+ subdir = subdir.toLower();
+ if (subdir == QStringLiteral("amd64"))
+ return ProString("x86_64");
+ return ProString(subdir);
+}
+
+static ProString defaultMsvcArchitecture()
+{
+ return ProString("x86");
+}
+
+static ProString msvcArchitecture(const QString &vcInstallDir, const QString &pathVar)
+{
+ if (vcInstallDir.isEmpty())
+ return defaultMsvcArchitecture();
+ QString vcBinDir = vcInstallDir;
+ if (vcBinDir.endsWith(QLatin1Char('\\')))
+ vcBinDir.chop(1);
+ foreach (const QString &dir, pathVar.split(QLatin1Char(';'))) {
+ if (!dir.startsWith(vcBinDir, Qt::CaseInsensitive))
+ continue;
+ const ProString arch = msvcBinDirToQMakeArch(dir.mid(vcBinDir.length() + 1));
+ if (!arch.isEmpty())
+ return arch;
+ }
+ return defaultMsvcArchitecture();
+}
+#endif // defined(Q_CC_MSVC)
+
void QMakeEvaluator::loadDefaults()
{
ProValueMap &vars = m_valuemapStack.top();
@@ -1004,21 +1043,9 @@ void QMakeEvaluator::loadDefaults()
vars[ProKey("QMAKE_HOST.arch")] << archStr;
# if defined(Q_CC_MSVC) // ### bogus condition, but nobody x-builds for msvc with a different qmake
- QLatin1Char backslash('\\');
- QString paths = m_option->getEnv(QLatin1String("PATH"));
- QString vcBin64 = m_option->getEnv(QLatin1String("VCINSTALLDIR"));
- if (!vcBin64.endsWith(backslash))
- vcBin64.append(backslash);
- vcBin64.append(QLatin1String("bin\\amd64"));
- QString vcBinX86_64 = m_option->getEnv(QLatin1String("VCINSTALLDIR"));
- if (!vcBinX86_64.endsWith(backslash))
- vcBinX86_64.append(backslash);
- vcBinX86_64.append(QLatin1String("bin\\x86_amd64"));
- if (paths.contains(vcBin64, Qt::CaseInsensitive)
- || paths.contains(vcBinX86_64, Qt::CaseInsensitive))
- vars[ProKey("QMAKE_TARGET.arch")] << ProString("x86_64");
- else
- vars[ProKey("QMAKE_TARGET.arch")] << ProString("x86");
+ vars[ProKey("QMAKE_TARGET.arch")] = msvcArchitecture(
+ m_option->getEnv(QLatin1String("VCINSTALLDIR")),
+ m_option->getEnv(QLatin1String("PATH")));
# endif
#elif defined(Q_OS_UNIX)
struct utsname name;