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"
|
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>
|
2018-03-10 18:45:06 +01:00
|
|
|
#include <coreplugin/icore.h>
|
2019-03-13 12:22:44 +01:00
|
|
|
|
2015-02-24 21:57:00 +01:00
|
|
|
#include <projectexplorer/kitmanager.h>
|
2017-03-03 18:16:34 +01:00
|
|
|
#include <projectexplorer/projectmanager.h>
|
2016-11-14 15:18:25 +01:00
|
|
|
#include <projectexplorer/projecttree.h>
|
2019-03-13 12:22:44 +01:00
|
|
|
#include <projectexplorer/runcontrol.h>
|
2019-10-25 09:55:32 +02:00
|
|
|
#include <projectexplorer/target.h>
|
2019-03-13 12:22:44 +01:00
|
|
|
|
2017-04-24 15:52:04 +02:00
|
|
|
#include <texteditor/snippets/snippetprovider.h>
|
|
|
|
|
|
2016-11-14 15:18:25 +01:00
|
|
|
#include <utils/parameteraction.h>
|
2016-11-09 14:25:30 +01:00
|
|
|
|
2016-11-14 15:18:25 +01:00
|
|
|
using namespace Core;
|
|
|
|
|
using namespace ProjectExplorer;
|
2019-10-25 09:55:32 +02:00
|
|
|
using namespace Utils;
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2018-02-09 15:35:02 +01:00
|
|
|
namespace CMakeProjectManager {
|
|
|
|
|
namespace Internal {
|
|
|
|
|
|
|
|
|
|
class CMakeProjectPluginPrivate
|
|
|
|
|
{
|
|
|
|
|
public:
|
2019-03-19 15:36:07 +01:00
|
|
|
CMakeToolManager cmakeToolManager; // have that before the first CMakeKitAspect
|
|
|
|
|
|
2019-10-25 09:55:32 +02:00
|
|
|
ParameterAction buildTargetContextAction{
|
|
|
|
|
CMakeProjectPlugin::tr("Build"),
|
|
|
|
|
CMakeProjectPlugin:: tr("Build \"%1\""),
|
|
|
|
|
ParameterAction::AlwaysEnabled/*handled manually*/
|
|
|
|
|
};
|
|
|
|
|
|
2018-02-09 15:35:02 +01:00
|
|
|
CMakeSettingsPage settingsPage;
|
2019-10-25 09:55:32 +02:00
|
|
|
CMakeSpecificSettingsPage specificSettings{CMakeProjectPlugin::projectTypeSpecificSettings()};
|
|
|
|
|
|
2018-02-09 15:35:02 +01:00
|
|
|
CMakeManager manager;
|
|
|
|
|
CMakeBuildStepFactory buildStepFactory;
|
|
|
|
|
CMakeBuildConfigurationFactory buildConfigFactory;
|
|
|
|
|
CMakeEditorFactory editorFactor;
|
2019-07-24 14:49:27 +02:00
|
|
|
BuildCMakeTargetLocatorFilter buildCMakeTargetLocatorFilter;
|
|
|
|
|
OpenCMakeTargetLocatorFilter openCMakeTargetLocationFilter;
|
2019-03-14 09:17:59 +01:00
|
|
|
|
|
|
|
|
CMakeKitAspect cmakeKitAspect;
|
|
|
|
|
CMakeGeneratorKitAspect cmakeGeneratorKitAspect;
|
|
|
|
|
CMakeConfigurationKitAspect cmakeConfigurationKitAspect;
|
2018-02-09 15:35:02 +01:00
|
|
|
};
|
|
|
|
|
|
2018-03-10 18:45:06 +01:00
|
|
|
CMakeSpecificSettings *CMakeProjectPlugin::projectTypeSpecificSettings()
|
|
|
|
|
{
|
2019-10-25 09:55:32 +02:00
|
|
|
static CMakeSpecificSettings theSettings;
|
|
|
|
|
return &theSettings;
|
2018-03-10 18:45:06 +01:00
|
|
|
}
|
|
|
|
|
|
2018-02-09 15:35:02 +01:00
|
|
|
CMakeProjectPlugin::~CMakeProjectPlugin()
|
|
|
|
|
{
|
|
|
|
|
delete d;
|
|
|
|
|
}
|
|
|
|
|
|
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)
|
2018-02-09 15:35:02 +01:00
|
|
|
|
|
|
|
|
d = new CMakeProjectPluginPrivate;
|
2019-10-25 09:55:32 +02:00
|
|
|
projectTypeSpecificSettings()->fromSettings(ICore::settings());
|
2018-02-09 15:35:02 +01:00
|
|
|
|
2019-10-25 09:55:32 +02:00
|
|
|
const Context projectContext{CMakeProjectManager::Constants::CMAKEPROJECT_ID};
|
2016-11-14 15:18:25 +01:00
|
|
|
|
2019-10-25 09:55:32 +02:00
|
|
|
FileIconProvider::registerIconOverlayForSuffix(Constants::FILEOVERLAY_CMAKE, "cmake");
|
|
|
|
|
FileIconProvider::registerIconOverlayForFilename(Constants::FILEOVERLAY_CMAKE,
|
|
|
|
|
"CMakeLists.txt");
|
2016-11-09 14:25:30 +01:00
|
|
|
|
2017-04-24 15:52:04 +02:00
|
|
|
TextEditor::SnippetProvider::registerGroup(Constants::CMAKE_SNIPPETS_GROUP_ID,
|
|
|
|
|
tr("CMake", "SnippetProvider"));
|
2017-03-03 18:16:34 +01:00
|
|
|
ProjectManager::registerProjectType<CMakeProject>(Constants::CMAKEPROJECTMIMETYPE);
|
|
|
|
|
|
2016-11-14 15:18:25 +01:00
|
|
|
//register actions
|
2019-10-25 09:55:32 +02:00
|
|
|
Command *command = ActionManager::registerAction(&d->buildTargetContextAction,
|
|
|
|
|
Constants::BUILD_TARGET_CONTEXTMENU, projectContext);
|
2016-11-14 15:18:25 +01:00
|
|
|
command->setAttribute(Command::CA_Hide);
|
|
|
|
|
command->setAttribute(Command::CA_UpdateText);
|
2019-10-25 09:55:32 +02:00
|
|
|
command->setDescription(d->buildTargetContextAction.text());
|
|
|
|
|
|
|
|
|
|
ActionManager::actionContainer(ProjectExplorer::Constants::M_SUBPROJECTCONTEXT)
|
|
|
|
|
->addAction(command, ProjectExplorer::Constants::G_PROJECT_BUILD);
|
2016-11-14 15:18:25 +01:00
|
|
|
|
|
|
|
|
// Wire up context menu updates:
|
|
|
|
|
connect(ProjectTree::instance(), &ProjectTree::currentNodeChanged,
|
|
|
|
|
this, &CMakeProjectPlugin::updateContextActions);
|
2015-02-24 21:57:00 +01:00
|
|
|
|
2019-10-25 09:55:32 +02:00
|
|
|
connect(&d->buildTargetContextAction, &ParameterAction::triggered, this, [] {
|
|
|
|
|
if (auto bs = qobject_cast<CMakeBuildSystem *>(ProjectTree::currentBuildSystem())) {
|
|
|
|
|
auto targetNode = dynamic_cast<const CMakeTargetNode *>(ProjectTree::currentNode());
|
|
|
|
|
bs->buildCMakeTarget(targetNode ? targetNode->displayName() : QString());
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
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
|
|
|
|
2017-02-24 10:02:39 +01:00
|
|
|
void CMakeProjectPlugin::updateContextActions()
|
2016-11-14 15:18:25 +01:00
|
|
|
{
|
2019-10-25 09:55:32 +02:00
|
|
|
auto targetNode = dynamic_cast<const CMakeTargetNode *>(ProjectTree::currentNode());
|
2016-12-08 22:31:43 +01:00
|
|
|
const QString targetDisplayName = targetNode ? targetNode->displayName() : QString();
|
2016-11-14 15:18:25 +01:00
|
|
|
|
|
|
|
|
// Build Target:
|
2019-10-25 09:55:32 +02:00
|
|
|
d->buildTargetContextAction.setParameter(targetDisplayName);
|
|
|
|
|
d->buildTargetContextAction.setEnabled(targetNode);
|
|
|
|
|
d->buildTargetContextAction.setVisible(targetNode);
|
2016-11-14 15:18:25 +01:00
|
|
|
}
|
2018-02-09 15:35:02 +01:00
|
|
|
|
|
|
|
|
} // Internal
|
|
|
|
|
} // CMakeProjectManager
|
|
|
|
|
|