2012-10-02 09:12:39 +02:00
|
|
|
/****************************************************************************
|
2009-11-23 12:11:48 +01:00
|
|
|
**
|
2016-01-15 14:57:40 +01:00
|
|
|
** Copyright (C) 2016 The Qt Company Ltd.
|
|
|
|
|
** Contact: https://www.qt.io/licensing/
|
2009-11-23 12:11:48 +01:00
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
** This file is part of Qt Creator.
|
2009-11-23 12:11:48 +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.
|
2009-11-23 12:11:48 +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
|
|
|
****************************************************************************/
|
2009-11-23 12:11:48 +01:00
|
|
|
|
|
|
|
|
#include "cmakebuildconfiguration.h"
|
2010-01-07 18:17:24 +01:00
|
|
|
|
2021-02-12 16:15:26 +01:00
|
|
|
#include "cmakebuildconfiguration.h"
|
2016-01-07 12:33:52 +01:00
|
|
|
#include "cmakebuildstep.h"
|
2020-04-17 15:30:05 +02:00
|
|
|
#include "cmakebuildsystem.h"
|
2021-02-12 16:15:26 +01:00
|
|
|
#include "cmakeconfigitem.h"
|
2016-02-03 13:52:50 +01:00
|
|
|
#include "cmakekitinformation.h"
|
2012-10-02 17:46:19 +02:00
|
|
|
#include "cmakeprojectconstants.h"
|
2021-02-18 18:50:11 +01:00
|
|
|
#include "cmakeprojectplugin.h"
|
|
|
|
|
#include "cmakespecificsettings.h"
|
2021-02-12 16:15:26 +01:00
|
|
|
#include "configmodel.h"
|
|
|
|
|
#include "configmodelitemdelegate.h"
|
2010-01-07 18:17:24 +01:00
|
|
|
|
2019-03-06 14:17:17 +02:00
|
|
|
#include <android/androidconstants.h>
|
2021-02-02 16:10:45 +01:00
|
|
|
#include <ios/iosconstants.h>
|
2021-02-12 16:15:26 +01:00
|
|
|
|
|
|
|
|
#include <coreplugin/find/itemviewfind.h>
|
2021-03-19 13:09:49 +01:00
|
|
|
#include <coreplugin/icore.h>
|
2021-02-12 16:15:26 +01:00
|
|
|
|
2020-03-16 10:24:35 +01:00
|
|
|
#include <projectexplorer/buildaspects.h>
|
2019-01-29 16:51:17 +01:00
|
|
|
#include <projectexplorer/buildinfo.h>
|
2016-11-14 15:18:25 +01:00
|
|
|
#include <projectexplorer/buildmanager.h>
|
2010-07-16 14:00:41 +02:00
|
|
|
#include <projectexplorer/buildsteplist.h>
|
2019-01-07 12:15:40 +01:00
|
|
|
#include <projectexplorer/kitinformation.h>
|
2021-02-12 16:15:26 +01:00
|
|
|
#include <projectexplorer/namedwidget.h>
|
2016-11-14 15:18:25 +01:00
|
|
|
#include <projectexplorer/projectexplorer.h>
|
2021-02-12 16:15:26 +01:00
|
|
|
#include <projectexplorer/project.h>
|
2014-10-22 09:16:55 +02:00
|
|
|
#include <projectexplorer/projectmacroexpander.h>
|
2012-04-24 15:49:09 +02:00
|
|
|
#include <projectexplorer/target.h>
|
2020-06-17 06:35:31 +02:00
|
|
|
|
2019-10-18 09:25:14 +03:00
|
|
|
#include <qtsupport/baseqtversion.h>
|
2020-02-05 15:16:04 +01:00
|
|
|
#include <qtsupport/qtbuildaspects.h>
|
2019-08-07 10:10:01 +02:00
|
|
|
#include <qtsupport/qtkitinformation.h>
|
|
|
|
|
|
2021-02-12 16:15:26 +01:00
|
|
|
#include <utils/algorithm.h>
|
|
|
|
|
#include <utils/categorysortfiltermodel.h>
|
2021-03-19 13:09:49 +01:00
|
|
|
#include <utils/checkablemessagebox.h>
|
2021-02-12 16:15:26 +01:00
|
|
|
#include <utils/detailswidget.h>
|
|
|
|
|
#include <utils/headerviewstretcher.h>
|
|
|
|
|
#include <utils/infolabel.h>
|
|
|
|
|
#include <utils/itemviews.h>
|
|
|
|
|
#include <utils/layoutbuilder.h>
|
|
|
|
|
#include <utils/progressindicator.h>
|
2013-07-22 15:53:57 +02:00
|
|
|
#include <utils/qtcassert.h>
|
2020-06-17 06:35:31 +02:00
|
|
|
#include <utils/stringutils.h>
|
2021-02-24 14:33:38 +01:00
|
|
|
#include <utils/variablechooser.h>
|
2013-07-22 15:53:57 +02:00
|
|
|
|
2021-02-25 15:21:01 +01:00
|
|
|
#include <QApplication>
|
2021-02-12 16:15:26 +01:00
|
|
|
#include <QBoxLayout>
|
|
|
|
|
#include <QCheckBox>
|
2021-02-25 15:21:01 +01:00
|
|
|
#include <QClipboard>
|
2021-02-24 14:33:38 +01:00
|
|
|
#include <QDialog>
|
|
|
|
|
#include <QDialogButtonBox>
|
2020-03-24 11:01:40 +01:00
|
|
|
#include <QDir>
|
2021-02-12 16:15:26 +01:00
|
|
|
#include <QGridLayout>
|
2019-08-09 12:20:49 +02:00
|
|
|
#include <QLoggingCategory>
|
2021-02-12 16:15:26 +01:00
|
|
|
#include <QMenu>
|
2020-03-24 11:01:40 +01:00
|
|
|
#include <QMessageBox>
|
2021-02-24 14:33:38 +01:00
|
|
|
#include <QPlainTextEdit>
|
2021-02-12 16:15:26 +01:00
|
|
|
#include <QPushButton>
|
|
|
|
|
#include <QTimer>
|
2019-08-09 12:20:49 +02:00
|
|
|
|
2014-10-22 09:16:55 +02:00
|
|
|
using namespace ProjectExplorer;
|
|
|
|
|
using namespace Utils;
|
2021-02-04 14:53:42 +01:00
|
|
|
using namespace CMakeProjectManager::Internal;
|
2014-10-22 09:16:55 +02:00
|
|
|
|
|
|
|
|
namespace CMakeProjectManager {
|
2009-11-23 13:29:45 +01:00
|
|
|
|
2020-01-15 14:39:23 +01:00
|
|
|
static Q_LOGGING_CATEGORY(cmakeBuildConfigurationLog, "qtc.cmake.bc", QtWarningMsg);
|
2019-08-09 12:20:49 +02:00
|
|
|
|
2016-02-03 13:52:50 +01:00
|
|
|
const char CONFIGURATION_KEY[] = "CMake.Configuration";
|
2021-02-04 14:53:42 +01:00
|
|
|
const char DEVELOPMENT_TEAM_FLAG[] = "Ios:DevelopmentTeam:Flag";
|
|
|
|
|
const char PROVISIONING_PROFILE_FLAG[] = "Ios:ProvisioningProfile:Flag";
|
|
|
|
|
|
|
|
|
|
namespace Internal {
|
2014-10-22 09:16:55 +02:00
|
|
|
|
2021-02-12 16:15:26 +01:00
|
|
|
class CMakeBuildSettingsWidget : public NamedWidget
|
|
|
|
|
{
|
2021-03-19 10:46:11 +01:00
|
|
|
Q_DECLARE_TR_FUNCTIONS(CMakeProjectManager::Internal::CMakeBuildSettingsWidget)
|
|
|
|
|
|
2021-02-12 16:15:26 +01:00
|
|
|
public:
|
|
|
|
|
CMakeBuildSettingsWidget(CMakeBuildConfiguration *bc);
|
|
|
|
|
|
|
|
|
|
void setError(const QString &message);
|
|
|
|
|
void setWarning(const QString &message);
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
void updateButtonState();
|
|
|
|
|
void updateAdvancedCheckBox();
|
|
|
|
|
void updateFromKit();
|
|
|
|
|
CMakeProjectManager::CMakeConfig getQmlDebugCxxFlags();
|
2021-02-04 14:53:42 +01:00
|
|
|
CMakeProjectManager::CMakeConfig getSigningFlagsChanges();
|
2021-02-12 16:15:26 +01:00
|
|
|
|
|
|
|
|
void updateSelection();
|
|
|
|
|
void setVariableUnsetFlag(bool unsetFlag);
|
|
|
|
|
QAction *createForceAction(int type, const QModelIndex &idx);
|
|
|
|
|
|
|
|
|
|
bool eventFilter(QObject *target, QEvent *event) override;
|
|
|
|
|
|
2021-02-24 14:33:38 +01:00
|
|
|
void batchEditConfiguration();
|
|
|
|
|
|
2021-02-12 16:15:26 +01:00
|
|
|
CMakeBuildConfiguration *m_buildConfiguration;
|
|
|
|
|
QTreeView *m_configView;
|
|
|
|
|
ConfigModel *m_configModel;
|
|
|
|
|
CategorySortFilterModel *m_configFilterModel;
|
|
|
|
|
CategorySortFilterModel *m_configTextFilterModel;
|
|
|
|
|
ProgressIndicator *m_progressIndicator;
|
|
|
|
|
QPushButton *m_addButton;
|
|
|
|
|
QMenu *m_addButtonMenu;
|
|
|
|
|
QPushButton *m_editButton;
|
|
|
|
|
QPushButton *m_setButton;
|
|
|
|
|
QPushButton *m_unsetButton;
|
|
|
|
|
QPushButton *m_resetButton;
|
|
|
|
|
QPushButton *m_clearSelectionButton;
|
|
|
|
|
QCheckBox *m_showAdvancedCheckBox;
|
|
|
|
|
QPushButton *m_reconfigureButton;
|
|
|
|
|
QTimer m_showProgressTimer;
|
|
|
|
|
FancyLineEdit *m_filterEdit;
|
|
|
|
|
InfoLabel *m_warningMessageLabel;
|
2021-02-24 14:33:38 +01:00
|
|
|
|
|
|
|
|
QPushButton *m_batchEditButton = nullptr;
|
2021-02-12 16:15:26 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
static QModelIndex mapToSource(const QAbstractItemView *view, const QModelIndex &idx)
|
|
|
|
|
{
|
|
|
|
|
if (!idx.isValid())
|
|
|
|
|
return idx;
|
|
|
|
|
|
|
|
|
|
QAbstractItemModel *model = view->model();
|
|
|
|
|
QModelIndex result = idx;
|
|
|
|
|
while (auto proxy = qobject_cast<const QSortFilterProxyModel *>(model)) {
|
|
|
|
|
result = proxy->mapToSource(result);
|
|
|
|
|
model = proxy->sourceModel();
|
|
|
|
|
}
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
CMakeBuildSettingsWidget::CMakeBuildSettingsWidget(CMakeBuildConfiguration *bc) :
|
|
|
|
|
NamedWidget(tr("CMake")),
|
|
|
|
|
m_buildConfiguration(bc),
|
|
|
|
|
m_configModel(new ConfigModel(this)),
|
|
|
|
|
m_configFilterModel(new CategorySortFilterModel(this)),
|
|
|
|
|
m_configTextFilterModel(new CategorySortFilterModel(this))
|
|
|
|
|
{
|
|
|
|
|
QTC_CHECK(bc);
|
|
|
|
|
|
|
|
|
|
auto vbox = new QVBoxLayout(this);
|
|
|
|
|
vbox->setContentsMargins(0, 0, 0, 0);
|
|
|
|
|
auto container = new DetailsWidget;
|
|
|
|
|
container->setState(DetailsWidget::NoSummary);
|
|
|
|
|
vbox->addWidget(container);
|
|
|
|
|
|
|
|
|
|
auto details = new QWidget(container);
|
|
|
|
|
container->setWidget(details);
|
|
|
|
|
|
|
|
|
|
auto mainLayout = new QGridLayout(details);
|
|
|
|
|
mainLayout->setContentsMargins(0, 0, 0, 0);
|
|
|
|
|
mainLayout->setColumnStretch(1, 10);
|
|
|
|
|
|
|
|
|
|
int row = 0;
|
|
|
|
|
auto buildDirAspect = bc->buildDirectoryAspect();
|
|
|
|
|
connect(buildDirAspect, &BaseAspect::changed, this, [this]() {
|
|
|
|
|
m_configModel->flush(); // clear out config cache...;
|
|
|
|
|
});
|
|
|
|
|
auto initialCMakeAspect = bc->aspect<InitialCMakeArgumentsAspect>();
|
|
|
|
|
auto aspectWidget = new QWidget;
|
|
|
|
|
LayoutBuilder aspectWidgetBuilder(aspectWidget);
|
|
|
|
|
buildDirAspect->addToLayout(aspectWidgetBuilder);
|
|
|
|
|
aspectWidgetBuilder.finishRow();
|
|
|
|
|
initialCMakeAspect->addToLayout(aspectWidgetBuilder);
|
2021-03-18 14:20:02 +01:00
|
|
|
aspectWidgetBuilder.finishRow();
|
2021-03-19 13:09:49 +01:00
|
|
|
auto clearCMakeConfiguration = new QPushButton(tr("Re-configure with Initial Parameters"));
|
|
|
|
|
connect(clearCMakeConfiguration, &QPushButton::clicked, this, [bc]() {
|
|
|
|
|
auto *settings = CMakeProjectPlugin::projectTypeSpecificSettings();
|
|
|
|
|
bool doNotAsk{!settings->askBeforeReConfigureInitialParams()};
|
|
|
|
|
if (!doNotAsk) {
|
|
|
|
|
QDialogButtonBox::StandardButton reply = Utils::CheckableMessageBox::question(
|
|
|
|
|
nullptr,
|
|
|
|
|
tr("Re-configure with Initial Parameters"),
|
|
|
|
|
tr("Clear CMake configuration and configure with initial parameters?"),
|
|
|
|
|
tr("Do not ask again"),
|
|
|
|
|
&doNotAsk,
|
|
|
|
|
QDialogButtonBox::Yes | QDialogButtonBox::No,
|
|
|
|
|
QDialogButtonBox::Yes);
|
|
|
|
|
|
|
|
|
|
settings->setAskBeforeReConfigureInitialParams(!doNotAsk);
|
|
|
|
|
settings->toSettings(Core::ICore::settings());
|
|
|
|
|
|
|
|
|
|
if (reply != QDialogButtonBox::Yes) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
auto cbc = static_cast<CMakeBuildSystem*>(bc->buildSystem());
|
|
|
|
|
cbc->clearCMakeCache();
|
|
|
|
|
if (ProjectExplorerPlugin::saveModifiedFiles())
|
|
|
|
|
cbc->runCMake();
|
|
|
|
|
});
|
|
|
|
|
aspectWidgetBuilder.addItem(LayoutBuilder::LayoutItem(new QLabel("")));
|
|
|
|
|
aspectWidgetBuilder.addItem(LayoutBuilder::LayoutItem(clearCMakeConfiguration));
|
|
|
|
|
aspectWidgetBuilder.finishRow();
|
2021-03-18 14:20:02 +01:00
|
|
|
auto buildTypeAspect = bc->aspect<BuildTypeAspect>();
|
|
|
|
|
connect(buildTypeAspect, &BaseAspect::changed, this, [this, buildTypeAspect]() {
|
|
|
|
|
if (!m_buildConfiguration->isMultiConfig()) {
|
|
|
|
|
CMakeConfig config;
|
|
|
|
|
config << CMakeConfigItem("CMAKE_BUILD_TYPE", buildTypeAspect->value().toUtf8());
|
|
|
|
|
|
|
|
|
|
m_configModel->setBatchEditConfiguration(config);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
buildTypeAspect->addToLayout(aspectWidgetBuilder);
|
2021-02-12 16:15:26 +01:00
|
|
|
mainLayout->addWidget(aspectWidget, row, 0, 1, -1);
|
|
|
|
|
++row;
|
|
|
|
|
|
|
|
|
|
auto qmlDebugAspect = bc->aspect<QtSupport::QmlDebuggingAspect>();
|
|
|
|
|
connect(qmlDebugAspect, &QtSupport::QmlDebuggingAspect::changed, this, [this]() {
|
|
|
|
|
updateButtonState();
|
|
|
|
|
});
|
|
|
|
|
auto widget = new QWidget;
|
|
|
|
|
LayoutBuilder builder(widget);
|
|
|
|
|
qmlDebugAspect->addToLayout(builder);
|
|
|
|
|
mainLayout->addWidget(widget, row, 0, 1, -1);
|
|
|
|
|
|
|
|
|
|
++row;
|
|
|
|
|
mainLayout->addItem(new QSpacerItem(20, 10), row, 0);
|
|
|
|
|
|
|
|
|
|
++row;
|
|
|
|
|
m_warningMessageLabel = new InfoLabel({}, InfoLabel::Warning);
|
|
|
|
|
m_warningMessageLabel->setVisible(false);
|
|
|
|
|
mainLayout->addWidget(m_warningMessageLabel, row, 0, 1, -1, Qt::AlignHCenter);
|
|
|
|
|
|
|
|
|
|
++row;
|
|
|
|
|
mainLayout->addItem(new QSpacerItem(20, 10), row, 0);
|
|
|
|
|
|
|
|
|
|
++row;
|
|
|
|
|
m_filterEdit = new FancyLineEdit;
|
|
|
|
|
m_filterEdit->setPlaceholderText(tr("Filter"));
|
|
|
|
|
m_filterEdit->setFiltering(true);
|
|
|
|
|
mainLayout->addWidget(m_filterEdit, row, 0, 1, 2);
|
|
|
|
|
|
|
|
|
|
++row;
|
|
|
|
|
auto tree = new TreeView;
|
|
|
|
|
connect(tree, &TreeView::activated,
|
|
|
|
|
tree, [tree](const QModelIndex &idx) { tree->edit(idx); });
|
|
|
|
|
m_configView = tree;
|
|
|
|
|
|
|
|
|
|
m_configView->viewport()->installEventFilter(this);
|
|
|
|
|
|
|
|
|
|
m_configFilterModel->setSourceModel(m_configModel);
|
|
|
|
|
m_configFilterModel->setFilterKeyColumn(0);
|
|
|
|
|
m_configFilterModel->setFilterRole(ConfigModel::ItemIsAdvancedRole);
|
|
|
|
|
m_configFilterModel->setFilterFixedString("0");
|
|
|
|
|
|
|
|
|
|
m_configTextFilterModel->setSourceModel(m_configFilterModel);
|
|
|
|
|
m_configTextFilterModel->setSortRole(Qt::DisplayRole);
|
|
|
|
|
m_configTextFilterModel->setFilterKeyColumn(-1);
|
|
|
|
|
|
|
|
|
|
connect(m_configTextFilterModel, &QAbstractItemModel::layoutChanged, this, [this]() {
|
|
|
|
|
QModelIndex selectedIdx = m_configView->currentIndex();
|
|
|
|
|
if (selectedIdx.isValid())
|
|
|
|
|
m_configView->scrollTo(selectedIdx);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
m_configView->setModel(m_configTextFilterModel);
|
|
|
|
|
m_configView->setMinimumHeight(300);
|
|
|
|
|
m_configView->setUniformRowHeights(true);
|
|
|
|
|
m_configView->setSortingEnabled(true);
|
|
|
|
|
m_configView->sortByColumn(0, Qt::AscendingOrder);
|
|
|
|
|
auto stretcher = new HeaderViewStretcher(m_configView->header(), 0);
|
|
|
|
|
m_configView->setSelectionMode(QAbstractItemView::ExtendedSelection);
|
|
|
|
|
m_configView->setSelectionBehavior(QAbstractItemView::SelectItems);
|
|
|
|
|
m_configView->setFrameShape(QFrame::NoFrame);
|
|
|
|
|
m_configView->setItemDelegate(new ConfigModelItemDelegate(m_buildConfiguration->project()->projectDirectory(),
|
|
|
|
|
m_configView));
|
|
|
|
|
QFrame *findWrapper = Core::ItemViewFind::createSearchableWrapper(m_configView, Core::ItemViewFind::LightColored);
|
|
|
|
|
findWrapper->setFrameStyle(QFrame::StyledPanel);
|
|
|
|
|
|
|
|
|
|
m_progressIndicator = new ProgressIndicator(ProgressIndicatorSize::Large, findWrapper);
|
|
|
|
|
m_progressIndicator->attachToWidget(findWrapper);
|
|
|
|
|
m_progressIndicator->raise();
|
|
|
|
|
m_progressIndicator->hide();
|
|
|
|
|
m_showProgressTimer.setSingleShot(true);
|
|
|
|
|
m_showProgressTimer.setInterval(50); // don't show progress for < 50ms tasks
|
|
|
|
|
connect(&m_showProgressTimer, &QTimer::timeout, [this]() { m_progressIndicator->show(); });
|
|
|
|
|
|
|
|
|
|
mainLayout->addWidget(findWrapper, row, 0, 1, 2);
|
|
|
|
|
|
|
|
|
|
auto buttonLayout = new QVBoxLayout;
|
|
|
|
|
m_addButton = new QPushButton(tr("&Add"));
|
|
|
|
|
m_addButton->setToolTip(tr("Add a new configuration value."));
|
|
|
|
|
buttonLayout->addWidget(m_addButton);
|
|
|
|
|
{
|
|
|
|
|
m_addButtonMenu = new QMenu(this);
|
|
|
|
|
m_addButtonMenu->addAction(tr("&Boolean"))->setData(
|
|
|
|
|
QVariant::fromValue(static_cast<int>(ConfigModel::DataItem::BOOLEAN)));
|
|
|
|
|
m_addButtonMenu->addAction(tr("&String"))->setData(
|
|
|
|
|
QVariant::fromValue(static_cast<int>(ConfigModel::DataItem::STRING)));
|
|
|
|
|
m_addButtonMenu->addAction(tr("&Directory"))->setData(
|
|
|
|
|
QVariant::fromValue(static_cast<int>(ConfigModel::DataItem::DIRECTORY)));
|
|
|
|
|
m_addButtonMenu->addAction(tr("&File"))->setData(
|
|
|
|
|
QVariant::fromValue(static_cast<int>(ConfigModel::DataItem::FILE)));
|
|
|
|
|
m_addButton->setMenu(m_addButtonMenu);
|
|
|
|
|
}
|
|
|
|
|
m_editButton = new QPushButton(tr("&Edit"));
|
|
|
|
|
m_editButton->setToolTip(tr("Edit the current CMake configuration value."));
|
|
|
|
|
buttonLayout->addWidget(m_editButton);
|
|
|
|
|
m_setButton = new QPushButton(tr("&Set"));
|
|
|
|
|
m_setButton->setToolTip(tr("Set a value in the CMake configuration."));
|
|
|
|
|
buttonLayout->addWidget(m_setButton);
|
|
|
|
|
m_unsetButton = new QPushButton(tr("&Unset"));
|
|
|
|
|
m_unsetButton->setToolTip(tr("Unset a value in the CMake configuration."));
|
|
|
|
|
buttonLayout->addWidget(m_unsetButton);
|
|
|
|
|
m_resetButton = new QPushButton(tr("&Reset"));
|
|
|
|
|
m_resetButton->setToolTip(tr("Reset all unapplied changes."));
|
|
|
|
|
m_resetButton->setEnabled(false);
|
|
|
|
|
m_clearSelectionButton = new QPushButton(tr("Clear Selection"));
|
|
|
|
|
m_clearSelectionButton->setToolTip(tr("Clear selection."));
|
|
|
|
|
m_clearSelectionButton->setEnabled(false);
|
|
|
|
|
buttonLayout->addWidget(m_clearSelectionButton);
|
|
|
|
|
buttonLayout->addWidget(m_resetButton);
|
2021-02-24 14:33:38 +01:00
|
|
|
m_batchEditButton = new QPushButton(tr("Batch Edit..."));
|
|
|
|
|
m_batchEditButton->setToolTip(tr("Set or reset multiple values in the CMake Configuration."));
|
|
|
|
|
buttonLayout->addWidget(m_batchEditButton);
|
2021-02-12 16:15:26 +01:00
|
|
|
buttonLayout->addItem(new QSpacerItem(10, 10, QSizePolicy::Fixed, QSizePolicy::Fixed));
|
|
|
|
|
m_showAdvancedCheckBox = new QCheckBox(tr("Advanced"));
|
|
|
|
|
buttonLayout->addWidget(m_showAdvancedCheckBox);
|
|
|
|
|
buttonLayout->addItem(new QSpacerItem(10, 10, QSizePolicy::Minimum, QSizePolicy::Expanding));
|
|
|
|
|
|
|
|
|
|
mainLayout->addLayout(buttonLayout, row, 2);
|
|
|
|
|
|
|
|
|
|
connect(m_configView->selectionModel(), &QItemSelectionModel::selectionChanged,
|
|
|
|
|
this, [this](const QItemSelection &, const QItemSelection &) {
|
|
|
|
|
updateSelection();
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
++row;
|
|
|
|
|
m_reconfigureButton = new QPushButton(tr("Apply Configuration Changes"));
|
|
|
|
|
m_reconfigureButton->setEnabled(false);
|
|
|
|
|
mainLayout->addWidget(m_reconfigureButton, row, 0, 1, 3);
|
|
|
|
|
|
|
|
|
|
updateAdvancedCheckBox();
|
|
|
|
|
setError(bc->error());
|
|
|
|
|
setWarning(bc->warning());
|
|
|
|
|
|
|
|
|
|
connect(bc->buildSystem(), &BuildSystem::parsingStarted, this, [this] {
|
|
|
|
|
updateButtonState();
|
|
|
|
|
m_configView->setEnabled(false);
|
|
|
|
|
m_showProgressTimer.start();
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
if (bc->buildSystem()->isParsing())
|
|
|
|
|
m_showProgressTimer.start();
|
|
|
|
|
else {
|
|
|
|
|
m_configModel->setConfiguration(m_buildConfiguration->configurationFromCMake());
|
|
|
|
|
m_configView->expandAll();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
connect(bc->target(), &Target::parsingFinished, this, [this, stretcher] {
|
|
|
|
|
m_configModel->setConfiguration(m_buildConfiguration->configurationFromCMake());
|
|
|
|
|
m_configView->expandAll();
|
|
|
|
|
m_configView->setEnabled(true);
|
|
|
|
|
stretcher->stretch();
|
|
|
|
|
updateButtonState();
|
|
|
|
|
m_showProgressTimer.stop();
|
|
|
|
|
m_progressIndicator->hide();
|
|
|
|
|
});
|
|
|
|
|
connect(m_buildConfiguration, &CMakeBuildConfiguration::errorOccurred,
|
|
|
|
|
this, [this]() {
|
|
|
|
|
m_showProgressTimer.stop();
|
|
|
|
|
m_progressIndicator->hide();
|
|
|
|
|
});
|
|
|
|
|
connect(m_configTextFilterModel, &QAbstractItemModel::modelReset, this, [this, stretcher]() {
|
|
|
|
|
m_configView->expandAll();
|
|
|
|
|
stretcher->stretch();
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
connect(m_configModel, &QAbstractItemModel::dataChanged,
|
|
|
|
|
this, &CMakeBuildSettingsWidget::updateButtonState);
|
|
|
|
|
connect(m_configModel, &QAbstractItemModel::modelReset,
|
|
|
|
|
this, &CMakeBuildSettingsWidget::updateButtonState);
|
|
|
|
|
|
2021-02-04 14:53:42 +01:00
|
|
|
connect(m_buildConfiguration,
|
|
|
|
|
&CMakeBuildConfiguration::signingFlagsChanged,
|
|
|
|
|
this,
|
|
|
|
|
&CMakeBuildSettingsWidget::updateButtonState);
|
|
|
|
|
|
2021-02-12 16:15:26 +01:00
|
|
|
connect(m_showAdvancedCheckBox, &QCheckBox::stateChanged,
|
|
|
|
|
this, &CMakeBuildSettingsWidget::updateAdvancedCheckBox);
|
|
|
|
|
|
|
|
|
|
connect(m_filterEdit,
|
|
|
|
|
&QLineEdit::textChanged,
|
|
|
|
|
m_configTextFilterModel,
|
|
|
|
|
[this](const QString &txt) {
|
|
|
|
|
m_configTextFilterModel->setFilterRegularExpression(
|
|
|
|
|
QRegularExpression(QRegularExpression::escape(txt),
|
|
|
|
|
QRegularExpression::CaseInsensitiveOption));
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
connect(m_resetButton, &QPushButton::clicked, m_configModel, &ConfigModel::resetAllChanges);
|
|
|
|
|
connect(m_reconfigureButton,
|
|
|
|
|
&QPushButton::clicked,
|
|
|
|
|
m_buildConfiguration,
|
|
|
|
|
&CMakeBuildConfiguration::runCMakeWithExtraArguments);
|
|
|
|
|
connect(m_setButton, &QPushButton::clicked, this, [this]() {
|
|
|
|
|
setVariableUnsetFlag(false);
|
|
|
|
|
});
|
|
|
|
|
connect(m_unsetButton, &QPushButton::clicked, this, [this]() {
|
|
|
|
|
setVariableUnsetFlag(true);
|
|
|
|
|
});
|
|
|
|
|
connect(m_editButton, &QPushButton::clicked, this, [this]() {
|
|
|
|
|
QModelIndex idx = m_configView->currentIndex();
|
|
|
|
|
if (idx.column() != 1)
|
|
|
|
|
idx = idx.sibling(idx.row(), 1);
|
|
|
|
|
m_configView->setCurrentIndex(idx);
|
|
|
|
|
m_configView->edit(idx);
|
|
|
|
|
});
|
|
|
|
|
connect(m_clearSelectionButton, &QPushButton::clicked, this, [this]() {
|
|
|
|
|
m_configView->selectionModel()->clear();
|
|
|
|
|
});
|
|
|
|
|
connect(m_addButtonMenu, &QMenu::triggered, this, [this](QAction *action) {
|
|
|
|
|
ConfigModel::DataItem::Type type =
|
|
|
|
|
static_cast<ConfigModel::DataItem::Type>(action->data().value<int>());
|
|
|
|
|
QString value = tr("<UNSET>");
|
|
|
|
|
if (type == ConfigModel::DataItem::BOOLEAN)
|
|
|
|
|
value = QString::fromLatin1("OFF");
|
|
|
|
|
|
|
|
|
|
m_configModel->appendConfiguration(tr("<UNSET>"), value, type);
|
|
|
|
|
const TreeItem *item = m_configModel->findNonRootItem([&value, type](TreeItem *item) {
|
|
|
|
|
ConfigModel::DataItem dataItem = ConfigModel::dataItemFromIndex(item->index());
|
|
|
|
|
return dataItem.key == tr("<UNSET>") && dataItem.type == type && dataItem.value == value;
|
|
|
|
|
});
|
|
|
|
|
QModelIndex idx = m_configModel->indexForItem(item);
|
|
|
|
|
idx = m_configTextFilterModel->mapFromSource(m_configFilterModel->mapFromSource(idx));
|
|
|
|
|
m_configView->setFocus();
|
|
|
|
|
m_configView->scrollTo(idx);
|
|
|
|
|
m_configView->setCurrentIndex(idx);
|
|
|
|
|
m_configView->edit(idx);
|
|
|
|
|
});
|
2021-02-24 14:33:38 +01:00
|
|
|
connect(m_batchEditButton, &QAbstractButton::clicked,
|
|
|
|
|
this, &CMakeBuildSettingsWidget::batchEditConfiguration);
|
2021-02-12 16:15:26 +01:00
|
|
|
|
|
|
|
|
connect(bc, &CMakeBuildConfiguration::errorOccurred, this, &CMakeBuildSettingsWidget::setError);
|
|
|
|
|
connect(bc, &CMakeBuildConfiguration::warningOccurred, this, &CMakeBuildSettingsWidget::setWarning);
|
|
|
|
|
|
|
|
|
|
updateFromKit();
|
|
|
|
|
connect(m_buildConfiguration->target(), &Target::kitChanged,
|
|
|
|
|
this, &CMakeBuildSettingsWidget::updateFromKit);
|
|
|
|
|
connect(m_buildConfiguration, &CMakeBuildConfiguration::enabledChanged,
|
|
|
|
|
this, [this]() {
|
2021-03-22 11:56:38 +01:00
|
|
|
if (m_buildConfiguration->isEnabled())
|
|
|
|
|
setError(QString());
|
2021-02-12 16:15:26 +01:00
|
|
|
});
|
|
|
|
|
|
|
|
|
|
updateSelection();
|
|
|
|
|
}
|
|
|
|
|
|
2021-02-24 14:33:38 +01:00
|
|
|
|
|
|
|
|
void CMakeBuildSettingsWidget::batchEditConfiguration()
|
|
|
|
|
{
|
|
|
|
|
auto dialog = new QDialog(this);
|
|
|
|
|
dialog->setWindowTitle(tr("Edit CMake Configuration"));
|
|
|
|
|
dialog->setAttribute(Qt::WA_DeleteOnClose);
|
|
|
|
|
dialog->setModal(true);
|
|
|
|
|
auto layout = new QVBoxLayout(dialog);
|
|
|
|
|
auto editor = new QPlainTextEdit(dialog);
|
|
|
|
|
|
|
|
|
|
auto label = new QLabel(dialog);
|
|
|
|
|
label->setText(tr("Enter one CMake variable per line.\n"
|
|
|
|
|
"To set or change a variable, use -D<variable>:<type>=<value>.\n"
|
|
|
|
|
"<type> can have one of the following values: FILEPATH, PATH, BOOL, INTERNAL, or STRING.\n"
|
|
|
|
|
"To unset a variable, use -U<variable>.\n"));
|
|
|
|
|
editor->setMinimumSize(800, 200);
|
|
|
|
|
|
|
|
|
|
auto chooser = new Utils::VariableChooser(dialog);
|
|
|
|
|
chooser->addSupportedWidget(editor);
|
|
|
|
|
chooser->addMacroExpanderProvider([this]() { return m_buildConfiguration->macroExpander(); });
|
|
|
|
|
|
|
|
|
|
auto buttons = new QDialogButtonBox(QDialogButtonBox::Ok|QDialogButtonBox::Cancel);
|
|
|
|
|
|
|
|
|
|
layout->addWidget(editor);
|
|
|
|
|
layout->addWidget(label);
|
|
|
|
|
layout->addWidget(buttons);
|
|
|
|
|
|
|
|
|
|
connect(buttons, &QDialogButtonBox::accepted, dialog, &QDialog::accept);
|
|
|
|
|
connect(buttons, &QDialogButtonBox::rejected, dialog, &QDialog::reject);
|
|
|
|
|
connect(dialog, &QDialog::accepted, this, [=]{
|
2021-03-01 20:18:08 +01:00
|
|
|
const auto expander = m_buildConfiguration->macroExpander();
|
|
|
|
|
|
|
|
|
|
const QStringList lines = editor->toPlainText().split('\n', Qt::SkipEmptyParts);
|
|
|
|
|
const QStringList expandedLines = Utils::transform(lines,
|
|
|
|
|
[expander](const QString &s) {
|
|
|
|
|
return expander->expand(s);
|
|
|
|
|
});
|
|
|
|
|
const CMakeConfig config = CMakeConfigItem::itemsFromArguments(expandedLines);
|
2021-02-24 14:33:38 +01:00
|
|
|
|
|
|
|
|
m_configModel->setBatchEditConfiguration(config);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
editor->setPlainText(m_buildConfiguration->configurationChangesArguments().join('\n'));
|
|
|
|
|
|
|
|
|
|
dialog->show();
|
|
|
|
|
}
|
|
|
|
|
|
2021-02-12 16:15:26 +01:00
|
|
|
void CMakeBuildSettingsWidget::setError(const QString &message)
|
|
|
|
|
{
|
|
|
|
|
m_buildConfiguration->buildDirectoryAspect()->setProblem(message);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void CMakeBuildSettingsWidget::setWarning(const QString &message)
|
|
|
|
|
{
|
|
|
|
|
bool showWarning = !message.isEmpty();
|
|
|
|
|
m_warningMessageLabel->setVisible(showWarning);
|
|
|
|
|
m_warningMessageLabel->setText(message);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void CMakeBuildSettingsWidget::updateButtonState()
|
|
|
|
|
{
|
|
|
|
|
const bool isParsing = m_buildConfiguration->buildSystem()->isParsing();
|
|
|
|
|
|
|
|
|
|
// Update extra data in buildconfiguration
|
|
|
|
|
const QList<ConfigModel::DataItem> changes = m_configModel->configurationForCMake();
|
|
|
|
|
|
|
|
|
|
const CMakeConfig configChanges
|
2021-02-04 14:53:42 +01:00
|
|
|
= getQmlDebugCxxFlags() + getSigningFlagsChanges()
|
|
|
|
|
+ Utils::transform(changes, [](const ConfigModel::DataItem &i) {
|
|
|
|
|
CMakeConfigItem ni;
|
|
|
|
|
ni.key = i.key.toUtf8();
|
|
|
|
|
ni.value = i.value.toUtf8();
|
|
|
|
|
ni.documentation = i.description.toUtf8();
|
|
|
|
|
ni.isAdvanced = i.isAdvanced;
|
|
|
|
|
ni.isUnset = i.isUnset;
|
|
|
|
|
ni.inCMakeCache = i.inCMakeCache;
|
|
|
|
|
ni.values = i.values;
|
|
|
|
|
switch (i.type) {
|
|
|
|
|
case CMakeProjectManager::ConfigModel::DataItem::BOOLEAN:
|
|
|
|
|
ni.type = CMakeConfigItem::BOOL;
|
|
|
|
|
break;
|
|
|
|
|
case CMakeProjectManager::ConfigModel::DataItem::FILE:
|
|
|
|
|
ni.type = CMakeConfigItem::FILEPATH;
|
|
|
|
|
break;
|
|
|
|
|
case CMakeProjectManager::ConfigModel::DataItem::DIRECTORY:
|
|
|
|
|
ni.type = CMakeConfigItem::PATH;
|
|
|
|
|
break;
|
|
|
|
|
case CMakeProjectManager::ConfigModel::DataItem::STRING:
|
|
|
|
|
ni.type = CMakeConfigItem::STRING;
|
|
|
|
|
break;
|
|
|
|
|
case CMakeProjectManager::ConfigModel::DataItem::UNKNOWN:
|
|
|
|
|
default:
|
2021-03-03 18:07:56 +01:00
|
|
|
ni.type = CMakeConfigItem::UNINITIALIZED;
|
2021-02-04 14:53:42 +01:00
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
return ni;
|
|
|
|
|
});
|
2021-02-12 16:15:26 +01:00
|
|
|
|
|
|
|
|
m_resetButton->setEnabled(m_configModel->hasChanges() && !isParsing);
|
2021-03-01 19:27:08 +01:00
|
|
|
m_reconfigureButton->setEnabled(!configChanges.isEmpty() && !isParsing);
|
2021-02-04 16:22:40 +01:00
|
|
|
m_buildConfiguration->setConfigurationChanges(configChanges);
|
2021-02-12 16:15:26 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void CMakeBuildSettingsWidget::updateAdvancedCheckBox()
|
|
|
|
|
{
|
|
|
|
|
if (m_showAdvancedCheckBox->isChecked()) {
|
|
|
|
|
m_configFilterModel->setSourceModel(nullptr);
|
|
|
|
|
m_configTextFilterModel->setSourceModel(m_configModel);
|
|
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
m_configTextFilterModel->setSourceModel(nullptr);
|
|
|
|
|
m_configFilterModel->setSourceModel(m_configModel);
|
|
|
|
|
m_configTextFilterModel->setSourceModel(m_configFilterModel);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void CMakeBuildSettingsWidget::updateFromKit()
|
|
|
|
|
{
|
|
|
|
|
const Kit *k = m_buildConfiguration->kit();
|
|
|
|
|
const CMakeConfig config = CMakeConfigurationKitAspect::configuration(k);
|
|
|
|
|
|
|
|
|
|
QHash<QString, QString> configHash;
|
|
|
|
|
for (const CMakeConfigItem &i : config)
|
|
|
|
|
configHash.insert(QString::fromUtf8(i.key), i.expandedValue(k));
|
|
|
|
|
|
|
|
|
|
m_configModel->setConfigurationFromKit(configHash);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
CMakeConfig CMakeBuildSettingsWidget::getQmlDebugCxxFlags()
|
|
|
|
|
{
|
|
|
|
|
const auto aspect = m_buildConfiguration->aspect<QtSupport::QmlDebuggingAspect>();
|
2021-02-22 07:41:51 +01:00
|
|
|
const TriState qmlDebuggingState = aspect->value();
|
2021-02-12 16:15:26 +01:00
|
|
|
if (qmlDebuggingState == TriState::Default) // don't touch anything
|
|
|
|
|
return {};
|
2021-02-22 07:41:51 +01:00
|
|
|
const bool enable = aspect->value() == TriState::Enabled;
|
2021-02-12 16:15:26 +01:00
|
|
|
|
|
|
|
|
const CMakeConfig configList = m_buildConfiguration->configurationFromCMake();
|
|
|
|
|
const QByteArrayList cxxFlags{"CMAKE_CXX_FLAGS", "CMAKE_CXX_FLAGS_DEBUG",
|
|
|
|
|
"CMAKE_CXX_FLAGS_RELWITHDEBINFO"};
|
|
|
|
|
const QByteArray qmlDebug("-DQT_QML_DEBUG");
|
|
|
|
|
|
|
|
|
|
CMakeConfig changedConfig;
|
|
|
|
|
|
|
|
|
|
for (const CMakeConfigItem &item : configList) {
|
|
|
|
|
if (!cxxFlags.contains(item.key))
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
|
|
CMakeConfigItem it(item);
|
|
|
|
|
if (enable) {
|
|
|
|
|
if (!it.value.contains(qmlDebug)) {
|
|
|
|
|
it.value = it.value.append(' ').append(qmlDebug).trimmed();
|
|
|
|
|
changedConfig.append(it);
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
int index = it.value.indexOf(qmlDebug);
|
|
|
|
|
if (index != -1) {
|
|
|
|
|
it.value.remove(index, qmlDebug.length());
|
|
|
|
|
it.value = it.value.trimmed();
|
|
|
|
|
changedConfig.append(it);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return changedConfig;
|
|
|
|
|
}
|
|
|
|
|
|
2021-02-04 14:53:42 +01:00
|
|
|
CMakeConfig CMakeBuildSettingsWidget::getSigningFlagsChanges()
|
|
|
|
|
{
|
|
|
|
|
const CMakeConfig flags = m_buildConfiguration->signingFlags();
|
|
|
|
|
if (flags.isEmpty())
|
|
|
|
|
return {};
|
|
|
|
|
const CMakeConfig configList = m_buildConfiguration->configurationFromCMake();
|
|
|
|
|
if (configList.isEmpty()) {
|
|
|
|
|
// we don't have any configuration --> initial configuration takes care of this itself
|
|
|
|
|
return {};
|
|
|
|
|
}
|
|
|
|
|
CMakeConfig changedConfig;
|
|
|
|
|
for (const CMakeConfigItem &signingFlag : flags) {
|
|
|
|
|
const CMakeConfigItem existingFlag = Utils::findOrDefault(configList,
|
|
|
|
|
Utils::equal(&CMakeConfigItem::key,
|
|
|
|
|
signingFlag.key));
|
|
|
|
|
const bool notInConfig = existingFlag.key.isEmpty();
|
|
|
|
|
if (notInConfig != signingFlag.isUnset || existingFlag.value != signingFlag.value)
|
|
|
|
|
changedConfig.append(signingFlag);
|
|
|
|
|
}
|
|
|
|
|
return changedConfig;
|
|
|
|
|
}
|
|
|
|
|
|
2021-02-12 16:15:26 +01:00
|
|
|
void CMakeBuildSettingsWidget::updateSelection()
|
|
|
|
|
{
|
|
|
|
|
const QModelIndexList selectedIndexes = m_configView->selectionModel()->selectedIndexes();
|
|
|
|
|
unsigned int setableCount = 0;
|
|
|
|
|
unsigned int unsetableCount = 0;
|
|
|
|
|
unsigned int editableCount = 0;
|
|
|
|
|
|
|
|
|
|
for (const QModelIndex &index : selectedIndexes) {
|
|
|
|
|
if (index.isValid() && index.flags().testFlag(Qt::ItemIsSelectable)) {
|
|
|
|
|
const ConfigModel::DataItem di = ConfigModel::dataItemFromIndex(index);
|
|
|
|
|
if (di.isUnset)
|
|
|
|
|
setableCount++;
|
|
|
|
|
else
|
|
|
|
|
unsetableCount++;
|
|
|
|
|
}
|
|
|
|
|
if (index.isValid() && index.flags().testFlag(Qt::ItemIsEditable))
|
|
|
|
|
editableCount++;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
m_clearSelectionButton->setEnabled(!selectedIndexes.isEmpty());
|
|
|
|
|
m_setButton->setEnabled(setableCount > 0);
|
|
|
|
|
m_unsetButton->setEnabled(unsetableCount > 0);
|
|
|
|
|
m_editButton->setEnabled(editableCount == 1);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void CMakeBuildSettingsWidget::setVariableUnsetFlag(bool unsetFlag)
|
|
|
|
|
{
|
|
|
|
|
const QModelIndexList selectedIndexes = m_configView->selectionModel()->selectedIndexes();
|
|
|
|
|
bool unsetFlagToggled = false;
|
|
|
|
|
for (const QModelIndex &index : selectedIndexes) {
|
|
|
|
|
if (index.isValid()) {
|
|
|
|
|
const ConfigModel::DataItem di = ConfigModel::dataItemFromIndex(index);
|
|
|
|
|
if (di.isUnset != unsetFlag) {
|
|
|
|
|
m_configModel->toggleUnsetFlag(mapToSource(m_configView, index));
|
|
|
|
|
unsetFlagToggled = true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (unsetFlagToggled)
|
|
|
|
|
updateSelection();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QAction *CMakeBuildSettingsWidget::createForceAction(int type, const QModelIndex &idx)
|
|
|
|
|
{
|
|
|
|
|
auto t = static_cast<ConfigModel::DataItem::Type>(type);
|
|
|
|
|
QString typeString;
|
|
|
|
|
switch (type) {
|
|
|
|
|
case ConfigModel::DataItem::BOOLEAN:
|
|
|
|
|
typeString = tr("bool", "display string for cmake type BOOLEAN");
|
|
|
|
|
break;
|
|
|
|
|
case ConfigModel::DataItem::FILE:
|
|
|
|
|
typeString = tr("file", "display string for cmake type FILE");
|
|
|
|
|
break;
|
|
|
|
|
case ConfigModel::DataItem::DIRECTORY:
|
|
|
|
|
typeString = tr("directory", "display string for cmake type DIRECTORY");
|
|
|
|
|
break;
|
|
|
|
|
case ConfigModel::DataItem::STRING:
|
|
|
|
|
typeString = tr("string", "display string for cmake type STRING");
|
|
|
|
|
break;
|
|
|
|
|
case ConfigModel::DataItem::UNKNOWN:
|
|
|
|
|
return nullptr;
|
|
|
|
|
}
|
|
|
|
|
QAction *forceAction = new QAction(tr("Force to %1").arg(typeString), nullptr);
|
|
|
|
|
forceAction->setEnabled(m_configModel->canForceTo(idx, t));
|
|
|
|
|
connect(forceAction, &QAction::triggered,
|
|
|
|
|
this, [this, idx, t]() { m_configModel->forceTo(idx, t); });
|
|
|
|
|
return forceAction;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool CMakeBuildSettingsWidget::eventFilter(QObject *target, QEvent *event)
|
|
|
|
|
{
|
|
|
|
|
// handle context menu events:
|
|
|
|
|
if (target != m_configView->viewport() || event->type() != QEvent::ContextMenu)
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
auto e = static_cast<QContextMenuEvent *>(event);
|
|
|
|
|
const QModelIndex idx = mapToSource(m_configView, m_configView->indexAt(e->pos()));
|
|
|
|
|
if (!idx.isValid())
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
auto menu = new QMenu(this);
|
|
|
|
|
connect(menu, &QMenu::triggered, menu, &QMenu::deleteLater);
|
|
|
|
|
|
|
|
|
|
QAction *action = nullptr;
|
|
|
|
|
if ((action = createForceAction(ConfigModel::DataItem::BOOLEAN, idx)))
|
|
|
|
|
menu->addAction(action);
|
|
|
|
|
if ((action = createForceAction(ConfigModel::DataItem::FILE, idx)))
|
|
|
|
|
menu->addAction(action);
|
|
|
|
|
if ((action = createForceAction(ConfigModel::DataItem::DIRECTORY, idx)))
|
|
|
|
|
menu->addAction(action);
|
|
|
|
|
if ((action = createForceAction(ConfigModel::DataItem::STRING, idx)))
|
|
|
|
|
menu->addAction(action);
|
|
|
|
|
|
2021-02-25 15:21:01 +01:00
|
|
|
auto copy = new QAction(tr("Copy"), this);
|
|
|
|
|
menu->addAction(copy);
|
|
|
|
|
connect(copy, &QAction::triggered, this, [this] {
|
|
|
|
|
const QModelIndexList selectedIndexes = m_configView->selectionModel()->selectedIndexes();
|
|
|
|
|
|
|
|
|
|
const QModelIndexList validIndexes = Utils::filtered(selectedIndexes, [](const QModelIndex &index) {
|
|
|
|
|
return index.isValid() && index.flags().testFlag(Qt::ItemIsSelectable);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
const QStringList variableList = Utils::transform(validIndexes, [this](const QModelIndex &index) {
|
|
|
|
|
return ConfigModel::dataItemFromIndex(index)
|
|
|
|
|
.toCMakeConfigItem().toArgument(m_buildConfiguration->macroExpander());
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
QApplication::clipboard()->setText(variableList.join('\n'), QClipboard::Clipboard);
|
|
|
|
|
});
|
|
|
|
|
|
2021-02-12 16:15:26 +01:00
|
|
|
menu->move(e->globalPos());
|
|
|
|
|
menu->show();
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
}
|
2020-04-02 14:49:05 +02:00
|
|
|
|
2021-02-02 16:10:45 +01:00
|
|
|
static bool isIos(const Kit *k)
|
|
|
|
|
{
|
|
|
|
|
const Id deviceType = DeviceTypeKitAspect::deviceTypeId(k);
|
|
|
|
|
return deviceType == Ios::Constants::IOS_DEVICE_TYPE
|
|
|
|
|
|| deviceType == Ios::Constants::IOS_SIMULATOR_TYPE;
|
|
|
|
|
}
|
|
|
|
|
|
2020-04-02 14:49:05 +02:00
|
|
|
static QStringList defaultInitialCMakeArguments(const Kit *k, const QString buildType)
|
|
|
|
|
{
|
|
|
|
|
// Generator:
|
|
|
|
|
QStringList initialArgs = CMakeGeneratorKitAspect::generatorArguments(k);
|
|
|
|
|
|
|
|
|
|
// CMAKE_BUILD_TYPE:
|
2021-01-14 16:38:55 +01:00
|
|
|
if (!buildType.isEmpty() && !CMakeGeneratorKitAspect::isMultiConfigGenerator(k)) {
|
2021-03-19 12:21:47 +01:00
|
|
|
initialArgs.append(QString::fromLatin1("-DCMAKE_BUILD_TYPE:STRING=%1").arg(buildType));
|
2021-01-14 16:38:55 +01:00
|
|
|
}
|
2020-04-02 14:49:05 +02:00
|
|
|
|
2021-02-18 18:50:11 +01:00
|
|
|
Internal::CMakeSpecificSettings *settings
|
|
|
|
|
= Internal::CMakeProjectPlugin::projectTypeSpecificSettings();
|
|
|
|
|
|
|
|
|
|
// Package manager
|
|
|
|
|
if (settings->packageManagerAutoSetup())
|
|
|
|
|
initialArgs.append(QString::fromLatin1("-DCMAKE_PROJECT_INCLUDE_BEFORE:PATH=%1")
|
|
|
|
|
.arg("%{IDE:ResourcePath}/package-manager/auto-setup.cmake"));
|
|
|
|
|
|
2020-04-02 14:49:05 +02:00
|
|
|
// Cross-compilation settings:
|
2021-02-02 16:10:45 +01:00
|
|
|
if (!isIos(k)) { // iOS handles this differently
|
|
|
|
|
const QString sysRoot = SysRootKitAspect::sysRoot(k).toString();
|
|
|
|
|
if (!sysRoot.isEmpty()) {
|
|
|
|
|
initialArgs.append(QString::fromLatin1("-DCMAKE_SYSROOT:PATH=%1").arg(sysRoot));
|
|
|
|
|
if (ToolChain *tc = ToolChainKitAspect::cxxToolChain(k)) {
|
|
|
|
|
const QString targetTriple = tc->originalTargetTriple();
|
|
|
|
|
initialArgs.append(
|
|
|
|
|
QString::fromLatin1("-DCMAKE_C_COMPILER_TARGET:STRING=%1").arg(targetTriple));
|
|
|
|
|
initialArgs.append(
|
|
|
|
|
QString::fromLatin1("-DCMAKE_CXX_COMPILER_TARGET:STRING=%1").arg(targetTriple));
|
|
|
|
|
}
|
2020-04-02 14:49:05 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
initialArgs += CMakeConfigurationKitAspect::toArgumentsList(k);
|
|
|
|
|
|
|
|
|
|
return initialArgs;
|
|
|
|
|
}
|
|
|
|
|
|
2021-02-04 14:53:42 +01:00
|
|
|
} // namespace Internal
|
|
|
|
|
|
2020-04-02 14:49:05 +02:00
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
|
// CMakeBuildConfiguration:
|
|
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
|
|
2021-02-12 16:15:26 +01:00
|
|
|
CMakeBuildConfiguration::CMakeBuildConfiguration(Target *target, Id id)
|
2019-12-09 12:59:38 +01:00
|
|
|
: BuildConfiguration(target, id)
|
2009-11-23 12:11:48 +01:00
|
|
|
{
|
2020-04-20 17:33:36 +02:00
|
|
|
m_buildSystem = new CMakeBuildSystem(this);
|
|
|
|
|
|
2020-03-16 10:24:35 +01:00
|
|
|
buildDirectoryAspect()->setFileDialogOnly(true);
|
2020-03-24 11:01:40 +01:00
|
|
|
const auto buildDirAspect = aspect<BuildDirectoryAspect>();
|
|
|
|
|
buildDirAspect->setFileDialogOnly(true);
|
|
|
|
|
buildDirAspect->setValueAcceptor(
|
2020-06-26 10:33:14 +02:00
|
|
|
[](const QString &oldDir, const QString &newDir) -> Utils::optional<QString> {
|
2020-03-24 11:01:40 +01:00
|
|
|
if (oldDir.isEmpty())
|
|
|
|
|
return newDir;
|
|
|
|
|
|
2020-11-25 17:56:03 +01:00
|
|
|
if (QDir(oldDir).exists("CMakeCache.txt") && !QDir(newDir).exists("CMakeCache.txt")) {
|
2020-03-24 11:01:40 +01:00
|
|
|
if (QMessageBox::information(nullptr,
|
|
|
|
|
tr("Changing Build Directory"),
|
|
|
|
|
tr("Change the build directory and start with a "
|
|
|
|
|
"basic CMake configuration?"),
|
|
|
|
|
QMessageBox::Ok,
|
|
|
|
|
QMessageBox::Cancel)
|
|
|
|
|
== QMessageBox::Ok) {
|
|
|
|
|
return newDir;
|
|
|
|
|
}
|
2020-06-25 11:19:15 +02:00
|
|
|
return Utils::nullopt;
|
2020-03-24 11:01:40 +01:00
|
|
|
}
|
2020-06-25 11:19:15 +02:00
|
|
|
return newDir;
|
2020-03-24 11:01:40 +01:00
|
|
|
});
|
2020-03-16 10:24:35 +01:00
|
|
|
|
2020-08-11 20:38:38 +02:00
|
|
|
auto initialCMakeArgumentsAspect = addAspect<InitialCMakeArgumentsAspect>();
|
|
|
|
|
initialCMakeArgumentsAspect->setMacroExpanderProvider([this]{ return macroExpander(); });
|
2021-02-04 14:53:42 +01:00
|
|
|
macroExpander()->registerVariable(DEVELOPMENT_TEAM_FLAG,
|
|
|
|
|
tr("The CMake flag for the development team"),
|
|
|
|
|
[this] {
|
|
|
|
|
const CMakeConfig flags = signingFlags();
|
|
|
|
|
if (!flags.isEmpty())
|
|
|
|
|
return flags.first().toArgument();
|
|
|
|
|
return QString();
|
|
|
|
|
});
|
|
|
|
|
macroExpander()->registerVariable(PROVISIONING_PROFILE_FLAG,
|
|
|
|
|
tr("The CMake flag for the provisioning profile"),
|
|
|
|
|
[this] {
|
|
|
|
|
const CMakeConfig flags = signingFlags();
|
|
|
|
|
if (flags.size() > 1 && !flags.at(1).isUnset) {
|
|
|
|
|
return flags.at(1).toArgument();
|
|
|
|
|
}
|
|
|
|
|
return QString();
|
|
|
|
|
});
|
2020-04-02 14:49:05 +02:00
|
|
|
|
2020-12-02 19:16:40 +01:00
|
|
|
addAspect<SourceDirectoryAspect>();
|
2021-01-14 16:38:55 +01:00
|
|
|
addAspect<BuildTypeAspect>();
|
2020-12-02 19:16:40 +01:00
|
|
|
|
2019-12-06 18:42:11 +01:00
|
|
|
appendInitialBuildStep(Constants::CMAKE_BUILD_STEP_ID);
|
|
|
|
|
appendInitialCleanStep(Constants::CMAKE_BUILD_STEP_ID);
|
2019-12-06 17:32:07 +01:00
|
|
|
|
2019-12-06 18:42:11 +01:00
|
|
|
setInitializer([this, target](const BuildInfo &info) {
|
2020-04-02 14:49:05 +02:00
|
|
|
const Kit *k = target->kit();
|
|
|
|
|
|
|
|
|
|
QStringList initialArgs = defaultInitialCMakeArguments(k, info.typeName);
|
2019-12-09 13:54:57 +01:00
|
|
|
|
2020-04-02 14:49:05 +02:00
|
|
|
// Android magic:
|
2019-12-09 13:54:57 +01:00
|
|
|
if (DeviceTypeKitAspect::deviceTypeId(k) == Android::Constants::ANDROID_DEVICE_TYPE) {
|
2019-12-09 12:59:38 +01:00
|
|
|
buildSteps()->appendStep(Android::Constants::ANDROID_BUILD_APK_ID);
|
|
|
|
|
const auto &bs = buildSteps()->steps().constLast();
|
2020-04-02 14:49:05 +02:00
|
|
|
initialArgs.append(
|
|
|
|
|
QString::fromLatin1("-DANDROID_NATIVE_API_LEVEL:STRING=%1")
|
|
|
|
|
.arg(bs->data(Android::Constants::AndroidNdkPlatform).toString()));
|
2019-12-09 12:59:38 +01:00
|
|
|
auto ndkLocation = bs->data(Android::Constants::NdkLocation).value<FilePath>();
|
2020-04-02 14:49:05 +02:00
|
|
|
initialArgs.append(
|
|
|
|
|
QString::fromLatin1("-DANDROID_NDK:PATH=%1").arg(ndkLocation.toString()));
|
ProjectExplorer/all: Re-organize BuildSteps/{Deploy,Build}Config setup
This follow the rough pattern of recent *RunConfigurationFactory changes
for build and deploy configurations.
- Collapse the two lines of constructors similar to what
890c1906e6fb2ec did for RunConfigurations
* Deploy* was purely mechanical
* Build* ctors are split in connects() in the ctor body
to create "empty shell for clone" etc
and build step additions in initialize() functions which
are only used in the create() case.
-- Allows to collapse the shared 'ctor()' functions, too.
- Move FooBuildConfigurationFactory::create() implementations
to FooBuildConfiguration() constructor. That was a strange
and unneeded ping-pong between factories and objects, and
furthermore allows one level less of indirection (and for a
later, left out here, some reduction of the
FooBuildConfiguration interfaces that were only used to
accommodate the *Factory::create() functions.
- Most {Build,Deploy}Configuration{,Factory} classes had a canHandle(),
but there wasn't one in the base classses. Have one there.
- Most canHandle() functions were checking simple restrictions on
e.g. project or target types, specify those by setters in the
constructors instead and check them in the base canHandle()
- clone() is generally replaced by a creation of a "shell object"
and a fromMap(source->toMap()), implemented in the base, there
are two cases left for Android and Qbs that needed(?) some extra
polish
- generally use canHandle() in base implementation, instead
of doing that in all Derived::canFoo()
- as a result, canCreate/create/canClone/clone reimplementations
are not needed anymore, keep the base implementation for
now (could be inlined into their only users later), but
de-virtualize them.
- Combine Ios{Preset,DSym}BuildStepFactory. There was only one
'dsym' build step they could create.
- Split the 'mangled' id into the ProjectConfiguration subtype
specific constant identifier, and a QString extraId() bit.
Only maintain the mangled id in saved settings.
- Make ProjectConfiguration::m_id a constant member, adapt
all constructors of derived classe.
Not done in this patch:
- Finish possible cosmetic changes on top
- Add a way to specify restrictions to supported Qt versions
(used in Android/Ios), as the base implementation does not
depend on the qtsupport plugin
- Combine the QList<X> availableFoo() + createFoo(X) function
pairs to somthing like a direct
QList<struct { X; std::function<X()>; }> fooCreators()
to avoid e.g. the baseId.withSuffix() <-> id.suffixAfter(base)
pingpong
- Remove the *Factories from the global object pool
- Do something about priority(). Falling back to plain
qmake in android+qmake setup is not helpful.
Change-Id: I2be7d88d554c5aa8b7db8edf5b93278e1ae0112a
Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
2017-11-29 12:28:40 +01:00
|
|
|
|
2020-04-02 14:49:05 +02:00
|
|
|
initialArgs.append(
|
|
|
|
|
QString::fromLatin1("-DCMAKE_TOOLCHAIN_FILE:PATH=%1")
|
|
|
|
|
.arg(
|
|
|
|
|
ndkLocation.pathAppended("build/cmake/android.toolchain.cmake").toString()));
|
2019-12-09 12:59:38 +01:00
|
|
|
|
|
|
|
|
auto androidAbis = bs->data(Android::Constants::AndroidABIs).toStringList();
|
|
|
|
|
QString preferredAbi;
|
2020-07-23 15:48:56 +02:00
|
|
|
if (androidAbis.contains(ProjectExplorer::Constants::ANDROID_ABI_ARMEABI_V7A)) {
|
|
|
|
|
preferredAbi = ProjectExplorer::Constants::ANDROID_ABI_ARMEABI_V7A;
|
|
|
|
|
} else if (androidAbis.isEmpty()
|
|
|
|
|
|| androidAbis.contains(ProjectExplorer::Constants::ANDROID_ABI_ARM64_V8A)) {
|
|
|
|
|
preferredAbi = ProjectExplorer::Constants::ANDROID_ABI_ARM64_V8A;
|
2019-12-09 12:59:38 +01:00
|
|
|
} else {
|
|
|
|
|
preferredAbi = androidAbis.first();
|
|
|
|
|
}
|
2020-04-02 14:49:05 +02:00
|
|
|
initialArgs.append(QString::fromLatin1("-DANDROID_ABI:STRING=%1").arg(preferredAbi));
|
2019-12-09 12:59:38 +01:00
|
|
|
|
2020-09-11 06:59:40 +02:00
|
|
|
initialArgs.append(QString::fromLatin1("-DANDROID_STL:STRING=c++_shared"));
|
2019-12-09 12:59:38 +01:00
|
|
|
|
2020-04-02 14:49:05 +02:00
|
|
|
initialArgs.append(
|
|
|
|
|
QString::fromLatin1("-DCMAKE_FIND_ROOT_PATH:PATH=%{Qt:QT_INSTALL_PREFIX}"));
|
2020-09-18 18:29:03 +03:00
|
|
|
|
2020-09-25 10:49:44 +03:00
|
|
|
QtSupport::BaseQtVersion *qt = QtSupport::QtKitAspect::qtVersion(k);
|
2020-11-05 14:21:12 +02:00
|
|
|
auto sdkLocation = bs->data(Android::Constants::SdkLocation).value<FilePath>();
|
2020-09-25 10:49:44 +03:00
|
|
|
|
2020-09-18 18:29:03 +03:00
|
|
|
if (qt->qtVersion() >= QtSupport::QtVersionNumber{6, 0, 0}) {
|
|
|
|
|
initialArgs.append(
|
|
|
|
|
QString::fromLatin1("-DQT_HOST_PATH:PATH=%{Qt:QT_HOST_PREFIX}"));
|
2020-09-25 10:49:44 +03:00
|
|
|
|
2020-11-05 14:21:12 +02:00
|
|
|
initialArgs.append(QString("-DANDROID_SDK_ROOT:PATH=%1").arg(sdkLocation.toString()));
|
|
|
|
|
} else {
|
|
|
|
|
initialArgs.append(QString("-DANDROID_SDK:PATH=%1").arg(sdkLocation.toString()));
|
2020-09-18 18:29:03 +03:00
|
|
|
}
|
2019-12-09 12:59:38 +01:00
|
|
|
}
|
|
|
|
|
|
2021-02-02 16:10:45 +01:00
|
|
|
if (isIos(k)) {
|
|
|
|
|
QtSupport::BaseQtVersion *qt = QtSupport::QtKitAspect::qtVersion(k);
|
|
|
|
|
if (qt && qt->qtVersion().majorVersion >= 6) {
|
|
|
|
|
// TODO it would be better if we could set
|
|
|
|
|
// CMAKE_SYSTEM_NAME=iOS and CMAKE_XCODE_ATTRIBUTE_ONLY_ACTIVE_ARCH=YES
|
|
|
|
|
// and build with "cmake --build . -- -arch <arch>" instead of setting the architecture
|
|
|
|
|
// and sysroot in the CMake configuration, but that currently doesn't work with Qt/CMake
|
|
|
|
|
// https://gitlab.kitware.com/cmake/cmake/-/issues/21276
|
|
|
|
|
const Id deviceType = DeviceTypeKitAspect::deviceTypeId(k);
|
|
|
|
|
// TODO the architectures are probably not correct with Apple Silicon in the mix...
|
|
|
|
|
const QString architecture = deviceType == Ios::Constants::IOS_DEVICE_TYPE
|
|
|
|
|
? QLatin1String("arm64")
|
|
|
|
|
: QLatin1String("x86_64");
|
|
|
|
|
const QString sysroot = deviceType == Ios::Constants::IOS_DEVICE_TYPE
|
|
|
|
|
? QLatin1String("iphoneos")
|
|
|
|
|
: QLatin1String("iphonesimulator");
|
|
|
|
|
initialArgs.append("-DCMAKE_TOOLCHAIN_FILE:PATH=%{Qt:QT_INSTALL_PREFIX}/lib/cmake/"
|
|
|
|
|
"Qt6/qt.toolchain.cmake");
|
|
|
|
|
initialArgs.append("-DCMAKE_OSX_ARCHITECTURES:STRING=" + architecture);
|
|
|
|
|
initialArgs.append("-DCMAKE_OSX_SYSROOT:STRING=" + sysroot);
|
2021-02-04 14:53:42 +01:00
|
|
|
initialArgs.append("%{" + QLatin1String(DEVELOPMENT_TEAM_FLAG) + "}");
|
|
|
|
|
initialArgs.append("%{" + QLatin1String(PROVISIONING_PROFILE_FLAG) + "}");
|
2021-02-02 16:10:45 +01:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2019-12-06 17:32:07 +01:00
|
|
|
if (info.buildDirectory.isEmpty()) {
|
2019-12-09 12:59:38 +01:00
|
|
|
setBuildDirectory(shadowBuildDirectory(target->project()->projectFilePath(),
|
2019-12-09 13:54:57 +01:00
|
|
|
k,
|
2019-12-06 17:32:07 +01:00
|
|
|
info.displayName,
|
|
|
|
|
info.buildType));
|
2019-10-18 09:25:14 +03:00
|
|
|
}
|
2019-12-09 13:54:57 +01:00
|
|
|
|
2020-12-02 19:16:40 +01:00
|
|
|
if (info.extraInfo.isValid()) {
|
|
|
|
|
setSourceDirectory(FilePath::fromVariant(
|
|
|
|
|
info.extraInfo.value<QVariantMap>().value(Constants::CMAKE_HOME_DIR)));
|
|
|
|
|
}
|
|
|
|
|
|
2020-04-02 14:49:05 +02:00
|
|
|
setInitialCMakeArguments(initialArgs);
|
2021-01-14 16:38:55 +01:00
|
|
|
setCMakeBuildType(info.typeName);
|
2019-12-09 12:59:38 +01:00
|
|
|
});
|
2020-02-05 15:16:04 +01:00
|
|
|
|
|
|
|
|
const auto qmlDebuggingAspect = addAspect<QtSupport::QmlDebuggingAspect>();
|
|
|
|
|
qmlDebuggingAspect->setKit(target->kit());
|
2019-12-09 12:59:38 +01:00
|
|
|
}
|
2019-10-18 09:25:14 +03:00
|
|
|
|
2019-12-09 12:59:38 +01:00
|
|
|
CMakeBuildConfiguration::~CMakeBuildConfiguration()
|
|
|
|
|
{
|
|
|
|
|
delete m_buildSystem;
|
2016-02-24 18:00:24 +01:00
|
|
|
}
|
|
|
|
|
|
2010-01-18 12:11:04 +01:00
|
|
|
QVariantMap CMakeBuildConfiguration::toMap() const
|
2009-12-08 12:21:11 +01:00
|
|
|
{
|
2021-02-12 16:15:26 +01:00
|
|
|
QVariantMap map(BuildConfiguration::toMap());
|
2010-01-18 12:11:04 +01:00
|
|
|
return map;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool CMakeBuildConfiguration::fromMap(const QVariantMap &map)
|
|
|
|
|
{
|
2010-09-22 15:14:07 +02:00
|
|
|
if (!BuildConfiguration::fromMap(map))
|
|
|
|
|
return false;
|
|
|
|
|
|
2016-02-03 13:52:50 +01:00
|
|
|
const CMakeConfig conf
|
2016-04-08 14:11:57 +02:00
|
|
|
= Utils::filtered(Utils::transform(map.value(QLatin1String(CONFIGURATION_KEY)).toStringList(),
|
|
|
|
|
[](const QString &v) { return CMakeConfigItem::fromString(v); }),
|
|
|
|
|
[](const CMakeConfigItem &c) { return !c.isNull(); });
|
2016-02-03 13:52:50 +01:00
|
|
|
|
2020-04-02 14:49:05 +02:00
|
|
|
// TODO: Upgrade from Qt Creator < 4.13: Remove when no longer supported!
|
|
|
|
|
const QString buildTypeName = [this]() {
|
|
|
|
|
switch (buildType()) {
|
|
|
|
|
case Debug:
|
|
|
|
|
return QString("Debug");
|
|
|
|
|
case Profile:
|
|
|
|
|
return QString("RelWithDebInfo");
|
|
|
|
|
case Release:
|
|
|
|
|
return QString("Release");
|
|
|
|
|
case Unknown:
|
|
|
|
|
default:
|
|
|
|
|
return QString("");
|
|
|
|
|
}
|
|
|
|
|
}();
|
|
|
|
|
if (initialCMakeArguments().isEmpty()) {
|
2020-09-07 15:56:18 +02:00
|
|
|
QStringList initialArgs = defaultInitialCMakeArguments(kit(), buildTypeName)
|
2020-04-02 14:49:05 +02:00
|
|
|
+ Utils::transform(conf, [this](const CMakeConfigItem &i) {
|
|
|
|
|
return i.toArgument(macroExpander());
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
setInitialCMakeArguments(initialArgs);
|
|
|
|
|
}
|
2010-01-18 12:11:04 +01:00
|
|
|
|
2010-09-22 15:14:07 +02:00
|
|
|
return true;
|
2009-11-23 12:11:48 +01:00
|
|
|
}
|
2009-11-23 13:29:45 +01:00
|
|
|
|
2019-05-28 13:49:26 +02:00
|
|
|
FilePath CMakeBuildConfiguration::shadowBuildDirectory(const FilePath &projectFilePath,
|
2016-03-01 14:12:35 +01:00
|
|
|
const Kit *k,
|
|
|
|
|
const QString &bcName,
|
|
|
|
|
BuildConfiguration::BuildType buildType)
|
|
|
|
|
{
|
|
|
|
|
if (projectFilePath.isEmpty())
|
2019-05-28 13:49:26 +02:00
|
|
|
return FilePath();
|
2016-03-01 14:12:35 +01:00
|
|
|
|
|
|
|
|
const QString projectName = projectFilePath.parentDir().fileName();
|
2019-06-26 17:09:35 +02:00
|
|
|
ProjectMacroExpander expander(projectFilePath, projectName, k, bcName, buildType);
|
2016-03-01 14:12:35 +01:00
|
|
|
QDir projectDir = QDir(Project::projectDirectory(projectFilePath).toString());
|
2018-10-05 15:04:25 +02:00
|
|
|
QString buildPath = expander.expand(ProjectExplorerPlugin::buildDirectoryTemplate());
|
2018-10-23 16:44:34 +02:00
|
|
|
buildPath.replace(" ", "-");
|
2021-01-14 16:38:55 +01:00
|
|
|
|
|
|
|
|
if (CMakeGeneratorKitAspect::isMultiConfigGenerator(k))
|
|
|
|
|
buildPath = buildPath.left(buildPath.lastIndexOf(QString("-%1").arg(bcName)));
|
|
|
|
|
|
2019-05-28 13:49:26 +02:00
|
|
|
return FilePath::fromUserInput(projectDir.absoluteFilePath(buildPath));
|
2016-03-01 14:12:35 +01:00
|
|
|
}
|
|
|
|
|
|
2016-11-14 15:18:25 +01:00
|
|
|
void CMakeBuildConfiguration::buildTarget(const QString &buildTarget)
|
|
|
|
|
{
|
2021-02-12 16:15:26 +01:00
|
|
|
auto cmBs = qobject_cast<CMakeBuildStep *>(findOrDefault(
|
2019-12-05 16:19:42 +01:00
|
|
|
buildSteps()->steps(),
|
2021-02-12 16:15:26 +01:00
|
|
|
[](const BuildStep *bs) {
|
2016-11-14 15:18:25 +01:00
|
|
|
return bs->id() == Constants::CMAKE_BUILD_STEP_ID;
|
|
|
|
|
}));
|
|
|
|
|
|
2020-06-02 19:37:25 +02:00
|
|
|
QStringList originalBuildTargets;
|
2016-11-14 15:18:25 +01:00
|
|
|
if (cmBs) {
|
2020-06-02 19:37:25 +02:00
|
|
|
originalBuildTargets = cmBs->buildTargets();
|
|
|
|
|
cmBs->setBuildTargets({buildTarget});
|
2016-11-14 15:18:25 +01:00
|
|
|
}
|
|
|
|
|
|
2019-12-05 16:19:42 +01:00
|
|
|
BuildManager::buildList(buildSteps());
|
2016-11-14 15:18:25 +01:00
|
|
|
|
|
|
|
|
if (cmBs)
|
2020-06-02 19:37:25 +02:00
|
|
|
cmBs->setBuildTargets(originalBuildTargets);
|
2016-11-14 15:18:25 +01:00
|
|
|
}
|
|
|
|
|
|
2017-09-28 11:32:39 +02:00
|
|
|
CMakeConfig CMakeBuildConfiguration::configurationFromCMake() const
|
2016-02-24 18:00:24 +01:00
|
|
|
{
|
2017-09-28 11:32:39 +02:00
|
|
|
return m_configurationFromCMake;
|
|
|
|
|
}
|
2016-02-24 18:00:24 +01:00
|
|
|
|
2021-02-04 16:22:40 +01:00
|
|
|
CMakeConfig CMakeBuildConfiguration::configurationChanges() const
|
2017-09-28 11:32:39 +02:00
|
|
|
{
|
2021-02-04 16:22:40 +01:00
|
|
|
return m_configurationChanges;
|
2016-02-24 18:00:24 +01:00
|
|
|
}
|
|
|
|
|
|
2021-02-04 16:22:40 +01:00
|
|
|
QStringList CMakeBuildConfiguration::configurationChangesArguments() const
|
2017-09-28 11:32:39 +02:00
|
|
|
{
|
2021-02-04 16:22:40 +01:00
|
|
|
return Utils::transform(m_configurationChanges, [](const CMakeConfigItem &i) { return i.toArgument(); });
|
2020-04-02 14:49:05 +02:00
|
|
|
}
|
2016-02-24 18:00:24 +01:00
|
|
|
|
2021-02-04 16:22:40 +01:00
|
|
|
QStringList CMakeBuildConfiguration::initialCMakeArguments() const
|
2020-04-02 14:49:05 +02:00
|
|
|
{
|
2021-02-04 16:22:40 +01:00
|
|
|
return aspect<InitialCMakeArgumentsAspect>()->value().split('\n', Qt::SkipEmptyParts);
|
2016-02-24 18:00:24 +01:00
|
|
|
}
|
|
|
|
|
|
2020-04-02 14:49:05 +02:00
|
|
|
void CMakeBuildConfiguration::setConfigurationFromCMake(const CMakeConfig &config)
|
|
|
|
|
{
|
|
|
|
|
m_configurationFromCMake = config;
|
|
|
|
|
}
|
|
|
|
|
|
2021-02-04 16:22:40 +01:00
|
|
|
void CMakeBuildConfiguration::setConfigurationChanges(const CMakeConfig &config)
|
|
|
|
|
{
|
|
|
|
|
qCDebug(cmakeBuildConfigurationLog)
|
|
|
|
|
<< "Configuration changes before:" << configurationChangesArguments();
|
|
|
|
|
|
|
|
|
|
m_configurationChanges = config;
|
|
|
|
|
|
|
|
|
|
qCDebug(cmakeBuildConfigurationLog)
|
|
|
|
|
<< "Configuration changes after:" << configurationChangesArguments();
|
|
|
|
|
}
|
|
|
|
|
|
2020-04-02 14:49:05 +02:00
|
|
|
// FIXME: Run clean steps when a setting starting with "ANDROID_BUILD_ABI_" is changed.
|
|
|
|
|
// FIXME: Warn when kit settings are overridden by a project.
|
|
|
|
|
|
2017-04-07 11:15:26 +02:00
|
|
|
void CMakeBuildConfiguration::clearError(ForceEnabledChanged fec)
|
2017-03-01 12:52:24 +01:00
|
|
|
{
|
|
|
|
|
if (!m_error.isEmpty()) {
|
|
|
|
|
m_error.clear();
|
2017-04-07 11:15:26 +02:00
|
|
|
fec = ForceEnabledChanged::True;
|
2017-03-01 12:52:24 +01:00
|
|
|
}
|
2019-10-08 12:53:23 +02:00
|
|
|
if (fec == ForceEnabledChanged::True) {
|
|
|
|
|
qCDebug(cmakeBuildConfigurationLog) << "Emitting enabledChanged signal";
|
2017-04-07 11:15:26 +02:00
|
|
|
emit enabledChanged();
|
2019-10-08 12:53:23 +02:00
|
|
|
}
|
2017-03-01 12:52:24 +01:00
|
|
|
}
|
|
|
|
|
|
2020-04-02 14:49:05 +02:00
|
|
|
void CMakeBuildConfiguration::setInitialCMakeArguments(const QStringList &args)
|
2015-09-10 16:17:38 +02:00
|
|
|
{
|
2020-04-02 14:49:05 +02:00
|
|
|
aspect<InitialCMakeArgumentsAspect>()->setValue(args.join('\n'));
|
2015-09-10 16:17:38 +02:00
|
|
|
}
|
|
|
|
|
|
2016-02-11 16:33:15 +01:00
|
|
|
void CMakeBuildConfiguration::setError(const QString &message)
|
|
|
|
|
{
|
2019-10-08 12:53:23 +02:00
|
|
|
qCDebug(cmakeBuildConfigurationLog) << "Setting error to" << message;
|
|
|
|
|
QTC_ASSERT(!message.isEmpty(), return );
|
|
|
|
|
|
2017-07-18 16:48:02 +02:00
|
|
|
const QString oldMessage = m_error;
|
2017-03-01 12:52:24 +01:00
|
|
|
if (m_error != message)
|
2016-12-02 17:32:31 +01:00
|
|
|
m_error = message;
|
2019-10-08 12:53:23 +02:00
|
|
|
if (oldMessage.isEmpty() != !message.isEmpty()) {
|
|
|
|
|
qCDebug(cmakeBuildConfigurationLog) << "Emitting enabledChanged signal";
|
2017-03-01 12:52:24 +01:00
|
|
|
emit enabledChanged();
|
2019-10-08 12:53:23 +02:00
|
|
|
}
|
2020-03-19 12:41:23 +01:00
|
|
|
emit errorOccurred(m_error);
|
2016-02-11 16:33:15 +01:00
|
|
|
}
|
|
|
|
|
|
2016-05-12 17:23:03 +02:00
|
|
|
void CMakeBuildConfiguration::setWarning(const QString &message)
|
|
|
|
|
{
|
|
|
|
|
if (m_warning == message)
|
|
|
|
|
return;
|
|
|
|
|
m_warning = message;
|
2020-03-19 12:41:23 +01:00
|
|
|
emit warningOccurred(m_warning);
|
2016-05-12 17:23:03 +02:00
|
|
|
}
|
|
|
|
|
|
2016-02-11 16:33:15 +01:00
|
|
|
QString CMakeBuildConfiguration::error() const
|
|
|
|
|
{
|
|
|
|
|
return m_error;
|
|
|
|
|
}
|
|
|
|
|
|
2016-05-12 17:23:03 +02:00
|
|
|
QString CMakeBuildConfiguration::warning() const
|
|
|
|
|
{
|
|
|
|
|
return m_warning;
|
|
|
|
|
}
|
|
|
|
|
|
2021-02-12 16:15:26 +01:00
|
|
|
NamedWidget *CMakeBuildConfiguration::createConfigWidget()
|
2009-11-26 14:43:27 +01:00
|
|
|
{
|
2012-11-08 17:35:59 +01:00
|
|
|
return new CMakeBuildSettingsWidget(this);
|
2009-11-26 14:43:27 +01:00
|
|
|
}
|
|
|
|
|
|
2021-02-04 14:53:42 +01:00
|
|
|
CMakeConfig CMakeBuildConfiguration::signingFlags() const
|
|
|
|
|
{
|
|
|
|
|
return {};
|
|
|
|
|
}
|
|
|
|
|
|
2010-01-07 18:17:24 +01:00
|
|
|
/*!
|
|
|
|
|
\class CMakeBuildConfigurationFactory
|
|
|
|
|
*/
|
|
|
|
|
|
ProjectExplorer/all: Re-organize BuildSteps/{Deploy,Build}Config setup
This follow the rough pattern of recent *RunConfigurationFactory changes
for build and deploy configurations.
- Collapse the two lines of constructors similar to what
890c1906e6fb2ec did for RunConfigurations
* Deploy* was purely mechanical
* Build* ctors are split in connects() in the ctor body
to create "empty shell for clone" etc
and build step additions in initialize() functions which
are only used in the create() case.
-- Allows to collapse the shared 'ctor()' functions, too.
- Move FooBuildConfigurationFactory::create() implementations
to FooBuildConfiguration() constructor. That was a strange
and unneeded ping-pong between factories and objects, and
furthermore allows one level less of indirection (and for a
later, left out here, some reduction of the
FooBuildConfiguration interfaces that were only used to
accommodate the *Factory::create() functions.
- Most {Build,Deploy}Configuration{,Factory} classes had a canHandle(),
but there wasn't one in the base classses. Have one there.
- Most canHandle() functions were checking simple restrictions on
e.g. project or target types, specify those by setters in the
constructors instead and check them in the base canHandle()
- clone() is generally replaced by a creation of a "shell object"
and a fromMap(source->toMap()), implemented in the base, there
are two cases left for Android and Qbs that needed(?) some extra
polish
- generally use canHandle() in base implementation, instead
of doing that in all Derived::canFoo()
- as a result, canCreate/create/canClone/clone reimplementations
are not needed anymore, keep the base implementation for
now (could be inlined into their only users later), but
de-virtualize them.
- Combine Ios{Preset,DSym}BuildStepFactory. There was only one
'dsym' build step they could create.
- Split the 'mangled' id into the ProjectConfiguration subtype
specific constant identifier, and a QString extraId() bit.
Only maintain the mangled id in saved settings.
- Make ProjectConfiguration::m_id a constant member, adapt
all constructors of derived classe.
Not done in this patch:
- Finish possible cosmetic changes on top
- Add a way to specify restrictions to supported Qt versions
(used in Android/Ios), as the base implementation does not
depend on the qtsupport plugin
- Combine the QList<X> availableFoo() + createFoo(X) function
pairs to somthing like a direct
QList<struct { X; std::function<X()>; }> fooCreators()
to avoid e.g. the baseId.withSuffix() <-> id.suffixAfter(base)
pingpong
- Remove the *Factories from the global object pool
- Do something about priority(). Falling back to plain
qmake in android+qmake setup is not helpful.
Change-Id: I2be7d88d554c5aa8b7db8edf5b93278e1ae0112a
Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
2017-11-29 12:28:40 +01:00
|
|
|
CMakeBuildConfigurationFactory::CMakeBuildConfigurationFactory()
|
|
|
|
|
{
|
2021-02-04 14:53:42 +01:00
|
|
|
registerBuildConfiguration<CMakeBuildConfiguration>(Constants::CMAKE_BUILDCONFIGURATION_ID);
|
2018-05-04 16:52:21 +02:00
|
|
|
|
2020-04-07 14:44:22 +02:00
|
|
|
setSupportedProjectType(CMakeProjectManager::Constants::CMAKE_PROJECT_ID);
|
|
|
|
|
setSupportedProjectMimeTypeName(Constants::CMAKE_PROJECT_MIMETYPE);
|
2020-01-09 15:06:30 +01:00
|
|
|
|
2020-01-09 18:42:28 +01:00
|
|
|
setBuildGenerator([](const Kit *k, const FilePath &projectPath, bool forSetup) {
|
2020-01-09 15:06:30 +01:00
|
|
|
QList<BuildInfo> result;
|
|
|
|
|
|
|
|
|
|
FilePath path = forSetup ? Project::projectDirectory(projectPath) : projectPath;
|
|
|
|
|
|
|
|
|
|
for (int type = BuildTypeDebug; type != BuildTypeLast; ++type) {
|
2020-01-09 18:42:28 +01:00
|
|
|
BuildInfo info = createBuildInfo(BuildType(type));
|
2020-01-09 15:06:30 +01:00
|
|
|
if (forSetup) {
|
|
|
|
|
info.buildDirectory = CMakeBuildConfiguration::shadowBuildDirectory(projectPath,
|
|
|
|
|
k,
|
|
|
|
|
info.typeName,
|
|
|
|
|
info.buildType);
|
|
|
|
|
}
|
|
|
|
|
result << info;
|
|
|
|
|
}
|
|
|
|
|
return result;
|
|
|
|
|
});
|
ProjectExplorer/all: Re-organize BuildSteps/{Deploy,Build}Config setup
This follow the rough pattern of recent *RunConfigurationFactory changes
for build and deploy configurations.
- Collapse the two lines of constructors similar to what
890c1906e6fb2ec did for RunConfigurations
* Deploy* was purely mechanical
* Build* ctors are split in connects() in the ctor body
to create "empty shell for clone" etc
and build step additions in initialize() functions which
are only used in the create() case.
-- Allows to collapse the shared 'ctor()' functions, too.
- Move FooBuildConfigurationFactory::create() implementations
to FooBuildConfiguration() constructor. That was a strange
and unneeded ping-pong between factories and objects, and
furthermore allows one level less of indirection (and for a
later, left out here, some reduction of the
FooBuildConfiguration interfaces that were only used to
accommodate the *Factory::create() functions.
- Most {Build,Deploy}Configuration{,Factory} classes had a canHandle(),
but there wasn't one in the base classses. Have one there.
- Most canHandle() functions were checking simple restrictions on
e.g. project or target types, specify those by setters in the
constructors instead and check them in the base canHandle()
- clone() is generally replaced by a creation of a "shell object"
and a fromMap(source->toMap()), implemented in the base, there
are two cases left for Android and Qbs that needed(?) some extra
polish
- generally use canHandle() in base implementation, instead
of doing that in all Derived::canFoo()
- as a result, canCreate/create/canClone/clone reimplementations
are not needed anymore, keep the base implementation for
now (could be inlined into their only users later), but
de-virtualize them.
- Combine Ios{Preset,DSym}BuildStepFactory. There was only one
'dsym' build step they could create.
- Split the 'mangled' id into the ProjectConfiguration subtype
specific constant identifier, and a QString extraId() bit.
Only maintain the mangled id in saved settings.
- Make ProjectConfiguration::m_id a constant member, adapt
all constructors of derived classe.
Not done in this patch:
- Finish possible cosmetic changes on top
- Add a way to specify restrictions to supported Qt versions
(used in Android/Ios), as the base implementation does not
depend on the qtsupport plugin
- Combine the QList<X> availableFoo() + createFoo(X) function
pairs to somthing like a direct
QList<struct { X; std::function<X()>; }> fooCreators()
to avoid e.g. the baseId.withSuffix() <-> id.suffixAfter(base)
pingpong
- Remove the *Factories from the global object pool
- Do something about priority(). Falling back to plain
qmake in android+qmake setup is not helpful.
Change-Id: I2be7d88d554c5aa8b7db8edf5b93278e1ae0112a
Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
2017-11-29 12:28:40 +01:00
|
|
|
}
|
2010-01-07 18:17:24 +01:00
|
|
|
|
2019-08-05 16:35:07 +02:00
|
|
|
CMakeBuildConfigurationFactory::BuildType CMakeBuildConfigurationFactory::buildTypeFromByteArray(
|
|
|
|
|
const QByteArray &in)
|
2017-02-07 16:23:36 +01:00
|
|
|
{
|
|
|
|
|
const QByteArray bt = in.toLower();
|
|
|
|
|
if (bt == "debug")
|
|
|
|
|
return BuildTypeDebug;
|
|
|
|
|
if (bt == "release")
|
|
|
|
|
return BuildTypeRelease;
|
|
|
|
|
if (bt == "relwithdebinfo")
|
|
|
|
|
return BuildTypeRelWithDebInfo;
|
|
|
|
|
if (bt == "minsizerel")
|
|
|
|
|
return BuildTypeMinSizeRel;
|
|
|
|
|
return BuildTypeNone;
|
|
|
|
|
}
|
|
|
|
|
|
2019-08-05 16:35:07 +02:00
|
|
|
BuildConfiguration::BuildType CMakeBuildConfigurationFactory::cmakeBuildTypeToBuildType(
|
|
|
|
|
const CMakeBuildConfigurationFactory::BuildType &in)
|
2017-02-07 16:23:36 +01:00
|
|
|
{
|
|
|
|
|
// Cover all common CMake build types
|
|
|
|
|
if (in == BuildTypeRelease || in == BuildTypeMinSizeRel)
|
|
|
|
|
return BuildConfiguration::Release;
|
|
|
|
|
else if (in == BuildTypeDebug)
|
|
|
|
|
return BuildConfiguration::Debug;
|
|
|
|
|
else if (in == BuildTypeRelWithDebInfo)
|
|
|
|
|
return BuildConfiguration::Profile;
|
|
|
|
|
else
|
|
|
|
|
return BuildConfiguration::Unknown;
|
|
|
|
|
}
|
|
|
|
|
|
2020-01-09 18:42:28 +01:00
|
|
|
BuildInfo CMakeBuildConfigurationFactory::createBuildInfo(BuildType buildType)
|
2013-07-22 15:53:57 +02:00
|
|
|
{
|
2020-01-09 18:42:28 +01:00
|
|
|
BuildInfo info;
|
2019-01-29 16:51:17 +01:00
|
|
|
|
2015-09-10 16:17:38 +02:00
|
|
|
switch (buildType) {
|
|
|
|
|
case BuildTypeNone:
|
2019-10-09 18:36:17 +02:00
|
|
|
info.typeName = "Build";
|
2020-01-09 17:32:51 +01:00
|
|
|
info.displayName = BuildConfiguration::tr("Build");
|
2019-10-09 18:36:17 +02:00
|
|
|
info.buildType = BuildConfiguration::Unknown;
|
2015-09-10 16:17:38 +02:00
|
|
|
break;
|
|
|
|
|
case BuildTypeDebug:
|
2019-10-09 18:36:17 +02:00
|
|
|
info.typeName = "Debug";
|
2020-01-09 17:32:51 +01:00
|
|
|
info.displayName = BuildConfiguration::tr("Debug");
|
2019-01-29 16:51:17 +01:00
|
|
|
info.buildType = BuildConfiguration::Debug;
|
2015-09-10 16:17:38 +02:00
|
|
|
break;
|
|
|
|
|
case BuildTypeRelease:
|
2019-10-09 18:36:17 +02:00
|
|
|
info.typeName = "Release";
|
2020-01-09 17:32:51 +01:00
|
|
|
info.displayName = BuildConfiguration::tr("Release");
|
2019-01-29 16:51:17 +01:00
|
|
|
info.buildType = BuildConfiguration::Release;
|
2015-09-10 16:17:38 +02:00
|
|
|
break;
|
|
|
|
|
case BuildTypeMinSizeRel:
|
2019-10-09 18:36:17 +02:00
|
|
|
info.typeName = "MinSizeRel";
|
2020-01-09 17:32:51 +01:00
|
|
|
info.displayName = CMakeBuildConfiguration::tr("Minimum Size Release");
|
2019-01-29 16:51:17 +01:00
|
|
|
info.buildType = BuildConfiguration::Release;
|
2015-09-10 16:17:38 +02:00
|
|
|
break;
|
|
|
|
|
case BuildTypeRelWithDebInfo:
|
2019-10-09 18:36:17 +02:00
|
|
|
info.typeName = "RelWithDebInfo";
|
2020-01-09 17:32:51 +01:00
|
|
|
info.displayName = CMakeBuildConfiguration::tr("Release with Debug Information");
|
2019-01-29 16:51:17 +01:00
|
|
|
info.buildType = BuildConfiguration::Profile;
|
2015-09-10 16:17:38 +02:00
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
QTC_CHECK(false);
|
|
|
|
|
break;
|
|
|
|
|
}
|
2013-07-22 15:53:57 +02:00
|
|
|
|
|
|
|
|
return info;
|
|
|
|
|
}
|
|
|
|
|
|
2021-02-12 16:15:26 +01:00
|
|
|
BuildConfiguration::BuildType CMakeBuildConfiguration::buildType() const
|
2011-03-03 16:12:00 +01:00
|
|
|
{
|
2020-04-02 14:49:05 +02:00
|
|
|
QByteArray cmakeBuildTypeName = CMakeConfigItem::valueOf("CMAKE_BUILD_TYPE", m_configurationFromCMake);
|
2021-01-14 16:38:55 +01:00
|
|
|
if (cmakeBuildTypeName.isEmpty()) {
|
|
|
|
|
QByteArray cmakeCfgTypes = CMakeConfigItem::valueOf("CMAKE_CONFIGURATION_TYPES", m_configurationFromCMake);
|
|
|
|
|
if (!cmakeCfgTypes.isEmpty())
|
|
|
|
|
cmakeBuildTypeName = cmakeBuildType().toUtf8();
|
|
|
|
|
}
|
2011-03-03 16:12:00 +01:00
|
|
|
// Cover all common CMake build types
|
2017-02-07 16:23:36 +01:00
|
|
|
const CMakeBuildConfigurationFactory::BuildType cmakeBuildType
|
2019-08-05 16:39:00 +02:00
|
|
|
= CMakeBuildConfigurationFactory::buildTypeFromByteArray(cmakeBuildTypeName);
|
2017-02-07 16:23:36 +01:00
|
|
|
return CMakeBuildConfigurationFactory::cmakeBuildTypeToBuildType(cmakeBuildType);
|
2011-03-03 16:12:00 +01:00
|
|
|
}
|
2012-10-02 17:46:12 +02:00
|
|
|
|
2019-10-25 09:55:32 +02:00
|
|
|
BuildSystem *CMakeBuildConfiguration::buildSystem() const
|
|
|
|
|
{
|
|
|
|
|
return m_buildSystem;
|
|
|
|
|
}
|
|
|
|
|
|
2020-04-02 14:49:05 +02:00
|
|
|
void CMakeBuildConfiguration::runCMakeWithExtraArguments()
|
|
|
|
|
{
|
|
|
|
|
m_buildSystem->runCMakeWithExtraArguments();
|
|
|
|
|
}
|
|
|
|
|
|
2020-12-02 19:16:40 +01:00
|
|
|
void CMakeBuildConfiguration::setSourceDirectory(const FilePath &path)
|
|
|
|
|
{
|
|
|
|
|
aspect<SourceDirectoryAspect>()->setValue(path.toString());
|
|
|
|
|
}
|
|
|
|
|
|
2021-02-12 16:15:26 +01:00
|
|
|
FilePath CMakeBuildConfiguration::sourceDirectory() const
|
2020-12-02 19:16:40 +01:00
|
|
|
{
|
2021-02-12 16:15:26 +01:00
|
|
|
return FilePath::fromString(aspect<SourceDirectoryAspect>()->value());
|
2020-12-02 19:16:40 +01:00
|
|
|
}
|
|
|
|
|
|
2021-01-14 16:38:55 +01:00
|
|
|
QString CMakeBuildConfiguration::cmakeBuildType() const
|
|
|
|
|
{
|
2021-03-18 14:20:02 +01:00
|
|
|
if (!isMultiConfig()) {
|
|
|
|
|
auto configChanges = configurationChanges();
|
|
|
|
|
auto it = std::find_if(configChanges.begin(), configChanges.end(),
|
|
|
|
|
[](const CMakeConfigItem &item) { return item.key == "CMAKE_BUILD_TYPE";});
|
|
|
|
|
if (it != configChanges.end())
|
|
|
|
|
const_cast<CMakeBuildConfiguration*>(this)
|
|
|
|
|
->setCMakeBuildType(QString::fromUtf8(it->value));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QString cmakeBuildType = aspect<BuildTypeAspect>()->value();
|
|
|
|
|
|
|
|
|
|
const Utils::FilePath cmakeCacheTxt = buildDirectory().pathAppended("CMakeCache.txt");
|
|
|
|
|
const bool hasCMakeCache = QFile::exists(cmakeCacheTxt.toString());
|
|
|
|
|
CMakeConfig config;
|
|
|
|
|
|
|
|
|
|
if (cmakeBuildType == "Unknown") {
|
|
|
|
|
// The "Unknown" type is the case of loading of an existing project
|
|
|
|
|
// that doesn't have the "CMake.Build.Type" aspect saved
|
|
|
|
|
if (hasCMakeCache) {
|
|
|
|
|
QString errorMessage;
|
|
|
|
|
config = CMakeBuildSystem::parseCMakeCacheDotTxt(cmakeCacheTxt, &errorMessage);
|
|
|
|
|
} else {
|
|
|
|
|
config = CMakeConfigItem::itemsFromArguments(initialCMakeArguments());
|
|
|
|
|
}
|
|
|
|
|
} else if (!hasCMakeCache) {
|
|
|
|
|
config = CMakeConfigItem::itemsFromArguments(initialCMakeArguments());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!config.isEmpty()) {
|
|
|
|
|
cmakeBuildType = QString::fromUtf8(CMakeConfigItem::valueOf("CMAKE_BUILD_TYPE", config));
|
|
|
|
|
const_cast<CMakeBuildConfiguration*>(this)
|
|
|
|
|
->setCMakeBuildType(cmakeBuildType);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return cmakeBuildType;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void CMakeBuildConfiguration::setCMakeBuildType(const QString &cmakeBuildType, bool quiet)
|
|
|
|
|
{
|
|
|
|
|
if (quiet) {
|
|
|
|
|
aspect<BuildTypeAspect>()->setValueQuietly(cmakeBuildType);
|
|
|
|
|
aspect<BuildTypeAspect>()->update();
|
|
|
|
|
} else {
|
|
|
|
|
aspect<BuildTypeAspect>()->setValue(cmakeBuildType);
|
|
|
|
|
}
|
2021-01-14 16:38:55 +01:00
|
|
|
}
|
|
|
|
|
|
2021-03-18 14:20:02 +01:00
|
|
|
bool CMakeBuildConfiguration::isMultiConfig() const
|
2021-01-14 16:38:55 +01:00
|
|
|
{
|
2021-03-18 14:20:02 +01:00
|
|
|
return m_buildSystem->isMultiConfig();
|
2021-01-14 16:38:55 +01:00
|
|
|
}
|
|
|
|
|
|
2021-02-04 14:53:42 +01:00
|
|
|
namespace Internal {
|
|
|
|
|
|
2020-04-02 14:49:05 +02:00
|
|
|
// ----------------------------------------------------------------------
|
|
|
|
|
// - InitialCMakeParametersAspect:
|
|
|
|
|
// ----------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
InitialCMakeArgumentsAspect::InitialCMakeArgumentsAspect()
|
|
|
|
|
{
|
|
|
|
|
setSettingsKey("CMake.Initial.Parameters");
|
2020-07-02 09:08:26 +02:00
|
|
|
setLabelText(tr("Initial CMake parameters:"));
|
2020-04-02 14:49:05 +02:00
|
|
|
setDisplayStyle(TextEditDisplay);
|
|
|
|
|
}
|
|
|
|
|
|
2020-12-02 19:16:40 +01:00
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
|
// SourceDirectoryAspect:
|
|
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
|
SourceDirectoryAspect::SourceDirectoryAspect()
|
|
|
|
|
{
|
|
|
|
|
// Will not be displayed, only persisted
|
|
|
|
|
setSettingsKey("CMake.Source.Directory");
|
|
|
|
|
}
|
|
|
|
|
|
2021-01-14 16:38:55 +01:00
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
|
// BuildTypeAspect:
|
|
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
|
BuildTypeAspect::BuildTypeAspect()
|
|
|
|
|
{
|
|
|
|
|
setSettingsKey("CMake.Build.Type");
|
2021-03-18 14:20:02 +01:00
|
|
|
setLabelText(tr("Build type:"));
|
|
|
|
|
setDisplayStyle(LineEditDisplay);
|
|
|
|
|
setDefaultValue("Unknown");
|
2021-01-14 16:38:55 +01:00
|
|
|
}
|
|
|
|
|
|
2014-10-22 09:16:55 +02:00
|
|
|
} // namespace Internal
|
|
|
|
|
} // namespace CMakeProjectManager
|