diff --git a/src/plugins/cmakeprojectmanager/cmakeprojectplugin.cpp b/src/plugins/cmakeprojectmanager/cmakeprojectplugin.cpp index 57f3a77380e..9aca653fc62 100644 --- a/src/plugins/cmakeprojectmanager/cmakeprojectplugin.cpp +++ b/src/plugins/cmakeprojectmanager/cmakeprojectplugin.cpp @@ -73,7 +73,6 @@ bool CMakeProjectPlugin::initialize(const QStringList & /*arguments*/, QString * addAutoReleasedObject(new CMakeLocatorFilter); new CMakeToolManager(this); - CMakeToolManager::restoreCMakeTools(); ProjectExplorer::KitManager::registerKitInformation(new CMakeKitInformation); @@ -82,4 +81,6 @@ bool CMakeProjectPlugin::initialize(const QStringList & /*arguments*/, QString * void CMakeProjectPlugin::extensionsInitialized() { + //restore the cmake tools before loading the kits + CMakeToolManager::restoreCMakeTools(); } diff --git a/src/plugins/cmakeprojectmanager/cmaketoolmanager.cpp b/src/plugins/cmakeprojectmanager/cmaketoolmanager.cpp index e3043db252f..b65febaec0e 100644 --- a/src/plugins/cmakeprojectmanager/cmaketoolmanager.cpp +++ b/src/plugins/cmakeprojectmanager/cmaketoolmanager.cpp @@ -31,6 +31,7 @@ #include "cmaketoolmanager.h" #include +#include #include #include #include @@ -42,6 +43,7 @@ using namespace Core; using namespace Utils; +using namespace ProjectExplorer; namespace CMakeProjectManager { @@ -65,6 +67,7 @@ public: Id m_defaultCMake; QList m_cmakeTools; PersistentSettingsWriter *m_writer; + QList m_autoDetectionHelpers; }; static CMakeToolManagerPrivate *d = 0; @@ -186,6 +189,10 @@ static QList autoDetectCMakeTools() found.append(item); } + //execute custom helpers if available + foreach (CMakeToolManager::AutodetectionHelper source, d->m_autoDetectionHelpers) + found.append(source()); + return found; } @@ -363,8 +370,8 @@ void CMakeToolManager::restoreCMakeTools() } //filter out the tools that are already known - for (int i = autoDetected.size() - 1; i >= 0; i--) { - CMakeTool *currTool = autoDetected.takeAt(i); + while (autoDetected.size()) { + CMakeTool *currTool = autoDetected.takeFirst(); if (Utils::anyOf(toolsToRegister, Utils::equal(&CMakeTool::cmakeExecutable, currTool->cmakeExecutable()))) delete currTool; @@ -390,6 +397,11 @@ void CMakeToolManager::restoreCMakeTools() readAndDeleteLegacyCMakeSettings(); } +void CMakeToolManager::registerAutodetectionHelper(CMakeToolManager::AutodetectionHelper helper) +{ + d->m_autoDetectionHelpers.append(helper); +} + void CMakeToolManager::notifyAboutUpdate(CMakeTool *tool) { if (!tool || !d->m_cmakeTools.contains(tool)) diff --git a/src/plugins/cmakeprojectmanager/cmaketoolmanager.h b/src/plugins/cmakeprojectmanager/cmaketoolmanager.h index be83fda4a61..23b75a88eb6 100644 --- a/src/plugins/cmakeprojectmanager/cmaketoolmanager.h +++ b/src/plugins/cmakeprojectmanager/cmaketoolmanager.h @@ -36,6 +36,7 @@ #include #include +#include #include @@ -45,6 +46,8 @@ class CMAKE_EXPORT CMakeToolManager : public QObject { Q_OBJECT public: + typedef std::function ()> AutodetectionHelper; + CMakeToolManager(QObject *parent); ~CMakeToolManager(); @@ -62,9 +65,10 @@ public: static void setDefaultCMakeTool(const Core::Id &id); static CMakeTool *findByCommand(const Utils::FileName &command); static CMakeTool *findById(const Core::Id &id); - static void restoreCMakeTools(); + static void registerAutodetectionHelper(AutodetectionHelper helper); static void notifyAboutUpdate(CMakeTool *); + static void restoreCMakeTools(); signals: void cmakeAdded (const Core::Id &id);