diff --git a/src/libs/utils/buildablehelperlibrary.cpp b/src/libs/utils/buildablehelperlibrary.cpp index 670624a20cb6959697b882271bd1dc341ac4d93b..492da529e4338f408c4ab5ed68c3ff0045484bf2 100644 --- a/src/libs/utils/buildablehelperlibrary.cpp +++ b/src/libs/utils/buildablehelperlibrary.cpp @@ -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('/'))) prefix.append(QLatin1Char('/')); foreach (const QString &possibleCommand, possibleQMakeCommands()) { - const QFileInfo qmake(prefix + possibleCommand); + QFileInfo qmake(prefix + possibleCommand); if (qmake.exists()) { + if (isQtChooser(qmake)) + qmake.setFile(qtChooserToQmakePath(qmake.symLinkTarget())); + if (!qtVersionForQMake(qmake.absoluteFilePath()).isNull()) return Utils::FileName(qmake); } diff --git a/src/libs/utils/buildablehelperlibrary.h b/src/libs/utils/buildablehelperlibrary.h index 2fb4ba2c3eed6ce6a1fa1f645fdcda58c958f7e2..dd68373eddabdaff4824780e54649a07095214b3 100644 --- a/src/libs/utils/buildablehelperlibrary.h +++ b/src/libs/utils/buildablehelperlibrary.h @@ -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); diff --git a/src/plugins/qtsupport/qtoptionspage.cpp b/src/plugins/qtsupport/qtoptionspage.cpp index 838dc5a0fd022bed558b1f1e78927c941b896e47..e72dab656cd1ad7590fd555e4abe9ca276b9b103 100644 --- a/src/plugins/qtsupport/qtoptionspage.cpp +++ b/src/plugins/qtsupport/qtoptionspage.cpp @@ -635,6 +635,12 @@ void QtOptionsPageWidget::addQtDir() QFileDialog::DontResolveSymlinks)); if (qtVersion.isNull()) return; + + 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) {