forked from qt-creator/qt-creator
CMake: Simplify CMakeTool registration in CMakeToolManager
Change-Id: Ida5e6aea8c39ef21f535e06c8fed11b130f875e9 Reviewed-by: Eike Ziller <eike.ziller@qt.io>
This commit is contained in:
@@ -242,11 +242,10 @@ QList<CMakeTool *> CMakeToolManager::cmakeTools()
|
|||||||
|
|
||||||
Id CMakeToolManager::registerOrFindCMakeTool(const FileName &command)
|
Id CMakeToolManager::registerOrFindCMakeTool(const FileName &command)
|
||||||
{
|
{
|
||||||
CMakeTool *cmake = findByCommand(command);
|
if (CMakeTool *cmake = findByCommand(command))
|
||||||
if (cmake)
|
|
||||||
return cmake->id();
|
return cmake->id();
|
||||||
|
|
||||||
cmake = new CMakeTool(CMakeTool::ManualDetection, CMakeTool::createId());
|
CMakeTool *cmake = new CMakeTool(CMakeTool::ManualDetection, CMakeTool::createId());
|
||||||
cmake->setCMakeExecutable(command);
|
cmake->setCMakeExecutable(command);
|
||||||
cmake->setDisplayName(tr("CMake at %1").arg(command.toUserOutput()));
|
cmake->setDisplayName(tr("CMake at %1").arg(command.toUserOutput()));
|
||||||
|
|
||||||
@@ -259,21 +258,21 @@ bool CMakeToolManager::registerCMakeTool(CMakeTool *tool)
|
|||||||
if (!tool || d->m_cmakeTools.contains(tool))
|
if (!tool || d->m_cmakeTools.contains(tool))
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
QTC_ASSERT(tool->id().isValid(),return false);
|
const Core::Id toolId = tool->id();
|
||||||
|
QTC_ASSERT(toolId.isValid(),return false);
|
||||||
|
|
||||||
//make sure the same id was not used before
|
//make sure the same id was not used before
|
||||||
foreach (CMakeTool *current, d->m_cmakeTools) {
|
QTC_ASSERT(!Utils::contains(d->m_cmakeTools, [toolId](const CMakeTool *known) {
|
||||||
if (tool->id() == current->id())
|
return toolId == known->id();
|
||||||
return false;
|
}), return false);
|
||||||
}
|
|
||||||
|
|
||||||
d->m_cmakeTools.append(tool);
|
d->m_cmakeTools.append(tool);
|
||||||
|
|
||||||
emit CMakeToolManager::m_instance->cmakeAdded(tool->id());
|
emit CMakeToolManager::m_instance->cmakeAdded(toolId);
|
||||||
|
|
||||||
//set the first registered cmake tool as default if there is not already one
|
//set the first registered cmake tool as default if there is not already one
|
||||||
if (!d->m_defaultCMake.isValid())
|
if (!d->m_defaultCMake.isValid())
|
||||||
CMakeToolManager::setDefaultCMakeTool(tool->id());
|
CMakeToolManager::setDefaultCMakeTool(toolId);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user