Skip to content
Snippets Groups Projects
Commit 298d07d8 authored by Tobias Hunger's avatar Tobias Hunger
Browse files

QtVersion: Fix detection of system Qt


We used to get a list of possible qmake file names, but now we
just get a list of filename patterns.

Task-number: QTCREATORBUG-13200
Change-Id: I9e635ec04b25139cfa8e7096173ac9e1910d0ef5
Reviewed-by: default avatarDaniel Teske <daniel.teske@digia.com>
parent 4336f887
No related branches found
No related tags found
No related merge requests found
...@@ -65,22 +65,40 @@ QString BuildableHelperLibrary::qtChooserToQmakePath(const QString &path) ...@@ -65,22 +65,40 @@ QString BuildableHelperLibrary::qtChooserToQmakePath(const QString &path)
return result; return result;
} }
static bool isQmake(const QString &path)
{
if (path.isEmpty())
return false;
QFileInfo fi(path);
if (BuildableHelperLibrary::isQtChooser(fi))
fi.setFile(BuildableHelperLibrary::qtChooserToQmakePath(fi.symLinkTarget()));
return !BuildableHelperLibrary::qtVersionForQMake(fi.absoluteFilePath()).isEmpty();
}
FileName BuildableHelperLibrary::findSystemQt(const Environment &env) FileName BuildableHelperLibrary::findSystemQt(const Environment &env)
{ {
const QString qmake = QLatin1String("qmake");
QStringList paths = env.path(); QStringList paths = env.path();
foreach (const QString &path, paths) { foreach (const QString &path, paths) {
QString prefix = path; if (path.isEmpty())
if (!prefix.endsWith(QLatin1Char('/'))) continue;
prefix.append(QLatin1Char('/'));
foreach (const QString &possibleCommand, possibleQMakeCommands()) { QDir dir(path);
QFileInfo qmake(prefix + possibleCommand);
if (qmake.exists()) { if (dir.exists(qmake)) {
if (isQtChooser(qmake)) const QString qmakePath = dir.absoluteFilePath(qmake);
qmake.setFile(qtChooserToQmakePath(qmake.symLinkTarget())); if (isQmake(qmakePath))
return FileName::fromString(qmakePath);
if (!qtVersionForQMake(qmake.absoluteFilePath()).isNull()) }
return FileName(qmake);
} // Prefer qmake-qt5 to qmake-qt4 by sorting the filenames in reverse order.
foreach (const QFileInfo &fi, dir.entryInfoList(possibleQMakeCommands(), QDir::Files, QDir::Name | QDir::Reversed)) {
if (fi.fileName() == qmake)
continue;
if (isQmake(fi.absoluteFilePath()))
return FileName(fi);
} }
} }
return FileName(); return FileName();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment