forked from qt-creator/qt-creator
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: Daniel Teske <daniel.teske@digia.com>
This commit is contained in:
@@ -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()) {
|
|
||||||
QFileInfo qmake(prefix + possibleCommand);
|
|
||||||
if (qmake.exists()) {
|
|
||||||
if (isQtChooser(qmake))
|
|
||||||
qmake.setFile(qtChooserToQmakePath(qmake.symLinkTarget()));
|
|
||||||
|
|
||||||
if (!qtVersionForQMake(qmake.absoluteFilePath()).isNull())
|
QDir dir(path);
|
||||||
return FileName(qmake);
|
|
||||||
|
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();
|
return FileName();
|
||||||
|
|||||||
Reference in New Issue
Block a user