Commit 84b47922 authored by Daniel Teske's avatar Daniel Teske
Browse files

QtVersion: Special treatment for qthooser

Resolve which qmake qtchooser will forward too, as that qmake will put
it's path into the makefile.

Task-number: QTCREATORBUG-9841
Change-Id: Ib7a17c7683550ce3bb9172c7428a0efc328652f5
Reviewed-by: default avatarTobias Hunger <>
parent e61c797c
......@@ -37,6 +37,32 @@
namespace Utils {
bool BuildableHelperLibrary::isQtChooser(const QFileInfo &info)
return info.isSymLink() && info.symLinkTarget().endsWith(QLatin1String("/qtchooser"));
QString BuildableHelperLibrary::qtChooserToQmakePath(const QString &path)
QProcess proc;
proc.start(path, QStringList(QLatin1String("-print-env")));
if (!proc.waitForStarted(1000))
return QString();
if (!proc.waitForFinished(1000))
return QString();
QByteArray output = proc.readAllStandardOutput();
int pos = output.indexOf("QTTOOLDIR=");
if (pos == -1)
return QString();
pos += strlen("QTTOOLDIR=\"");
int end = output.indexOf('\"', pos);
if (end == -1)
return QString();
QString result = QString::fromLocal8Bit(output.mid(pos, end - pos)) + QLatin1String("/qmake");
return result;
Utils::FileName BuildableHelperLibrary::findSystemQt(const Utils::Environment &env)
QStringList paths = env.path();
......@@ -45,8 +71,11 @@ Utils::FileName BuildableHelperLibrary::findSystemQt(const Utils::Environment &e
if (!prefix.endsWith(QLatin1Char('/')))
foreach (const QString &possibleCommand, possibleQMakeCommands()) {
const QFileInfo qmake(prefix + possibleCommand);
QFileInfo qmake(prefix + possibleCommand);
if (qmake.exists()) {
if (isQtChooser(qmake))
if (!qtVersionForQMake(qmake.absoluteFilePath()).isNull())
return Utils::FileName(qmake);
......@@ -43,6 +43,8 @@ public:
// returns the full path to the first qmake, qmake-qt4, qmake4 that has
// at least version 2.0.0 and thus is a qt4 qmake
static FileName findSystemQt(const Utils::Environment &env);
static bool isQtChooser(const QFileInfo &info);
static QString qtChooserToQmakePath(const QString &path);
// return true if the qmake at qmakePath is qt4 (used by QtVersion)
static QString qtVersionForQMake(const QString &qmakePath);
static QString qtVersionForQMake(const QString &qmakePath, bool *qmakeIsExecutable);
......@@ -635,6 +635,12 @@ void QtOptionsPageWidget::addQtDir()
if (qtVersion.isNull())
QFileInfo fi(qtVersion.toString());
// should add all qt versions here ?
if (BuildableHelperLibrary::isQtChooser(fi))
qtVersion = Utils::FileName::fromString(BuildableHelperLibrary::qtChooserToQmakePath(fi.symLinkTarget()));
BaseQtVersion *version = 0;
foreach (BaseQtVersion *v, m_versions) {
if (v->qmakeCommand() == qtVersion) {
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment