forked from qt-creator/qt-creator
CMake: Allow autodetected tools to associate themselves with kits
Change-Id: I5b48ddf36ba1b9c4eb6476017be63c4d43b60627 Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
@@ -272,7 +272,18 @@ Tasks CMakeKitAspect::validate(const Kit *k) const
|
|||||||
void CMakeKitAspect::setup(Kit *k)
|
void CMakeKitAspect::setup(Kit *k)
|
||||||
{
|
{
|
||||||
CMakeTool *tool = CMakeKitAspect::cmakeTool(k);
|
CMakeTool *tool = CMakeKitAspect::cmakeTool(k);
|
||||||
if (!tool)
|
if (tool)
|
||||||
|
return;
|
||||||
|
|
||||||
|
// Look for a suitable auto-detected one:
|
||||||
|
const QString id = k->autoDetectionSource();
|
||||||
|
for (CMakeTool *tool : CMakeToolManager::cmakeTools()) {
|
||||||
|
if (tool->detectionSource() == id) {
|
||||||
|
setCMakeTool(k, tool->id());
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
setCMakeTool(k, defaultCMakeToolId());
|
setCMakeTool(k, defaultCMakeToolId());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -109,6 +109,9 @@ public:
|
|||||||
|
|
||||||
static Utils::FilePath searchQchFile(const Utils::FilePath &executable);
|
static Utils::FilePath searchQchFile(const Utils::FilePath &executable);
|
||||||
|
|
||||||
|
QString detectionSource() const { return m_detectionSource; }
|
||||||
|
void setDetectionSource(const QString &source) { m_detectionSource = source; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void readInformation() const;
|
void readInformation() const;
|
||||||
|
|
||||||
@@ -126,6 +129,7 @@ private:
|
|||||||
|
|
||||||
bool m_isAutoRun = true;
|
bool m_isAutoRun = true;
|
||||||
bool m_isAutoDetected = false;
|
bool m_isAutoDetected = false;
|
||||||
|
QString m_detectionSource;
|
||||||
bool m_autoCreateBuildDirectory = false;
|
bool m_autoCreateBuildDirectory = false;
|
||||||
|
|
||||||
Utils::optional<ReaderType> m_readerType;
|
Utils::optional<ReaderType> m_readerType;
|
||||||
|
|||||||
@@ -177,7 +177,7 @@ void CMakeToolManager::updateDocumentation()
|
|||||||
Core::HelpManager::registerDocumentation(docs);
|
Core::HelpManager::registerDocumentation(docs);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CMakeToolManager::registerCMakeByPath(const FilePath &cmakePath)
|
void CMakeToolManager::registerCMakeByPath(const FilePath &cmakePath, const QString &detectionSource)
|
||||||
{
|
{
|
||||||
const Id id = Id::fromString(cmakePath.toUserOutput());
|
const Id id = Id::fromString(cmakePath.toUserOutput());
|
||||||
|
|
||||||
@@ -188,6 +188,7 @@ void CMakeToolManager::registerCMakeByPath(const FilePath &cmakePath)
|
|||||||
auto newTool = std::make_unique<CMakeTool>(CMakeTool::ManualDetection, id);
|
auto newTool = std::make_unique<CMakeTool>(CMakeTool::ManualDetection, id);
|
||||||
newTool->setFilePath(cmakePath);
|
newTool->setFilePath(cmakePath);
|
||||||
newTool->setDisplayName(cmakePath.toUserOutput());
|
newTool->setDisplayName(cmakePath.toUserOutput());
|
||||||
|
newTool->setDetectionSource(detectionSource);
|
||||||
registerCMakeTool(std::move(newTool));
|
registerCMakeTool(std::move(newTool));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -63,7 +63,7 @@ public:
|
|||||||
static void updateDocumentation();
|
static void updateDocumentation();
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void registerCMakeByPath(const Utils::FilePath &cmakePath);
|
void registerCMakeByPath(const Utils::FilePath &cmakePath, const QString &detectionSource);
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void cmakeAdded (const Utils::Id &id);
|
void cmakeAdded (const Utils::Id &id);
|
||||||
|
|||||||
@@ -491,7 +491,8 @@ void DockerDevicePrivate::autoDetectCMake(QTextBrowser *log)
|
|||||||
log->append(tr("Found CMake binary: %1").arg(cmake.toUserOutput()));
|
log->append(tr("Found CMake binary: %1").arg(cmake.toUserOutput()));
|
||||||
const bool res = QMetaObject::invokeMethod(cmakeManager,
|
const bool res = QMetaObject::invokeMethod(cmakeManager,
|
||||||
"registerCMakeByPath",
|
"registerCMakeByPath",
|
||||||
Q_ARG(Utils::FilePath, cmake));
|
Q_ARG(Utils::FilePath, cmake),
|
||||||
|
Q_ARG(QString, m_data.id()));
|
||||||
QTC_CHECK(res);
|
QTC_CHECK(res);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user