Commit 2c985096 authored by Tobias Hunger's avatar Tobias Hunger
Browse files

QtVersion: Mark system Qt as autodetectionSource "PATH"



... and use that to retrieve that version again.

This avoids trying to run qmake to make sure it is actually a qmake
and not just some binary with the same name in the PATH.

Change-Id: I7a2c3c85e81c77cc3b56dde088a73e065d03760c
Reviewed-by: default avatarDaniel Teske <daniel.teske@digia.com>
parent 86d7a980
......@@ -35,6 +35,7 @@
#include "qtversionmanager.h"
#include "qtparser.h"
#include <utils/algorithm.h>
#include <utils/buildablehelperlibrary.h>
#include <utils/macroexpander.h>
#include <utils/qtcassert.h>
......@@ -59,23 +60,31 @@ QVariant QtKitInformation::defaultValue(ProjectExplorer::Kit *k) const
Q_UNUSED(k);
// find "Qt in PATH":
Utils::FileName qmake = Utils::BuildableHelperLibrary::findSystemQt(Utils::Environment::systemEnvironment());
QList<BaseQtVersion *> versionList = QtVersionManager::versions();
BaseQtVersion *result = findOrDefault(versionList, [](const BaseQtVersion *v) {
return v->autodetectionSource() == QLatin1String("PATH");
});
if (qmake.isEmpty())
return -1;
if (result)
return result->uniqueId();
QList<BaseQtVersion *> versionList = QtVersionManager::versions();
BaseQtVersion *fallBack = 0;
foreach (BaseQtVersion *v, versionList) {
if (qmake == v->qmakeCommand())
return v->uniqueId();
if (v->type() == QLatin1String(QtSupport::Constants::DESKTOPQT) && !fallBack)
fallBack = v;
// Legacy: Check for system qmake path: Remove in 3.5 (or later):
// This check is expensive as it will potentially run binaries (qmake --version)!
const FileName qmakePath
= BuildableHelperLibrary::findSystemQt(Utils::Environment::systemEnvironment());
if (!qmakePath.isEmpty()) {
result = findOrDefault(versionList, [qmakePath](const BaseQtVersion *v) {
return v->qmakeCommand() == qmakePath;
});
}
if (fallBack)
return fallBack->uniqueId();
return -1;
// Use *any* desktop Qt:
result = findOrDefault(versionList, [](const BaseQtVersion *v) {
return v->type() == QLatin1String(QtSupport::Constants::DESKTOPQT);
});
return result ? result->uniqueId() : -1;
}
QList<ProjectExplorer::Task> QtKitInformation::validate(const ProjectExplorer::Kit *k) const
......
......@@ -440,7 +440,8 @@ static void findSystemQt()
if (systemQMakePath.isNull())
return;
BaseQtVersion *version = QtVersionFactory::createQtVersionFromQMakePath(systemQMakePath);
BaseQtVersion *version
= QtVersionFactory::createQtVersionFromQMakePath(systemQMakePath, false, QLatin1String("PATH"));
if (version) {
version->setUnexpandedDisplayName(BaseQtVersion::defaultUnexpandedDisplayName(systemQMakePath, true));
m_versions.insert(version->uniqueId(), version);
......
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