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
......@@ -65,22 +65,40 @@ QString BuildableHelperLibrary::qtChooserToQmakePath(const QString &path)
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)
{
const QString qmake = QLatin1String("qmake");
QStringList paths = env.path();
foreach (const QString &path, paths) {
QString prefix = path;
if (!prefix.endsWith(QLatin1Char('/')))
prefix.append(QLatin1Char('/'));
foreach (const QString &possibleCommand, possibleQMakeCommands()) {
QFileInfo qmake(prefix + possibleCommand);
if (qmake.exists()) {
if (isQtChooser(qmake))
qmake.setFile(qtChooserToQmakePath(qmake.symLinkTarget()));
if (!qtVersionForQMake(qmake.absoluteFilePath()).isNull())
return FileName(qmake);
}
if (path.isEmpty())
continue;
QDir dir(path);
if (dir.exists(qmake)) {
const QString qmakePath = dir.absoluteFilePath(qmake);
if (isQmake(qmakePath))
return FileName::fromString(qmakePath);
}
// 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();
......
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