forked from qt-creator/qt-creator
CMake: Register CMake tools detected while scanning build directories
Fixes: QTCREATORBUG-24502 Change-Id: Idf96e666e783edbf8b0fbe4216affb80b0464104 Reviewed-by: Cristian Adam <cristian.adam@qt.io>
This commit is contained in:
@@ -38,6 +38,7 @@
|
|||||||
|
|
||||||
#include <utils/algorithm.h>
|
#include <utils/algorithm.h>
|
||||||
#include <utils/qtcassert.h>
|
#include <utils/qtcassert.h>
|
||||||
|
#include <utils/stringutils.h>
|
||||||
|
|
||||||
#include <QDir>
|
#include <QDir>
|
||||||
#include <QLoggingCategory>
|
#include <QLoggingCategory>
|
||||||
@@ -82,6 +83,22 @@ static QStringList scanDirectory(const QString &path, const QString &prefix)
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QString baseCMakeToolDisplayName(CMakeProjectManager::CMakeTool &tool)
|
||||||
|
{
|
||||||
|
CMakeProjectManager::CMakeTool::Version version = tool.version();
|
||||||
|
return QString("CMake %1.%2.%3").arg(version.major).arg(version.minor).arg(version.patch);
|
||||||
|
}
|
||||||
|
|
||||||
|
QString uniqueCMakeToolDisplayName(CMakeProjectManager::CMakeTool &tool)
|
||||||
|
{
|
||||||
|
QString baseName = baseCMakeToolDisplayName(tool);
|
||||||
|
|
||||||
|
QStringList existingNames;
|
||||||
|
for (const CMakeProjectManager::CMakeTool *t : CMakeProjectManager::CMakeToolManager::cmakeTools())
|
||||||
|
existingNames << t->displayName();
|
||||||
|
return Utils::makeUniquelyNumbered(baseName, existingNames);
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
namespace CMakeProjectManager {
|
namespace CMakeProjectManager {
|
||||||
@@ -319,6 +336,7 @@ Kit *CMakeProjectImporter::createKit(void *directoryData) const
|
|||||||
QTC_ASSERT(cmtd.cmakeTool, return);
|
QTC_ASSERT(cmtd.cmakeTool, return);
|
||||||
if (cmtd.isTemporary)
|
if (cmtd.isTemporary)
|
||||||
addTemporaryData(CMakeKitAspect::id(), cmtd.cmakeTool->id().toSetting(), k);
|
addTemporaryData(CMakeKitAspect::id(), cmtd.cmakeTool->id().toSetting(), k);
|
||||||
|
CMakeKitAspect::setCMakeTool(k, cmtd.cmakeTool->id());
|
||||||
|
|
||||||
CMakeGeneratorKitAspect::setGenerator(k, QString::fromUtf8(data->generator));
|
CMakeGeneratorKitAspect::setGenerator(k, QString::fromUtf8(data->generator));
|
||||||
CMakeGeneratorKitAspect::setExtraGenerator(k, QString::fromUtf8(data->extraGenerator));
|
CMakeGeneratorKitAspect::setExtraGenerator(k, QString::fromUtf8(data->extraGenerator));
|
||||||
@@ -364,8 +382,16 @@ CMakeProjectImporter::findOrCreateCMakeTool(const Utils::FilePath &cmakeToolPath
|
|||||||
result.cmakeTool = CMakeToolManager::findByCommand(cmakeToolPath);
|
result.cmakeTool = CMakeToolManager::findByCommand(cmakeToolPath);
|
||||||
if (!result.cmakeTool) {
|
if (!result.cmakeTool) {
|
||||||
qCDebug(cmInputLog) << "Creating temporary CMakeTool for" << cmakeToolPath.toUserOutput();
|
qCDebug(cmInputLog) << "Creating temporary CMakeTool for" << cmakeToolPath.toUserOutput();
|
||||||
result.cmakeTool = new CMakeTool(CMakeTool::ManualDetection, CMakeTool::createId());
|
|
||||||
|
UpdateGuard guard(*this);
|
||||||
|
|
||||||
|
auto newTool = std::make_unique<CMakeTool>(CMakeTool::ManualDetection, CMakeTool::createId());
|
||||||
|
newTool->setFilePath(cmakeToolPath);
|
||||||
|
newTool->setDisplayName(uniqueCMakeToolDisplayName(*newTool));
|
||||||
|
|
||||||
|
result.cmakeTool = newTool.get();
|
||||||
result.isTemporary = true;
|
result.isTemporary = true;
|
||||||
|
CMakeToolManager::registerCMakeTool(std::move(newTool));
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user