2022-12-09 18:44:42 +01:00
|
|
|
// Copyright (C) 2022 The Qt Company Ltd.
|
2022-12-21 10:12:09 +01:00
|
|
|
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
|
2022-12-09 18:44:42 +01:00
|
|
|
|
|
|
|
|
#include "cmakeinstallstep.h"
|
|
|
|
|
|
2022-12-19 16:17:36 +01:00
|
|
|
#include "cmakeabstractprocessstep.h"
|
2022-12-09 18:44:42 +01:00
|
|
|
#include "cmakebuildsystem.h"
|
|
|
|
|
#include "cmakekitinformation.h"
|
|
|
|
|
#include "cmakeparser.h"
|
|
|
|
|
#include "cmakeprojectconstants.h"
|
|
|
|
|
#include "cmakeprojectmanagertr.h"
|
|
|
|
|
#include "cmaketool.h"
|
|
|
|
|
|
|
|
|
|
#include <projectexplorer/buildsteplist.h>
|
|
|
|
|
#include <projectexplorer/processparameters.h>
|
|
|
|
|
#include <projectexplorer/project.h>
|
|
|
|
|
#include <projectexplorer/projectexplorer.h>
|
|
|
|
|
#include <projectexplorer/projectexplorerconstants.h>
|
2023-07-12 17:14:56 +02:00
|
|
|
|
2022-12-09 18:44:42 +01:00
|
|
|
#include <utils/layoutbuilder.h>
|
|
|
|
|
|
|
|
|
|
using namespace Core;
|
|
|
|
|
using namespace ProjectExplorer;
|
|
|
|
|
using namespace Utils;
|
|
|
|
|
|
|
|
|
|
namespace CMakeProjectManager::Internal {
|
|
|
|
|
|
|
|
|
|
// CMakeInstallStep
|
|
|
|
|
|
2022-12-19 16:17:36 +01:00
|
|
|
class CMakeInstallStep : public CMakeAbstractProcessStep
|
|
|
|
|
{
|
|
|
|
|
public:
|
2023-07-12 17:14:56 +02:00
|
|
|
CMakeInstallStep(BuildStepList *bsl, Id id)
|
|
|
|
|
: CMakeAbstractProcessStep(bsl, id)
|
|
|
|
|
{
|
|
|
|
|
cmakeArguments.setSettingsKey("CMakeProjectManager.InstallStep.CMakeArguments");
|
|
|
|
|
cmakeArguments.setLabelText(Tr::tr("CMake arguments:"));
|
|
|
|
|
cmakeArguments.setDisplayStyle(StringAspect::LineEditDisplay);
|
|
|
|
|
|
|
|
|
|
setCommandLineProvider([this] { return cmakeCommand(); });
|
|
|
|
|
}
|
2022-12-19 16:17:36 +01:00
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
CommandLine cmakeCommand() const;
|
|
|
|
|
|
|
|
|
|
void setupOutputFormatter(OutputFormatter *formatter) override;
|
|
|
|
|
QWidget *createConfigWidget() override;
|
|
|
|
|
|
2023-07-12 17:14:56 +02:00
|
|
|
StringAspect cmakeArguments{this};
|
2022-12-19 16:17:36 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
void CMakeInstallStep::setupOutputFormatter(OutputFormatter *formatter)
|
2022-12-09 18:44:42 +01:00
|
|
|
{
|
|
|
|
|
CMakeParser *cmakeParser = new CMakeParser;
|
|
|
|
|
cmakeParser->setSourceDirectory(project()->projectDirectory());
|
|
|
|
|
formatter->addLineParsers({cmakeParser});
|
|
|
|
|
formatter->addSearchDir(processParameters()->effectiveWorkingDirectory());
|
|
|
|
|
CMakeAbstractProcessStep::setupOutputFormatter(formatter);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
CommandLine CMakeInstallStep::cmakeCommand() const
|
|
|
|
|
{
|
|
|
|
|
CommandLine cmd;
|
|
|
|
|
if (CMakeTool *tool = CMakeKitAspect::cmakeTool(kit()))
|
|
|
|
|
cmd.setExecutable(tool->cmakeExecutable());
|
|
|
|
|
|
|
|
|
|
FilePath buildDirectory = ".";
|
|
|
|
|
if (buildConfiguration())
|
|
|
|
|
buildDirectory = buildConfiguration()->buildDirectory();
|
|
|
|
|
|
2023-04-04 10:39:20 +02:00
|
|
|
cmd.addArgs({"--install", buildDirectory.path()});
|
2022-12-09 18:44:42 +01:00
|
|
|
|
|
|
|
|
auto bs = qobject_cast<CMakeBuildSystem *>(buildSystem());
|
|
|
|
|
if (bs && bs->isMultiConfigReader()) {
|
|
|
|
|
cmd.addArg("--config");
|
|
|
|
|
cmd.addArg(bs->cmakeBuildType());
|
|
|
|
|
}
|
|
|
|
|
|
2023-07-12 17:14:56 +02:00
|
|
|
cmd.addArgs(cmakeArguments(), CommandLine::Raw);
|
2022-12-09 18:44:42 +01:00
|
|
|
|
|
|
|
|
return cmd;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QWidget *CMakeInstallStep::createConfigWidget()
|
|
|
|
|
{
|
|
|
|
|
auto updateDetails = [this] {
|
|
|
|
|
ProcessParameters param;
|
|
|
|
|
setupProcessParameters(¶m);
|
|
|
|
|
param.setCommandLine(cmakeCommand());
|
|
|
|
|
|
|
|
|
|
setSummaryText(param.summary(displayName()));
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
setDisplayName(Tr::tr("Install", "ConfigWidget display name."));
|
|
|
|
|
|
2023-05-03 16:09:01 +02:00
|
|
|
using namespace Layouting;
|
2023-07-12 17:14:56 +02:00
|
|
|
auto widget = Form { cmakeArguments, noMargin }.emerge();
|
2022-12-09 18:44:42 +01:00
|
|
|
|
|
|
|
|
updateDetails();
|
|
|
|
|
|
2023-07-12 17:14:56 +02:00
|
|
|
connect(&cmakeArguments, &StringAspect::changed, this, updateDetails);
|
2022-12-09 18:44:42 +01:00
|
|
|
|
|
|
|
|
connect(ProjectExplorerPlugin::instance(),
|
|
|
|
|
&ProjectExplorerPlugin::settingsChanged,
|
|
|
|
|
this,
|
|
|
|
|
updateDetails);
|
|
|
|
|
connect(buildConfiguration(), &BuildConfiguration::buildDirectoryChanged, this, updateDetails);
|
|
|
|
|
connect(buildConfiguration(), &BuildConfiguration::buildTypeChanged, this, updateDetails);
|
|
|
|
|
|
|
|
|
|
return widget;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// CMakeInstallStepFactory
|
|
|
|
|
|
|
|
|
|
CMakeInstallStepFactory::CMakeInstallStepFactory()
|
|
|
|
|
{
|
|
|
|
|
registerStep<CMakeInstallStep>(Constants::CMAKE_INSTALL_STEP_ID);
|
|
|
|
|
setDisplayName(
|
|
|
|
|
Tr::tr("CMake Install", "Display name for CMakeProjectManager::CMakeInstallStep id."));
|
|
|
|
|
setSupportedProjectType(Constants::CMAKE_PROJECT_ID);
|
|
|
|
|
setSupportedStepLists({ProjectExplorer::Constants::BUILDSTEPS_DEPLOY});
|
|
|
|
|
}
|
|
|
|
|
|
2022-12-19 16:17:36 +01:00
|
|
|
} // CMakeProjectManager::Internal
|
2022-12-09 18:44:42 +01:00
|
|
|
|