diff --git a/src/plugins/cmakeprojectmanager/cmakekitinformation.cpp b/src/plugins/cmakeprojectmanager/cmakekitinformation.cpp index 24669a58a53..925c240942c 100644 --- a/src/plugins/cmakeprojectmanager/cmakekitinformation.cpp +++ b/src/plugins/cmakeprojectmanager/cmakekitinformation.cpp @@ -272,8 +272,19 @@ Tasks CMakeKitAspect::validate(const Kit *k) const void CMakeKitAspect::setup(Kit *k) { CMakeTool *tool = CMakeKitAspect::cmakeTool(k); - if (!tool) - setCMakeTool(k, defaultCMakeToolId()); + 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()); } void CMakeKitAspect::fix(Kit *k) diff --git a/src/plugins/cmakeprojectmanager/cmaketool.h b/src/plugins/cmakeprojectmanager/cmaketool.h index 1414168acb1..62b5c9964ce 100644 --- a/src/plugins/cmakeprojectmanager/cmaketool.h +++ b/src/plugins/cmakeprojectmanager/cmaketool.h @@ -109,6 +109,9 @@ public: static Utils::FilePath searchQchFile(const Utils::FilePath &executable); + QString detectionSource() const { return m_detectionSource; } + void setDetectionSource(const QString &source) { m_detectionSource = source; } + private: void readInformation() const; @@ -126,6 +129,7 @@ private: bool m_isAutoRun = true; bool m_isAutoDetected = false; + QString m_detectionSource; bool m_autoCreateBuildDirectory = false; Utils::optional m_readerType; diff --git a/src/plugins/cmakeprojectmanager/cmaketoolmanager.cpp b/src/plugins/cmakeprojectmanager/cmaketoolmanager.cpp index a250b1cf4fb..42beff4b932 100644 --- a/src/plugins/cmakeprojectmanager/cmaketoolmanager.cpp +++ b/src/plugins/cmakeprojectmanager/cmaketoolmanager.cpp @@ -177,7 +177,7 @@ void CMakeToolManager::updateDocumentation() 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()); @@ -188,6 +188,7 @@ void CMakeToolManager::registerCMakeByPath(const FilePath &cmakePath) auto newTool = std::make_unique(CMakeTool::ManualDetection, id); newTool->setFilePath(cmakePath); newTool->setDisplayName(cmakePath.toUserOutput()); + newTool->setDetectionSource(detectionSource); registerCMakeTool(std::move(newTool)); } diff --git a/src/plugins/cmakeprojectmanager/cmaketoolmanager.h b/src/plugins/cmakeprojectmanager/cmaketoolmanager.h index a8fb3a24329..2f71ddf34c4 100644 --- a/src/plugins/cmakeprojectmanager/cmaketoolmanager.h +++ b/src/plugins/cmakeprojectmanager/cmaketoolmanager.h @@ -63,7 +63,7 @@ public: static void updateDocumentation(); public slots: - void registerCMakeByPath(const Utils::FilePath &cmakePath); + void registerCMakeByPath(const Utils::FilePath &cmakePath, const QString &detectionSource); signals: void cmakeAdded (const Utils::Id &id); diff --git a/src/plugins/docker/dockerdevice.cpp b/src/plugins/docker/dockerdevice.cpp index 563a4b63aef..5510972443c 100644 --- a/src/plugins/docker/dockerdevice.cpp +++ b/src/plugins/docker/dockerdevice.cpp @@ -491,7 +491,8 @@ void DockerDevicePrivate::autoDetectCMake(QTextBrowser *log) log->append(tr("Found CMake binary: %1").arg(cmake.toUserOutput())); const bool res = QMetaObject::invokeMethod(cmakeManager, "registerCMakeByPath", - Q_ARG(Utils::FilePath, cmake)); + Q_ARG(Utils::FilePath, cmake), + Q_ARG(QString, m_data.id())); QTC_CHECK(res); } }