forked from qt-creator/qt-creator
Docker: Re-do auto-detection of Qt
This now properly iterates into subdirectories when selecting the "Search in selected directories" option for the auto-detection so it works with Boot2Qt images that don't put Qt in PATH, but somewhere under /opt Change-Id: Ifc337c0169d4b98b4e894a5d7e8286f171e0c569 Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
@@ -709,20 +709,26 @@ QtVersions KitDetectorPrivate::autoDetectQtVersions() const
|
||||
QtVersions qtVersions;
|
||||
|
||||
QString error;
|
||||
|
||||
const auto handleQmake = [this, &qtVersions, &error](const FilePath &qmake) {
|
||||
if (QtVersion *qtVersion = QtVersionFactory::createQtVersionFromQMakePath(qmake, false, m_sharedId, &error)) {
|
||||
qtVersions.append(qtVersion);
|
||||
QtVersionManager::addVersion(qtVersion);
|
||||
emit q->logOutput(tr("Found \"%1\"").arg(qtVersion->qmakeFilePath().toUserOutput()));
|
||||
}
|
||||
return true;
|
||||
};
|
||||
|
||||
emit q->logOutput(tr("Searching for qmake executables..."));
|
||||
|
||||
const QStringList candidates = {"qmake-qt6", "qmake-qt5", "qmake"};
|
||||
emit q->logOutput('\n' + tr("Searching Qt installations..."));
|
||||
for (const QString &candidate : candidates) {
|
||||
emit q->logOutput(tr("Searching for %1 executable...").arg(candidate));
|
||||
const FilePath qmake = m_device->searchExecutable(candidate, m_searchPaths);
|
||||
if (qmake.isEmpty())
|
||||
continue;
|
||||
QtVersion *qtVersion = QtVersionFactory::createQtVersionFromQMakePath(qmake, false, m_sharedId, &error);
|
||||
if (!qtVersion)
|
||||
continue;
|
||||
qtVersions.append(qtVersion);
|
||||
QtVersionManager::addVersion(qtVersion);
|
||||
emit q->logOutput(tr("Found \"%1\"").arg(qtVersion->qmakeFilePath().toUserOutput()));
|
||||
for (const FilePath &searchPath : m_searchPaths) {
|
||||
searchPath.iterateDirectory(handleQmake, {candidates, QDir::Files | QDir::Executable,
|
||||
QDirIterator::Subdirectories});
|
||||
}
|
||||
|
||||
if (!error.isEmpty())
|
||||
emit q->logOutput(tr("Error: %1.").arg(error));
|
||||
if (qtVersions.isEmpty())
|
||||
emit q->logOutput(tr("No Qt installation found."));
|
||||
return qtVersions;
|
||||
@@ -793,19 +799,20 @@ void KitDetectorPrivate::autoDetect()
|
||||
|
||||
emit q->logOutput(tr("Starting auto-detection. This will take a while..."));
|
||||
|
||||
QList<ToolChain *> toolChains = autoDetectToolChains();
|
||||
QtVersions qtVersions = autoDetectQtVersions();
|
||||
const Toolchains toolchains = autoDetectToolChains();
|
||||
const QtVersions qtVersions = autoDetectQtVersions();
|
||||
|
||||
autoDetectCMake();
|
||||
autoDetectDebugger();
|
||||
|
||||
const auto initializeKit = [this, toolChains, qtVersions](Kit *k) {
|
||||
const auto initializeKit = [this, toolchains, qtVersions](Kit *k) {
|
||||
k->setAutoDetected(false);
|
||||
k->setAutoDetectionSource(m_sharedId);
|
||||
k->setUnexpandedDisplayName("%{Device:Name}");
|
||||
|
||||
DeviceTypeKitAspect::setDeviceTypeId(k, Constants::DOCKER_DEVICE_TYPE);
|
||||
DeviceKitAspect::setDevice(k, m_device);
|
||||
|
||||
QtVersion *qt = nullptr;
|
||||
if (!qtVersions.isEmpty()) {
|
||||
qt = qtVersions.at(0);
|
||||
|
Reference in New Issue
Block a user