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: Daniel Teske <daniel.teske@digia.com>
This commit is contained in:
Tobias Hunger
2014-10-30 15:51:47 +01:00
parent 86d7a980ff
commit 2c985096a5
2 changed files with 26 additions and 16 deletions

View File

@@ -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());
if (qmake.isEmpty())
return -1;
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;
}
if (fallBack)
return fallBack->uniqueId();
BaseQtVersion *result = findOrDefault(versionList, [](const BaseQtVersion *v) {
return v->autodetectionSource() == QLatin1String("PATH");
});
return -1;
if (result)
return result->uniqueId();
// 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;
});
}
// 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

View File

@@ -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);