2012-10-02 09:12:39 +02:00
|
|
|
/****************************************************************************
|
2008-12-02 12:01:29 +01:00
|
|
|
**
|
2016-01-15 14:57:40 +01:00
|
|
|
** Copyright (C) 2016 The Qt Company Ltd.
|
|
|
|
|
** Contact: https://www.qt.io/licensing/
|
2008-12-02 12:01:29 +01:00
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
** This file is part of Qt Creator.
|
2008-12-02 12:01:29 +01:00
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
** Commercial License Usage
|
|
|
|
|
** Licensees holding valid commercial Qt licenses may use this file in
|
|
|
|
|
** accordance with the commercial license agreement provided with the
|
|
|
|
|
** Software or, alternatively, in accordance with the terms contained in
|
2016-01-15 14:57:40 +01:00
|
|
|
** a written agreement between you and The Qt Company. For licensing terms
|
|
|
|
|
** and conditions see https://www.qt.io/terms-conditions. For further
|
|
|
|
|
** information use the contact form at https://www.qt.io/contact-us.
|
2008-12-02 14:17:16 +01:00
|
|
|
**
|
2016-01-15 14:57:40 +01:00
|
|
|
** GNU General Public License Usage
|
|
|
|
|
** Alternatively, this file may be used under the terms of the GNU
|
|
|
|
|
** General Public License version 3 as published by the Free Software
|
|
|
|
|
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
|
|
|
|
|
** included in the packaging of this file. Please review the following
|
|
|
|
|
** information to ensure the GNU General Public License requirements will
|
|
|
|
|
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
|
2010-12-17 16:01:08 +01:00
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
****************************************************************************/
|
2008-12-02 14:09:21 +01:00
|
|
|
|
2008-12-02 12:01:29 +01:00
|
|
|
#include "cmakeprojectplugin.h"
|
2014-08-20 00:07:43 +02:00
|
|
|
|
|
|
|
|
#include "cmakeeditor.h"
|
2016-01-07 12:33:52 +01:00
|
|
|
#include "cmakebuildstep.h"
|
2016-11-14 15:18:25 +01:00
|
|
|
#include "cmakeproject.h"
|
|
|
|
|
#include "cmakeprojectconstants.h"
|
2008-12-02 14:09:21 +01:00
|
|
|
#include "cmakeprojectmanager.h"
|
2016-11-14 15:18:25 +01:00
|
|
|
#include "cmakeprojectnodes.h"
|
2012-04-24 15:49:09 +02:00
|
|
|
#include "cmakebuildconfiguration.h"
|
2008-12-09 14:13:29 +01:00
|
|
|
#include "cmakerunconfiguration.h"
|
2016-08-18 13:22:06 +02:00
|
|
|
#include "cmakesnippetprovider.h"
|
2010-03-30 12:11:32 +02:00
|
|
|
#include "cmakeprojectconstants.h"
|
2011-10-21 23:17:58 +02:00
|
|
|
#include "cmakelocatorfilter.h"
|
2014-09-12 13:02:40 +04:00
|
|
|
#include "cmakesettingspage.h"
|
2015-02-04 17:54:46 +01:00
|
|
|
#include "cmaketoolmanager.h"
|
2015-02-24 21:57:00 +01:00
|
|
|
#include "cmakekitinformation.h"
|
2008-12-02 14:09:21 +01:00
|
|
|
|
2016-11-14 15:18:25 +01:00
|
|
|
#include <coreplugin/actionmanager/actioncontainer.h>
|
|
|
|
|
#include <coreplugin/actionmanager/actionmanager.h>
|
2016-11-09 14:25:30 +01:00
|
|
|
#include <coreplugin/fileiconprovider.h>
|
2016-11-14 15:18:25 +01:00
|
|
|
|
2015-02-24 21:57:00 +01:00
|
|
|
#include <projectexplorer/kitmanager.h>
|
2016-11-14 15:18:25 +01:00
|
|
|
#include <projectexplorer/projecttree.h>
|
2008-12-02 14:09:21 +01:00
|
|
|
|
2016-11-09 14:25:30 +01:00
|
|
|
#include <utils/mimetypes/mimedatabase.h>
|
2016-11-14 15:18:25 +01:00
|
|
|
#include <utils/parameteraction.h>
|
2016-11-09 14:25:30 +01:00
|
|
|
|
2008-12-02 12:01:29 +01:00
|
|
|
using namespace CMakeProjectManager::Internal;
|
2016-11-14 15:18:25 +01:00
|
|
|
using namespace Core;
|
|
|
|
|
using namespace ProjectExplorer;
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2008-12-02 12:21:14 +01:00
|
|
|
bool CMakeProjectPlugin::initialize(const QStringList & /*arguments*/, QString *errorMessage)
|
2008-12-02 12:01:29 +01:00
|
|
|
{
|
2015-02-04 09:32:46 +01:00
|
|
|
Q_UNUSED(errorMessage)
|
2016-11-14 15:18:25 +01:00
|
|
|
const Context projectContext(Constants::PROJECTCONTEXT);
|
|
|
|
|
|
2015-02-04 09:32:46 +01:00
|
|
|
Utils::MimeDatabase::addMimeTypes(QLatin1String(":cmakeproject/CMakeProjectManager.mimetypes.xml"));
|
2014-10-01 22:39:47 +02:00
|
|
|
|
2016-11-09 14:25:30 +01:00
|
|
|
Core::FileIconProvider::registerIconOverlayForSuffix(Constants::FILEOVERLAY_CMAKE, "cmake");
|
|
|
|
|
Core::FileIconProvider::registerIconOverlayForFilename(Constants::FILEOVERLAY_CMAKE, "CMakeLists.txt");
|
|
|
|
|
|
2016-08-18 13:22:06 +02:00
|
|
|
addAutoReleasedObject(new Internal::CMakeSnippetProvider);
|
2015-02-04 17:54:46 +01:00
|
|
|
addAutoReleasedObject(new CMakeSettingsPage);
|
|
|
|
|
addAutoReleasedObject(new CMakeManager);
|
2016-01-07 12:33:52 +01:00
|
|
|
addAutoReleasedObject(new CMakeBuildStepFactory);
|
2010-01-19 13:41:02 +01:00
|
|
|
addAutoReleasedObject(new CMakeRunConfigurationFactory);
|
2012-04-24 15:49:09 +02:00
|
|
|
addAutoReleasedObject(new CMakeBuildConfigurationFactory);
|
2015-02-04 17:54:46 +01:00
|
|
|
addAutoReleasedObject(new CMakeEditorFactory);
|
2011-10-21 23:17:58 +02:00
|
|
|
addAutoReleasedObject(new CMakeLocatorFilter);
|
2015-02-04 17:54:46 +01:00
|
|
|
|
|
|
|
|
new CMakeToolManager(this);
|
2014-06-26 00:27:27 +02:00
|
|
|
|
2016-11-14 15:18:25 +01:00
|
|
|
KitManager::registerKitInformation(new CMakeKitInformation);
|
|
|
|
|
KitManager::registerKitInformation(new CMakeGeneratorKitInformation);
|
|
|
|
|
KitManager::registerKitInformation(new CMakeConfigurationKitInformation);
|
|
|
|
|
|
|
|
|
|
//menus
|
|
|
|
|
ActionContainer *msubproject =
|
|
|
|
|
ActionManager::actionContainer(ProjectExplorer::Constants::M_SUBPROJECTCONTEXT);
|
|
|
|
|
|
|
|
|
|
//register actions
|
|
|
|
|
Command *command = nullptr;
|
|
|
|
|
|
|
|
|
|
m_buildTargetContextAction = new Utils::ParameterAction(tr("Build"), tr("Build \"%1\""),
|
|
|
|
|
Utils::ParameterAction::AlwaysEnabled/*handled manually*/,
|
|
|
|
|
this);
|
|
|
|
|
command = ActionManager::registerAction(m_buildTargetContextAction, Constants::BUILD_TARGET_CONTEXTMENU, projectContext);
|
|
|
|
|
command->setAttribute(Command::CA_Hide);
|
|
|
|
|
command->setAttribute(Command::CA_UpdateText);
|
|
|
|
|
command->setDescription(m_buildTargetContextAction->text());
|
|
|
|
|
msubproject->addAction(command, ProjectExplorer::Constants::G_PROJECT_BUILD);
|
|
|
|
|
|
|
|
|
|
// Wire up context menu updates:
|
|
|
|
|
connect(ProjectTree::instance(), &ProjectTree::currentNodeChanged,
|
|
|
|
|
this, &CMakeProjectPlugin::updateContextActions);
|
2015-02-24 21:57:00 +01:00
|
|
|
|
2008-12-02 12:01:29 +01:00
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void CMakeProjectPlugin::extensionsInitialized()
|
|
|
|
|
{
|
2015-03-04 13:32:31 +01:00
|
|
|
//restore the cmake tools before loading the kits
|
|
|
|
|
CMakeToolManager::restoreCMakeTools();
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
2016-11-14 15:18:25 +01:00
|
|
|
|
|
|
|
|
void CMakeProjectPlugin::updateContextActions(ProjectExplorer::Node *node,
|
|
|
|
|
ProjectExplorer::Project *project)
|
|
|
|
|
{
|
|
|
|
|
CMakeTargetNode *targetNode = dynamic_cast<CMakeTargetNode *>(node);
|
|
|
|
|
CMakeProject *cmProject = dynamic_cast<CMakeProject *>(project);
|
|
|
|
|
|
|
|
|
|
// Build Target:
|
|
|
|
|
disconnect(m_buildTargetContextAction);
|
|
|
|
|
m_buildTargetContextAction->setParameter(targetNode ? targetNode->displayName() : QString());
|
|
|
|
|
m_buildTargetContextAction->setEnabled(targetNode);
|
|
|
|
|
m_buildTargetContextAction->setVisible(targetNode);
|
|
|
|
|
if (cmProject && targetNode) {
|
|
|
|
|
connect(m_buildTargetContextAction, &Utils::ParameterAction::triggered,
|
|
|
|
|
cmProject, [cmProject, targetNode]() { cmProject->buildCMakeTarget(targetNode->displayName()); });
|
|
|
|
|
}
|
|
|
|
|
}
|