forked from qt-creator/qt-creator
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:
@@ -35,6 +35,7 @@
|
|||||||
#include "qtversionmanager.h"
|
#include "qtversionmanager.h"
|
||||||
#include "qtparser.h"
|
#include "qtparser.h"
|
||||||
|
|
||||||
|
#include <utils/algorithm.h>
|
||||||
#include <utils/buildablehelperlibrary.h>
|
#include <utils/buildablehelperlibrary.h>
|
||||||
#include <utils/macroexpander.h>
|
#include <utils/macroexpander.h>
|
||||||
#include <utils/qtcassert.h>
|
#include <utils/qtcassert.h>
|
||||||
@@ -59,23 +60,31 @@ QVariant QtKitInformation::defaultValue(ProjectExplorer::Kit *k) const
|
|||||||
Q_UNUSED(k);
|
Q_UNUSED(k);
|
||||||
|
|
||||||
// find "Qt in PATH":
|
// find "Qt in PATH":
|
||||||
Utils::FileName qmake = Utils::BuildableHelperLibrary::findSystemQt(Utils::Environment::systemEnvironment());
|
|
||||||
|
|
||||||
if (qmake.isEmpty())
|
|
||||||
return -1;
|
|
||||||
|
|
||||||
QList<BaseQtVersion *> versionList = QtVersionManager::versions();
|
QList<BaseQtVersion *> versionList = QtVersionManager::versions();
|
||||||
BaseQtVersion *fallBack = 0;
|
BaseQtVersion *result = findOrDefault(versionList, [](const BaseQtVersion *v) {
|
||||||
foreach (BaseQtVersion *v, versionList) {
|
return v->autodetectionSource() == QLatin1String("PATH");
|
||||||
if (qmake == v->qmakeCommand())
|
});
|
||||||
return v->uniqueId();
|
|
||||||
if (v->type() == QLatin1String(QtSupport::Constants::DESKTOPQT) && !fallBack)
|
|
||||||
fallBack = v;
|
|
||||||
}
|
|
||||||
if (fallBack)
|
|
||||||
return fallBack->uniqueId();
|
|
||||||
|
|
||||||
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
|
QList<ProjectExplorer::Task> QtKitInformation::validate(const ProjectExplorer::Kit *k) const
|
||||||
|
|||||||
@@ -440,7 +440,8 @@ static void findSystemQt()
|
|||||||
if (systemQMakePath.isNull())
|
if (systemQMakePath.isNull())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
BaseQtVersion *version = QtVersionFactory::createQtVersionFromQMakePath(systemQMakePath);
|
BaseQtVersion *version
|
||||||
|
= QtVersionFactory::createQtVersionFromQMakePath(systemQMakePath, false, QLatin1String("PATH"));
|
||||||
if (version) {
|
if (version) {
|
||||||
version->setUnexpandedDisplayName(BaseQtVersion::defaultUnexpandedDisplayName(systemQMakePath, true));
|
version->setUnexpandedDisplayName(BaseQtVersion::defaultUnexpandedDisplayName(systemQMakePath, true));
|
||||||
m_versions.insert(version->uniqueId(), version);
|
m_versions.insert(version->uniqueId(), version);
|
||||||
|
|||||||
Reference in New Issue
Block a user