2015-02-24 21:57:00 +01:00
|
|
|
/****************************************************************************
|
|
|
|
|
**
|
2016-01-15 14:57:40 +01:00
|
|
|
** Copyright (C) 2016 Canonical Ltd.
|
|
|
|
|
** Contact: https://www.qt.io/licensing/
|
2015-02-24 21:57:00 +01:00
|
|
|
**
|
|
|
|
|
** This file is part of Qt Creator.
|
|
|
|
|
**
|
|
|
|
|
** 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.
|
2015-02-24 21:57:00 +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.
|
2015-02-24 21:57:00 +01:00
|
|
|
**
|
|
|
|
|
****************************************************************************/
|
2016-01-15 14:57:40 +01:00
|
|
|
|
2015-02-24 21:57:00 +01:00
|
|
|
#include "cmakekitinformation.h"
|
2017-04-03 14:31:32 +02:00
|
|
|
#include "cmakeprojectconstants.h"
|
2020-03-03 12:23:04 +01:00
|
|
|
#include "cmakeprojectplugin.h"
|
|
|
|
|
#include "cmakespecificsettings.h"
|
2015-02-24 21:57:00 +01:00
|
|
|
#include "cmaketool.h"
|
2020-03-03 12:23:04 +01:00
|
|
|
#include "cmaketoolmanager.h"
|
2015-02-24 21:57:00 +01:00
|
|
|
|
2017-08-29 11:48:48 +02:00
|
|
|
#include <app/app_version.h>
|
2019-02-06 15:04:17 +01:00
|
|
|
#include <coreplugin/icore.h>
|
|
|
|
|
#include <coreplugin/variablechooser.h>
|
2015-02-24 21:57:00 +01:00
|
|
|
#include <projectexplorer/kit.h>
|
2016-02-12 12:23:18 +01:00
|
|
|
#include <projectexplorer/kitinformation.h>
|
2020-04-17 08:53:16 +02:00
|
|
|
#include <projectexplorer/projectexplorer.h>
|
|
|
|
|
#include <projectexplorer/projectexplorersettings.h>
|
|
|
|
|
#include <projectexplorer/task.h>
|
|
|
|
|
#include <projectexplorer/toolchain.h>
|
2016-09-19 11:53:30 +02:00
|
|
|
#include <qtsupport/baseqtversion.h>
|
2016-02-12 12:23:18 +01:00
|
|
|
#include <qtsupport/qtkitinformation.h>
|
2015-02-24 21:57:00 +01:00
|
|
|
#include <projectexplorer/projectexplorerconstants.h>
|
2016-02-12 12:23:18 +01:00
|
|
|
#include <utils/algorithm.h>
|
2019-02-06 15:04:17 +01:00
|
|
|
#include <utils/elidinglabel.h>
|
2016-02-29 14:26:50 +01:00
|
|
|
#include <utils/environment.h>
|
2016-02-12 12:10:28 +01:00
|
|
|
#include <utils/qtcassert.h>
|
2015-02-24 21:57:00 +01:00
|
|
|
|
2019-02-06 15:04:17 +01:00
|
|
|
#include <QComboBox>
|
|
|
|
|
#include <QDialog>
|
|
|
|
|
#include <QDialogButtonBox>
|
2019-08-05 12:57:01 +02:00
|
|
|
#include <QFileInfo>
|
2019-02-06 15:04:17 +01:00
|
|
|
#include <QGridLayout>
|
|
|
|
|
#include <QLabel>
|
|
|
|
|
#include <QLineEdit>
|
|
|
|
|
#include <QPlainTextEdit>
|
|
|
|
|
#include <QPointer>
|
|
|
|
|
#include <QPushButton>
|
2016-09-19 11:53:30 +02:00
|
|
|
#include <QVariant>
|
|
|
|
|
|
2015-02-24 21:57:00 +01:00
|
|
|
using namespace ProjectExplorer;
|
|
|
|
|
|
|
|
|
|
namespace CMakeProjectManager {
|
2016-02-04 18:09:31 +01:00
|
|
|
// --------------------------------------------------------------------
|
2019-02-06 12:50:51 +01:00
|
|
|
// CMakeKitAspect:
|
2016-02-04 18:09:31 +01:00
|
|
|
// --------------------------------------------------------------------
|
2015-02-24 21:57:00 +01:00
|
|
|
|
2016-02-04 17:52:55 +01:00
|
|
|
static Core::Id defaultCMakeToolId()
|
|
|
|
|
{
|
|
|
|
|
CMakeTool *defaultTool = CMakeToolManager::defaultCMakeTool();
|
2016-02-04 18:09:31 +01:00
|
|
|
return defaultTool ? defaultTool->id() : Core::Id();
|
2016-02-04 17:52:55 +01:00
|
|
|
}
|
|
|
|
|
|
2016-02-04 18:09:31 +01:00
|
|
|
static const char TOOL_ID[] = "CMakeProjectManager.CMakeKitInformation";
|
|
|
|
|
|
2019-02-06 15:04:17 +01:00
|
|
|
class CMakeKitAspectWidget : public KitAspectWidget
|
|
|
|
|
{
|
|
|
|
|
Q_DECLARE_TR_FUNCTIONS(CMakeProjectManager::Internal::CMakeKitAspect)
|
|
|
|
|
public:
|
|
|
|
|
CMakeKitAspectWidget(Kit *kit, const KitAspect *ki) : KitAspectWidget(kit, ki),
|
|
|
|
|
m_comboBox(new QComboBox),
|
|
|
|
|
m_manageButton(new QPushButton(KitAspectWidget::msgManage()))
|
|
|
|
|
{
|
|
|
|
|
m_comboBox->setSizePolicy(QSizePolicy::Ignored, m_comboBox->sizePolicy().verticalPolicy());
|
|
|
|
|
m_comboBox->setEnabled(false);
|
2019-02-11 17:10:03 +01:00
|
|
|
m_comboBox->setToolTip(ki->description());
|
2019-02-06 15:04:17 +01:00
|
|
|
|
|
|
|
|
foreach (CMakeTool *tool, CMakeToolManager::cmakeTools())
|
|
|
|
|
cmakeToolAdded(tool->id());
|
|
|
|
|
|
|
|
|
|
updateComboBox();
|
|
|
|
|
refresh();
|
2019-05-27 23:28:48 +02:00
|
|
|
connect(m_comboBox, QOverload<int>::of(&QComboBox::currentIndexChanged),
|
2019-02-06 15:04:17 +01:00
|
|
|
this, &CMakeKitAspectWidget::currentCMakeToolChanged);
|
|
|
|
|
|
|
|
|
|
m_manageButton->setContentsMargins(0, 0, 0, 0);
|
|
|
|
|
connect(m_manageButton, &QPushButton::clicked,
|
|
|
|
|
this, &CMakeKitAspectWidget::manageCMakeTools);
|
|
|
|
|
|
|
|
|
|
CMakeToolManager *cmakeMgr = CMakeToolManager::instance();
|
|
|
|
|
connect(cmakeMgr, &CMakeToolManager::cmakeAdded,
|
|
|
|
|
this, &CMakeKitAspectWidget::cmakeToolAdded);
|
|
|
|
|
connect(cmakeMgr, &CMakeToolManager::cmakeRemoved,
|
|
|
|
|
this, &CMakeKitAspectWidget::cmakeToolRemoved);
|
|
|
|
|
connect(cmakeMgr, &CMakeToolManager::cmakeUpdated,
|
|
|
|
|
this, &CMakeKitAspectWidget::cmakeToolUpdated);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
~CMakeKitAspectWidget() override
|
|
|
|
|
{
|
|
|
|
|
delete m_comboBox;
|
|
|
|
|
delete m_manageButton;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
// KitAspectWidget interface
|
|
|
|
|
void makeReadOnly() override { m_comboBox->setEnabled(false); }
|
|
|
|
|
QWidget *mainWidget() const override { return m_comboBox; }
|
|
|
|
|
QWidget *buttonWidget() const override { return m_manageButton; }
|
|
|
|
|
|
|
|
|
|
void refresh() override
|
|
|
|
|
{
|
|
|
|
|
CMakeTool *tool = CMakeKitAspect::cmakeTool(m_kit);
|
|
|
|
|
m_comboBox->setCurrentIndex(tool ? indexOf(tool->id()) : -1);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int indexOf(const Core::Id &id)
|
|
|
|
|
{
|
|
|
|
|
for (int i = 0; i < m_comboBox->count(); ++i) {
|
|
|
|
|
if (id == Core::Id::fromSetting(m_comboBox->itemData(i)))
|
|
|
|
|
return i;
|
|
|
|
|
}
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void updateComboBox()
|
|
|
|
|
{
|
|
|
|
|
// remove unavailable cmake tool:
|
|
|
|
|
int pos = indexOf(Core::Id());
|
|
|
|
|
if (pos >= 0)
|
|
|
|
|
m_comboBox->removeItem(pos);
|
|
|
|
|
|
|
|
|
|
if (m_comboBox->count() == 0) {
|
|
|
|
|
m_comboBox->addItem(tr("<No CMake Tool available>"),
|
|
|
|
|
Core::Id().toSetting());
|
|
|
|
|
m_comboBox->setEnabled(false);
|
|
|
|
|
} else {
|
|
|
|
|
m_comboBox->setEnabled(true);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void cmakeToolAdded(const Core::Id &id)
|
|
|
|
|
{
|
|
|
|
|
const CMakeTool *tool = CMakeToolManager::findById(id);
|
|
|
|
|
QTC_ASSERT(tool, return);
|
|
|
|
|
|
|
|
|
|
m_comboBox->addItem(tool->displayName(), tool->id().toSetting());
|
|
|
|
|
updateComboBox();
|
|
|
|
|
refresh();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void cmakeToolUpdated(const Core::Id &id)
|
|
|
|
|
{
|
|
|
|
|
const int pos = indexOf(id);
|
|
|
|
|
QTC_ASSERT(pos >= 0, return);
|
|
|
|
|
|
|
|
|
|
const CMakeTool *tool = CMakeToolManager::findById(id);
|
|
|
|
|
QTC_ASSERT(tool, return);
|
|
|
|
|
|
|
|
|
|
m_comboBox->setItemText(pos, tool->displayName());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void cmakeToolRemoved(const Core::Id &id)
|
|
|
|
|
{
|
|
|
|
|
const int pos = indexOf(id);
|
|
|
|
|
QTC_ASSERT(pos >= 0, return);
|
|
|
|
|
|
|
|
|
|
// do not handle the current index changed signal
|
|
|
|
|
m_removingItem = true;
|
|
|
|
|
m_comboBox->removeItem(pos);
|
|
|
|
|
m_removingItem = false;
|
|
|
|
|
|
|
|
|
|
// update the checkbox and set the current index
|
|
|
|
|
updateComboBox();
|
|
|
|
|
refresh();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void currentCMakeToolChanged(int index)
|
|
|
|
|
{
|
|
|
|
|
if (m_removingItem)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
const Core::Id id = Core::Id::fromSetting(m_comboBox->itemData(index));
|
|
|
|
|
CMakeKitAspect::setCMakeTool(m_kit, id);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void manageCMakeTools()
|
|
|
|
|
{
|
|
|
|
|
Core::ICore::showOptionsDialog(Constants::CMAKE_SETTINGSPAGE_ID,
|
|
|
|
|
buttonWidget());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool m_removingItem = false;
|
|
|
|
|
QComboBox *m_comboBox;
|
|
|
|
|
QPushButton *m_manageButton;
|
|
|
|
|
};
|
2016-01-22 17:17:36 +01:00
|
|
|
|
2019-02-06 12:50:51 +01:00
|
|
|
CMakeKitAspect::CMakeKitAspect()
|
2015-02-24 21:57:00 +01:00
|
|
|
{
|
2019-02-06 12:50:51 +01:00
|
|
|
setObjectName(QLatin1String("CMakeKitAspect"));
|
2016-02-04 18:09:31 +01:00
|
|
|
setId(TOOL_ID);
|
2019-02-06 16:16:07 +01:00
|
|
|
setDisplayName(tr("CMake Tool"));
|
|
|
|
|
setDescription(tr("The CMake Tool to use when building a project with CMake.<br>"
|
|
|
|
|
"This setting is ignored when using other build systems."));
|
2015-08-02 20:21:21 +03:00
|
|
|
setPriority(20000);
|
2015-02-24 21:57:00 +01:00
|
|
|
|
|
|
|
|
//make sure the default value is set if a selected CMake is removed
|
|
|
|
|
connect(CMakeToolManager::instance(), &CMakeToolManager::cmakeRemoved,
|
|
|
|
|
[this]() { foreach (Kit *k, KitManager::kits()) fix(k); });
|
|
|
|
|
|
|
|
|
|
//make sure the default value is set if a new default CMake is set
|
|
|
|
|
connect(CMakeToolManager::instance(), &CMakeToolManager::defaultCMakeChanged,
|
|
|
|
|
[this]() { foreach (Kit *k, KitManager::kits()) fix(k); });
|
|
|
|
|
}
|
|
|
|
|
|
2019-02-06 12:50:51 +01:00
|
|
|
Core::Id CMakeKitAspect::id()
|
2016-08-25 14:33:44 +02:00
|
|
|
{
|
|
|
|
|
return TOOL_ID;
|
|
|
|
|
}
|
|
|
|
|
|
2019-02-06 12:50:51 +01:00
|
|
|
Core::Id CMakeKitAspect::cmakeToolId(const Kit *k)
|
2015-02-24 21:57:00 +01:00
|
|
|
{
|
|
|
|
|
if (!k)
|
2018-05-24 16:57:31 +02:00
|
|
|
return {};
|
|
|
|
|
return Core::Id::fromSetting(k->value(TOOL_ID));
|
|
|
|
|
}
|
2015-02-24 21:57:00 +01:00
|
|
|
|
2019-02-06 12:50:51 +01:00
|
|
|
CMakeTool *CMakeKitAspect::cmakeTool(const Kit *k)
|
2018-05-24 16:57:31 +02:00
|
|
|
{
|
|
|
|
|
return CMakeToolManager::findById(cmakeToolId(k));
|
2015-02-24 21:57:00 +01:00
|
|
|
}
|
|
|
|
|
|
2019-02-06 12:50:51 +01:00
|
|
|
void CMakeKitAspect::setCMakeTool(Kit *k, const Core::Id id)
|
2015-02-24 21:57:00 +01:00
|
|
|
{
|
2016-02-04 18:09:31 +01:00
|
|
|
const Core::Id toSet = id.isValid() ? id : defaultCMakeToolId();
|
|
|
|
|
QTC_ASSERT(!id.isValid() || CMakeToolManager::findById(toSet), return);
|
|
|
|
|
if (k)
|
|
|
|
|
k->setValue(TOOL_ID, toSet.toSetting());
|
2015-02-24 21:57:00 +01:00
|
|
|
}
|
|
|
|
|
|
2019-05-27 16:09:44 +02:00
|
|
|
Tasks CMakeKitAspect::validate(const Kit *k) const
|
2015-02-24 21:57:00 +01:00
|
|
|
{
|
2019-05-27 16:09:44 +02:00
|
|
|
Tasks result;
|
2019-02-06 12:50:51 +01:00
|
|
|
CMakeTool *tool = CMakeKitAspect::cmakeTool(k);
|
2016-09-28 17:26:02 +02:00
|
|
|
if (tool) {
|
|
|
|
|
CMakeTool::Version version = tool->version();
|
|
|
|
|
if (version.major < 3) {
|
2020-01-15 08:56:11 +01:00
|
|
|
result << BuildSystemTask(Task::Warning, tr("CMake version %1 is unsupported. Please update to "
|
|
|
|
|
"version 3.0 or later.").arg(QString::fromUtf8(version.fullVersion)));
|
2016-09-28 17:26:02 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return result;
|
2015-02-24 21:57:00 +01:00
|
|
|
}
|
|
|
|
|
|
2019-02-06 12:50:51 +01:00
|
|
|
void CMakeKitAspect::setup(Kit *k)
|
2015-02-24 21:57:00 +01:00
|
|
|
{
|
2019-02-06 12:50:51 +01:00
|
|
|
CMakeTool *tool = CMakeKitAspect::cmakeTool(k);
|
2016-02-04 18:09:31 +01:00
|
|
|
if (!tool)
|
|
|
|
|
setCMakeTool(k, defaultCMakeToolId());
|
2015-02-24 21:57:00 +01:00
|
|
|
}
|
|
|
|
|
|
2019-02-06 12:50:51 +01:00
|
|
|
void CMakeKitAspect::fix(Kit *k)
|
2015-02-24 21:57:00 +01:00
|
|
|
{
|
2019-03-12 16:50:39 +01:00
|
|
|
setup(k);
|
2015-02-24 21:57:00 +01:00
|
|
|
}
|
|
|
|
|
|
2019-02-06 12:50:51 +01:00
|
|
|
KitAspect::ItemList CMakeKitAspect::toUserOutput(const Kit *k) const
|
2015-02-24 21:57:00 +01:00
|
|
|
{
|
2016-02-04 18:09:31 +01:00
|
|
|
const CMakeTool *const tool = cmakeTool(k);
|
2019-05-28 08:28:51 +02:00
|
|
|
return {{tr("CMake"), tool ? tool->displayName() : tr("Unconfigured")}};
|
2015-02-24 21:57:00 +01:00
|
|
|
}
|
|
|
|
|
|
2019-02-06 12:50:51 +01:00
|
|
|
KitAspectWidget *CMakeKitAspect::createConfigWidget(Kit *k) const
|
2015-02-24 21:57:00 +01:00
|
|
|
{
|
2018-02-12 12:49:22 +01:00
|
|
|
QTC_ASSERT(k, return nullptr);
|
2019-02-06 15:04:17 +01:00
|
|
|
return new CMakeKitAspectWidget(k, this);
|
2015-02-24 21:57:00 +01:00
|
|
|
}
|
|
|
|
|
|
2019-02-06 12:50:51 +01:00
|
|
|
void CMakeKitAspect::addToMacroExpander(Kit *k, Utils::MacroExpander *expander) const
|
2015-11-23 12:45:47 +01:00
|
|
|
{
|
2018-02-12 12:49:22 +01:00
|
|
|
QTC_ASSERT(k, return);
|
2015-11-23 12:45:47 +01:00
|
|
|
expander->registerFileVariables("CMake:Executable", tr("Path to the cmake executable"),
|
2017-09-07 17:05:47 +02:00
|
|
|
[k]() -> QString {
|
2019-02-06 12:50:51 +01:00
|
|
|
CMakeTool *tool = CMakeKitAspect::cmakeTool(k);
|
2015-11-23 12:45:47 +01:00
|
|
|
return tool ? tool->cmakeExecutable().toString() : QString();
|
2017-04-03 14:31:32 +02:00
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
2019-02-06 12:50:51 +01:00
|
|
|
QSet<Core::Id> CMakeKitAspect::availableFeatures(const Kit *k) const
|
2017-04-03 14:31:32 +02:00
|
|
|
{
|
|
|
|
|
if (cmakeTool(k))
|
|
|
|
|
return { CMakeProjectManager::Constants::CMAKE_FEATURE_ID };
|
|
|
|
|
return {};
|
2015-11-23 12:45:47 +01:00
|
|
|
}
|
|
|
|
|
|
2016-01-22 17:17:36 +01:00
|
|
|
// --------------------------------------------------------------------
|
2019-02-06 12:50:51 +01:00
|
|
|
// CMakeGeneratorKitAspect:
|
2016-01-22 17:17:36 +01:00
|
|
|
// --------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
static const char GENERATOR_ID[] = "CMake.GeneratorKitInformation";
|
|
|
|
|
|
2016-09-27 13:26:54 +02:00
|
|
|
static const char GENERATOR_KEY[] = "Generator";
|
|
|
|
|
static const char EXTRA_GENERATOR_KEY[] = "ExtraGenerator";
|
|
|
|
|
static const char PLATFORM_KEY[] = "Platform";
|
|
|
|
|
static const char TOOLSET_KEY[] = "Toolset";
|
|
|
|
|
|
2019-02-06 15:04:17 +01:00
|
|
|
class CMakeGeneratorKitAspectWidget : public KitAspectWidget
|
|
|
|
|
{
|
|
|
|
|
Q_DECLARE_TR_FUNCTIONS(CMakeProjectManager::Internal::CMakeGeneratorKitAspect)
|
|
|
|
|
public:
|
|
|
|
|
CMakeGeneratorKitAspectWidget(Kit *kit, const ::KitAspect *ki)
|
|
|
|
|
: KitAspectWidget(kit, ki),
|
2019-11-21 22:06:38 +01:00
|
|
|
m_label(new Utils::ElidingLabel),
|
2019-02-06 15:04:17 +01:00
|
|
|
m_changeButton(new QPushButton)
|
|
|
|
|
{
|
2019-02-11 17:10:03 +01:00
|
|
|
m_label->setToolTip(ki->description());
|
2019-02-06 15:04:17 +01:00
|
|
|
m_changeButton->setText(tr("Change..."));
|
|
|
|
|
refresh();
|
|
|
|
|
connect(m_changeButton, &QPushButton::clicked,
|
|
|
|
|
this, &CMakeGeneratorKitAspectWidget::changeGenerator);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
~CMakeGeneratorKitAspectWidget() override
|
|
|
|
|
{
|
|
|
|
|
delete m_label;
|
|
|
|
|
delete m_changeButton;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
// KitAspectWidget interface
|
|
|
|
|
void makeReadOnly() override { m_changeButton->setEnabled(false); }
|
|
|
|
|
QWidget *mainWidget() const override { return m_label; }
|
|
|
|
|
QWidget *buttonWidget() const override { return m_changeButton; }
|
|
|
|
|
|
|
|
|
|
void refresh() override
|
|
|
|
|
{
|
|
|
|
|
if (m_ignoreChange)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
CMakeTool *const tool = CMakeKitAspect::cmakeTool(m_kit);
|
|
|
|
|
if (tool != m_currentTool)
|
|
|
|
|
m_currentTool = tool;
|
|
|
|
|
|
|
|
|
|
m_changeButton->setEnabled(m_currentTool);
|
|
|
|
|
const QString generator = CMakeGeneratorKitAspect::generator(kit());
|
|
|
|
|
const QString extraGenerator = CMakeGeneratorKitAspect::extraGenerator(kit());
|
|
|
|
|
const QString platform = CMakeGeneratorKitAspect::platform(kit());
|
|
|
|
|
const QString toolset = CMakeGeneratorKitAspect::toolset(kit());
|
|
|
|
|
|
|
|
|
|
const QString message = tr("%1 - %2, Platform: %3, Toolset: %4")
|
|
|
|
|
.arg(extraGenerator.isEmpty() ? tr("<none>") : extraGenerator)
|
|
|
|
|
.arg(generator.isEmpty() ? tr("<none>") : generator)
|
|
|
|
|
.arg(platform.isEmpty() ? tr("<none>") : platform)
|
|
|
|
|
.arg(toolset.isEmpty() ? tr("<none>") : toolset);
|
|
|
|
|
m_label->setText(message);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void changeGenerator()
|
|
|
|
|
{
|
|
|
|
|
QPointer<QDialog> changeDialog = new QDialog(m_changeButton);
|
|
|
|
|
|
|
|
|
|
// Disable help button in titlebar on windows:
|
|
|
|
|
Qt::WindowFlags flags = changeDialog->windowFlags();
|
|
|
|
|
flags |= Qt::MSWindowsFixedSizeDialogHint;
|
|
|
|
|
changeDialog->setWindowFlags(flags);
|
|
|
|
|
|
|
|
|
|
changeDialog->setWindowTitle(tr("CMake Generator"));
|
|
|
|
|
|
|
|
|
|
auto *layout = new QGridLayout(changeDialog);
|
|
|
|
|
layout->setSizeConstraint(QLayout::SetFixedSize);
|
|
|
|
|
|
|
|
|
|
auto *cmakeLabel = new QLabel;
|
|
|
|
|
cmakeLabel->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed);
|
|
|
|
|
|
|
|
|
|
auto *generatorCombo = new QComboBox;
|
|
|
|
|
auto *extraGeneratorCombo = new QComboBox;
|
|
|
|
|
auto *platformEdit = new QLineEdit;
|
|
|
|
|
auto *toolsetEdit = new QLineEdit;
|
|
|
|
|
|
|
|
|
|
int row = 0;
|
|
|
|
|
layout->addWidget(new QLabel(QLatin1String("Executable:")));
|
|
|
|
|
layout->addWidget(cmakeLabel, row, 1);
|
|
|
|
|
|
|
|
|
|
++row;
|
|
|
|
|
layout->addWidget(new QLabel(tr("Generator:")), row, 0);
|
|
|
|
|
layout->addWidget(generatorCombo, row, 1);
|
|
|
|
|
|
|
|
|
|
++row;
|
|
|
|
|
layout->addWidget(new QLabel(tr("Extra generator:")), row, 0);
|
|
|
|
|
layout->addWidget(extraGeneratorCombo, row, 1);
|
|
|
|
|
|
|
|
|
|
++row;
|
|
|
|
|
layout->addWidget(new QLabel(tr("Platform:")), row, 0);
|
|
|
|
|
layout->addWidget(platformEdit, row, 1);
|
|
|
|
|
|
|
|
|
|
++row;
|
|
|
|
|
layout->addWidget(new QLabel(tr("Toolset:")), row, 0);
|
|
|
|
|
layout->addWidget(toolsetEdit, row, 1);
|
|
|
|
|
|
|
|
|
|
++row;
|
|
|
|
|
auto *bb = new QDialogButtonBox(QDialogButtonBox::Ok|QDialogButtonBox::Cancel);
|
|
|
|
|
layout->addWidget(bb, row, 0, 1, 2);
|
|
|
|
|
|
|
|
|
|
connect(bb, &QDialogButtonBox::accepted, changeDialog.data(), &QDialog::accept);
|
|
|
|
|
connect(bb, &QDialogButtonBox::rejected, changeDialog.data(), &QDialog::reject);
|
|
|
|
|
|
|
|
|
|
cmakeLabel->setText(m_currentTool->cmakeExecutable().toUserOutput());
|
|
|
|
|
|
|
|
|
|
QList<CMakeTool::Generator> generatorList = m_currentTool->supportedGenerators();
|
|
|
|
|
Utils::sort(generatorList, &CMakeTool::Generator::name);
|
|
|
|
|
|
|
|
|
|
for (auto it = generatorList.constBegin(); it != generatorList.constEnd(); ++it)
|
|
|
|
|
generatorCombo->addItem(it->name);
|
|
|
|
|
|
|
|
|
|
auto updateDialog = [&generatorList, generatorCombo, extraGeneratorCombo,
|
|
|
|
|
platformEdit, toolsetEdit](const QString &name) {
|
|
|
|
|
auto it = std::find_if(generatorList.constBegin(), generatorList.constEnd(),
|
|
|
|
|
[name](const CMakeTool::Generator &g) { return g.name == name; });
|
|
|
|
|
QTC_ASSERT(it != generatorList.constEnd(), return);
|
|
|
|
|
generatorCombo->setCurrentText(name);
|
|
|
|
|
|
|
|
|
|
extraGeneratorCombo->clear();
|
|
|
|
|
extraGeneratorCombo->addItem(tr("<none>"), QString());
|
|
|
|
|
foreach (const QString &eg, it->extraGenerators)
|
|
|
|
|
extraGeneratorCombo->addItem(eg, eg);
|
|
|
|
|
extraGeneratorCombo->setEnabled(extraGeneratorCombo->count() > 1);
|
|
|
|
|
|
|
|
|
|
platformEdit->setEnabled(it->supportsPlatform);
|
|
|
|
|
toolsetEdit->setEnabled(it->supportsToolset);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
updateDialog(CMakeGeneratorKitAspect::generator(kit()));
|
|
|
|
|
|
|
|
|
|
generatorCombo->setCurrentText(CMakeGeneratorKitAspect::generator(kit()));
|
|
|
|
|
extraGeneratorCombo->setCurrentText(CMakeGeneratorKitAspect::extraGenerator(kit()));
|
|
|
|
|
platformEdit->setText(platformEdit->isEnabled() ? CMakeGeneratorKitAspect::platform(kit()) : QLatin1String("<unsupported>"));
|
|
|
|
|
toolsetEdit->setText(toolsetEdit->isEnabled() ? CMakeGeneratorKitAspect::toolset(kit()) : QLatin1String("<unsupported>"));
|
|
|
|
|
|
|
|
|
|
connect(generatorCombo, &QComboBox::currentTextChanged, updateDialog);
|
|
|
|
|
|
|
|
|
|
if (changeDialog->exec() == QDialog::Accepted) {
|
|
|
|
|
if (!changeDialog)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
CMakeGeneratorKitAspect::set(kit(), generatorCombo->currentText(),
|
|
|
|
|
extraGeneratorCombo->currentData().toString(),
|
|
|
|
|
platformEdit->isEnabled() ? platformEdit->text() : QString(),
|
|
|
|
|
toolsetEdit->isEnabled() ? toolsetEdit->text() : QString());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool m_ignoreChange = false;
|
2019-11-21 22:06:38 +01:00
|
|
|
Utils::ElidingLabel *m_label;
|
2019-02-06 15:04:17 +01:00
|
|
|
QPushButton *m_changeButton;
|
|
|
|
|
CMakeTool *m_currentTool = nullptr;
|
|
|
|
|
};
|
|
|
|
|
|
2016-09-27 13:26:54 +02:00
|
|
|
namespace {
|
|
|
|
|
|
|
|
|
|
struct GeneratorInfo {
|
|
|
|
|
QVariant toVariant() const {
|
|
|
|
|
QVariantMap result;
|
|
|
|
|
result.insert(GENERATOR_KEY, generator);
|
|
|
|
|
result.insert(EXTRA_GENERATOR_KEY, extraGenerator);
|
|
|
|
|
result.insert(PLATFORM_KEY, platform);
|
|
|
|
|
result.insert(TOOLSET_KEY, toolset);
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
void fromVariant(const QVariant &v) {
|
|
|
|
|
const QVariantMap value = v.toMap();
|
|
|
|
|
|
|
|
|
|
generator = value.value(GENERATOR_KEY).toString();
|
|
|
|
|
extraGenerator = value.value(EXTRA_GENERATOR_KEY).toString();
|
|
|
|
|
platform = value.value(PLATFORM_KEY).toString();
|
|
|
|
|
toolset = value.value(TOOLSET_KEY).toString();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QString generator;
|
|
|
|
|
QString extraGenerator;
|
|
|
|
|
QString platform;
|
|
|
|
|
QString toolset;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
} // namespace
|
|
|
|
|
|
|
|
|
|
static GeneratorInfo generatorInfo(const Kit *k)
|
|
|
|
|
{
|
|
|
|
|
GeneratorInfo info;
|
|
|
|
|
if (!k)
|
|
|
|
|
return info;
|
|
|
|
|
|
|
|
|
|
info.fromVariant(k->value(GENERATOR_ID));
|
|
|
|
|
return info;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void setGeneratorInfo(Kit *k, const GeneratorInfo &info)
|
|
|
|
|
{
|
|
|
|
|
if (!k)
|
|
|
|
|
return;
|
|
|
|
|
k->setValue(GENERATOR_ID, info.toVariant());
|
|
|
|
|
}
|
|
|
|
|
|
2019-02-06 12:50:51 +01:00
|
|
|
CMakeGeneratorKitAspect::CMakeGeneratorKitAspect()
|
2016-01-22 17:17:36 +01:00
|
|
|
{
|
2019-02-06 12:50:51 +01:00
|
|
|
setObjectName(QLatin1String("CMakeGeneratorKitAspect"));
|
2016-01-22 17:17:36 +01:00
|
|
|
setId(GENERATOR_ID);
|
2019-02-06 16:16:07 +01:00
|
|
|
setDisplayName(tr("CMake generator"));
|
|
|
|
|
setDescription(tr("CMake generator defines how a project is built when using CMake.<br>"
|
|
|
|
|
"This setting is ignored when using other build systems."));
|
2016-01-22 17:17:36 +01:00
|
|
|
setPriority(19000);
|
|
|
|
|
}
|
|
|
|
|
|
2019-02-06 12:50:51 +01:00
|
|
|
QString CMakeGeneratorKitAspect::generator(const Kit *k)
|
2016-01-22 17:17:36 +01:00
|
|
|
{
|
2016-09-27 13:26:54 +02:00
|
|
|
return generatorInfo(k).generator;
|
|
|
|
|
}
|
|
|
|
|
|
2019-02-06 12:50:51 +01:00
|
|
|
QString CMakeGeneratorKitAspect::extraGenerator(const Kit *k)
|
2016-09-27 13:26:54 +02:00
|
|
|
{
|
|
|
|
|
return generatorInfo(k).extraGenerator;
|
|
|
|
|
}
|
|
|
|
|
|
2019-02-06 12:50:51 +01:00
|
|
|
QString CMakeGeneratorKitAspect::platform(const Kit *k)
|
2016-09-27 13:26:54 +02:00
|
|
|
{
|
|
|
|
|
return generatorInfo(k).platform;
|
|
|
|
|
}
|
|
|
|
|
|
2019-02-06 12:50:51 +01:00
|
|
|
QString CMakeGeneratorKitAspect::toolset(const Kit *k)
|
2016-09-27 13:26:54 +02:00
|
|
|
{
|
|
|
|
|
return generatorInfo(k).toolset;
|
2016-01-22 17:17:36 +01:00
|
|
|
}
|
|
|
|
|
|
2019-02-06 12:50:51 +01:00
|
|
|
void CMakeGeneratorKitAspect::setGenerator(Kit *k, const QString &generator)
|
2016-01-22 17:17:36 +01:00
|
|
|
{
|
2016-09-27 13:26:54 +02:00
|
|
|
GeneratorInfo info = generatorInfo(k);
|
|
|
|
|
info.generator = generator;
|
|
|
|
|
setGeneratorInfo(k, info);
|
2016-01-22 17:17:36 +01:00
|
|
|
}
|
|
|
|
|
|
2019-02-06 12:50:51 +01:00
|
|
|
void CMakeGeneratorKitAspect::setExtraGenerator(Kit *k, const QString &extraGenerator)
|
2016-01-22 17:17:36 +01:00
|
|
|
{
|
2016-09-27 13:26:54 +02:00
|
|
|
GeneratorInfo info = generatorInfo(k);
|
|
|
|
|
info.extraGenerator = extraGenerator;
|
|
|
|
|
setGeneratorInfo(k, info);
|
|
|
|
|
}
|
|
|
|
|
|
2019-02-06 12:50:51 +01:00
|
|
|
void CMakeGeneratorKitAspect::setPlatform(Kit *k, const QString &platform)
|
2016-09-27 13:26:54 +02:00
|
|
|
{
|
|
|
|
|
GeneratorInfo info = generatorInfo(k);
|
|
|
|
|
info.platform = platform;
|
|
|
|
|
setGeneratorInfo(k, info);
|
|
|
|
|
}
|
|
|
|
|
|
2019-02-06 12:50:51 +01:00
|
|
|
void CMakeGeneratorKitAspect::setToolset(Kit *k, const QString &toolset)
|
2016-09-27 13:26:54 +02:00
|
|
|
{
|
|
|
|
|
GeneratorInfo info = generatorInfo(k);
|
|
|
|
|
info.toolset = toolset;
|
|
|
|
|
setGeneratorInfo(k, info);
|
|
|
|
|
}
|
|
|
|
|
|
2019-02-06 12:50:51 +01:00
|
|
|
void CMakeGeneratorKitAspect::set(Kit *k,
|
2016-09-28 12:24:06 +02:00
|
|
|
const QString &generator, const QString &extraGenerator,
|
|
|
|
|
const QString &platform, const QString &toolset)
|
|
|
|
|
{
|
2017-02-22 15:09:35 +01:00
|
|
|
GeneratorInfo info = {generator, extraGenerator, platform, toolset};
|
2016-09-28 12:24:06 +02:00
|
|
|
setGeneratorInfo(k, info);
|
|
|
|
|
}
|
|
|
|
|
|
2019-02-06 12:50:51 +01:00
|
|
|
QStringList CMakeGeneratorKitAspect::generatorArguments(const Kit *k)
|
2016-09-27 13:26:54 +02:00
|
|
|
{
|
|
|
|
|
QStringList result;
|
|
|
|
|
GeneratorInfo info = generatorInfo(k);
|
|
|
|
|
if (info.generator.isEmpty())
|
|
|
|
|
return result;
|
|
|
|
|
|
|
|
|
|
if (info.extraGenerator.isEmpty()) {
|
|
|
|
|
result.append("-G" + info.generator);
|
|
|
|
|
} else {
|
2016-09-30 14:31:28 +02:00
|
|
|
result.append("-G" + info.extraGenerator + " - " + info.generator);
|
2016-09-27 13:26:54 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!info.platform.isEmpty())
|
|
|
|
|
result.append("-A" + info.platform);
|
|
|
|
|
|
|
|
|
|
if (!info.toolset.isEmpty())
|
|
|
|
|
result.append("-T" + info.toolset);
|
|
|
|
|
|
|
|
|
|
return result;
|
2016-01-22 17:17:36 +01:00
|
|
|
}
|
|
|
|
|
|
2019-02-06 12:50:51 +01:00
|
|
|
QVariant CMakeGeneratorKitAspect::defaultValue(const Kit *k) const
|
2016-01-22 17:17:36 +01:00
|
|
|
{
|
2018-02-12 12:49:22 +01:00
|
|
|
QTC_ASSERT(k, return QVariant());
|
|
|
|
|
|
2019-02-06 12:50:51 +01:00
|
|
|
CMakeTool *tool = CMakeKitAspect::cmakeTool(k);
|
2016-01-22 17:17:36 +01:00
|
|
|
if (!tool)
|
2016-09-27 13:26:54 +02:00
|
|
|
return QVariant();
|
2016-09-28 12:24:06 +02:00
|
|
|
|
2016-09-27 13:26:54 +02:00
|
|
|
const QString extraGenerator = "CodeBlocks";
|
|
|
|
|
|
2016-09-28 12:24:06 +02:00
|
|
|
QList<CMakeTool::Generator> known = tool->supportedGenerators();
|
2016-01-22 17:17:36 +01:00
|
|
|
auto it = std::find_if(known.constBegin(), known.constEnd(),
|
2016-09-28 12:24:06 +02:00
|
|
|
[extraGenerator](const CMakeTool::Generator &g) {
|
|
|
|
|
return g.matches("Ninja", extraGenerator);
|
|
|
|
|
});
|
2016-02-29 14:26:50 +01:00
|
|
|
if (it != known.constEnd()) {
|
2020-03-03 12:23:04 +01:00
|
|
|
const bool hasNinja = [k]() {
|
|
|
|
|
Internal::CMakeSpecificSettings *settings
|
|
|
|
|
= Internal::CMakeProjectPlugin::projectTypeSpecificSettings();
|
|
|
|
|
|
|
|
|
|
if (settings->ninjaPath().isEmpty()) {
|
|
|
|
|
Utils::Environment env = Utils::Environment::systemEnvironment();
|
|
|
|
|
k->addToEnvironment(env);
|
|
|
|
|
return !env.searchInPath("ninja").isEmpty();
|
|
|
|
|
}
|
|
|
|
|
return true;
|
|
|
|
|
}();
|
|
|
|
|
|
|
|
|
|
if (hasNinja)
|
2017-02-22 15:09:35 +01:00
|
|
|
return GeneratorInfo({QString("Ninja"), extraGenerator, QString(), QString()}).toVariant();
|
2016-02-29 14:26:50 +01:00
|
|
|
}
|
2016-09-28 12:24:06 +02:00
|
|
|
|
2016-03-02 10:18:06 +01:00
|
|
|
if (Utils::HostOsInfo::isWindowsHost()) {
|
|
|
|
|
// *sigh* Windows with its zoo of incompatible stuff again...
|
2019-02-06 12:50:51 +01:00
|
|
|
ToolChain *tc = ToolChainKitAspect::toolChain(k, ProjectExplorer::Constants::CXX_LANGUAGE_ID);
|
2016-03-02 10:18:06 +01:00
|
|
|
if (tc && tc->typeId() == ProjectExplorer::Constants::MINGW_TOOLCHAIN_TYPEID) {
|
2016-09-28 12:24:06 +02:00
|
|
|
it = std::find_if(known.constBegin(), known.constEnd(),
|
|
|
|
|
[extraGenerator](const CMakeTool::Generator &g) {
|
|
|
|
|
return g.matches("MinGW Makefiles", extraGenerator);
|
|
|
|
|
});
|
2016-03-02 10:18:06 +01:00
|
|
|
} else {
|
2016-09-28 12:24:06 +02:00
|
|
|
it = std::find_if(known.constBegin(), known.constEnd(),
|
|
|
|
|
[extraGenerator](const CMakeTool::Generator &g) {
|
2016-12-23 13:25:24 +03:00
|
|
|
return g.matches("NMake Makefiles", extraGenerator)
|
|
|
|
|
|| g.matches("NMake Makefiles JOM", extraGenerator);
|
2016-09-28 12:24:06 +02:00
|
|
|
});
|
2020-04-17 08:53:16 +02:00
|
|
|
if (ProjectExplorerPlugin::projectExplorerSettings().useJom) {
|
|
|
|
|
it = std::find_if(known.constBegin(),
|
|
|
|
|
known.constEnd(),
|
|
|
|
|
[extraGenerator](const CMakeTool::Generator &g) {
|
|
|
|
|
return g.matches("NMake Makefiles JOM", extraGenerator);
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (it == known.constEnd()) {
|
|
|
|
|
it = std::find_if(known.constBegin(),
|
|
|
|
|
known.constEnd(),
|
|
|
|
|
[extraGenerator](const CMakeTool::Generator &g) {
|
|
|
|
|
return g.matches("NMake Makefiles", extraGenerator);
|
|
|
|
|
});
|
|
|
|
|
}
|
2016-03-02 10:18:06 +01:00
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
// Unix-oid OSes:
|
2016-09-28 12:24:06 +02:00
|
|
|
it = std::find_if(known.constBegin(), known.constEnd(),
|
|
|
|
|
[extraGenerator](const CMakeTool::Generator &g) {
|
|
|
|
|
return g.matches("Unix Makefiles", extraGenerator);
|
|
|
|
|
});
|
2016-03-02 10:18:06 +01:00
|
|
|
}
|
2016-01-22 17:17:36 +01:00
|
|
|
if (it == known.constEnd())
|
|
|
|
|
it = known.constBegin(); // Fallback to the first generator...
|
2016-09-27 13:26:54 +02:00
|
|
|
if (it == known.constEnd())
|
|
|
|
|
return QVariant();
|
|
|
|
|
|
2017-02-22 15:09:35 +01:00
|
|
|
return GeneratorInfo({it->name, extraGenerator, QString(), QString()}).toVariant();
|
2016-01-22 17:17:36 +01:00
|
|
|
}
|
|
|
|
|
|
2019-05-27 16:09:44 +02:00
|
|
|
Tasks CMakeGeneratorKitAspect::validate(const Kit *k) const
|
2016-01-22 17:17:36 +01:00
|
|
|
{
|
2019-02-06 12:50:51 +01:00
|
|
|
CMakeTool *tool = CMakeKitAspect::cmakeTool(k);
|
2020-01-15 08:56:11 +01:00
|
|
|
if (!tool)
|
|
|
|
|
return {};
|
2016-01-22 17:17:36 +01:00
|
|
|
|
2019-05-27 16:09:44 +02:00
|
|
|
Tasks result;
|
2020-01-15 08:56:11 +01:00
|
|
|
const auto addWarning = [&result](const QString &desc) {
|
|
|
|
|
result << BuildSystemTask(Task::Warning, desc);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
if (!tool->isValid()) {
|
|
|
|
|
addWarning(tr("CMake Tool is unconfigured, CMake generator will be ignored."));
|
|
|
|
|
} else {
|
|
|
|
|
const GeneratorInfo info = generatorInfo(k);
|
|
|
|
|
QList<CMakeTool::Generator> known = tool->supportedGenerators();
|
|
|
|
|
auto it = std::find_if(known.constBegin(), known.constEnd(), [info](const CMakeTool::Generator &g) {
|
|
|
|
|
return g.matches(info.generator, info.extraGenerator);
|
|
|
|
|
});
|
|
|
|
|
if (it == known.constEnd()) {
|
|
|
|
|
addWarning(tr("CMake Tool does not support the configured generator."));
|
2016-01-22 17:17:36 +01:00
|
|
|
} else {
|
2020-01-15 08:56:11 +01:00
|
|
|
if (!it->supportsPlatform && !info.platform.isEmpty())
|
|
|
|
|
addWarning(tr("Platform is not supported by the selected CMake generator."));
|
|
|
|
|
if (!it->supportsToolset && !info.toolset.isEmpty())
|
|
|
|
|
addWarning(tr("Toolset is not supported by the selected CMake generator."));
|
|
|
|
|
}
|
|
|
|
|
if (!tool->hasServerMode() && !tool->hasFileApi() && info.extraGenerator != "CodeBlocks") {
|
|
|
|
|
addWarning(tr("The selected CMake binary has no server-mode and the CMake "
|
|
|
|
|
"generator does not generate a CodeBlocks file. "
|
|
|
|
|
"%1 will not be able to parse CMake projects.")
|
|
|
|
|
.arg(Core::Constants::IDE_DISPLAY_NAME));
|
2016-01-22 17:17:36 +01:00
|
|
|
}
|
|
|
|
|
}
|
2020-01-15 08:56:11 +01:00
|
|
|
|
2016-01-22 17:17:36 +01:00
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
2019-02-06 12:50:51 +01:00
|
|
|
void CMakeGeneratorKitAspect::setup(Kit *k)
|
2016-01-22 17:17:36 +01:00
|
|
|
{
|
2019-05-06 14:55:34 +02:00
|
|
|
if (!k || k->hasValue(id()))
|
|
|
|
|
return;
|
2016-09-27 13:26:54 +02:00
|
|
|
GeneratorInfo info;
|
|
|
|
|
info.fromVariant(defaultValue(k));
|
|
|
|
|
setGeneratorInfo(k, info);
|
2016-01-22 17:17:36 +01:00
|
|
|
}
|
|
|
|
|
|
2019-02-06 12:50:51 +01:00
|
|
|
void CMakeGeneratorKitAspect::fix(Kit *k)
|
2016-01-22 17:17:36 +01:00
|
|
|
{
|
2019-02-06 12:50:51 +01:00
|
|
|
const CMakeTool *tool = CMakeKitAspect::cmakeTool(k);
|
2016-09-27 13:26:54 +02:00
|
|
|
const GeneratorInfo info = generatorInfo(k);
|
2016-01-22 17:17:36 +01:00
|
|
|
|
|
|
|
|
if (!tool)
|
|
|
|
|
return;
|
2016-09-28 12:24:06 +02:00
|
|
|
QList<CMakeTool::Generator> known = tool->supportedGenerators();
|
|
|
|
|
auto it = std::find_if(known.constBegin(), known.constEnd(),
|
|
|
|
|
[info](const CMakeTool::Generator &g) {
|
|
|
|
|
return g.matches(info.generator, info.extraGenerator);
|
|
|
|
|
});
|
|
|
|
|
if (it == known.constEnd()) {
|
2016-09-27 13:26:54 +02:00
|
|
|
GeneratorInfo dv;
|
|
|
|
|
dv.fromVariant(defaultValue(k));
|
|
|
|
|
setGeneratorInfo(k, dv);
|
2016-09-28 12:24:06 +02:00
|
|
|
} else {
|
2017-02-22 15:09:35 +01:00
|
|
|
const GeneratorInfo dv = {info.generator, info.extraGenerator,
|
|
|
|
|
it->supportsPlatform ? info.platform : QString(),
|
|
|
|
|
it->supportsToolset ? info.toolset : QString()};
|
2016-09-28 12:24:06 +02:00
|
|
|
setGeneratorInfo(k, dv);
|
2016-09-27 13:26:54 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2019-02-06 12:50:51 +01:00
|
|
|
void CMakeGeneratorKitAspect::upgrade(Kit *k)
|
2016-09-27 13:26:54 +02:00
|
|
|
{
|
2018-02-12 12:49:22 +01:00
|
|
|
QTC_ASSERT(k, return);
|
|
|
|
|
|
2016-09-27 13:26:54 +02:00
|
|
|
const QVariant value = k->value(GENERATOR_ID);
|
|
|
|
|
if (value.type() != QVariant::Map) {
|
2016-12-02 15:15:04 +01:00
|
|
|
GeneratorInfo info;
|
2016-09-27 13:26:54 +02:00
|
|
|
const QString fullName = value.toString();
|
|
|
|
|
const int pos = fullName.indexOf(" - ");
|
|
|
|
|
if (pos >= 0) {
|
|
|
|
|
info.generator = fullName.mid(pos + 3);
|
|
|
|
|
info.extraGenerator = fullName.mid(0, pos);
|
|
|
|
|
} else {
|
|
|
|
|
info.generator = fullName;
|
|
|
|
|
}
|
2016-10-11 12:10:51 +02:00
|
|
|
setGeneratorInfo(k, info);
|
2016-09-27 13:26:54 +02:00
|
|
|
}
|
2016-01-22 17:17:36 +01:00
|
|
|
}
|
|
|
|
|
|
2019-02-06 12:50:51 +01:00
|
|
|
KitAspect::ItemList CMakeGeneratorKitAspect::toUserOutput(const Kit *k) const
|
2016-01-22 17:17:36 +01:00
|
|
|
{
|
2016-09-27 13:26:54 +02:00
|
|
|
const GeneratorInfo info = generatorInfo(k);
|
|
|
|
|
QString message;
|
|
|
|
|
if (info.generator.isEmpty()) {
|
|
|
|
|
message = tr("<Use Default Generator>");
|
|
|
|
|
} else {
|
2016-11-01 14:56:14 +01:00
|
|
|
message = tr("Generator: %1<br>Extra generator: %2").arg(info.generator).arg(info.extraGenerator);
|
2016-09-27 13:26:54 +02:00
|
|
|
if (!info.platform.isEmpty())
|
2017-09-13 15:56:47 +02:00
|
|
|
message += "<br/>" + tr("Platform: %1").arg(info.platform);
|
2016-09-27 13:26:54 +02:00
|
|
|
if (!info.toolset.isEmpty())
|
2017-09-13 15:56:47 +02:00
|
|
|
message += "<br/>" + tr("Toolset: %1").arg(info.toolset);
|
2016-09-27 13:26:54 +02:00
|
|
|
}
|
2019-05-28 08:28:51 +02:00
|
|
|
return {{tr("CMake Generator"), message}};
|
2016-01-22 17:17:36 +01:00
|
|
|
}
|
|
|
|
|
|
2019-02-06 12:50:51 +01:00
|
|
|
KitAspectWidget *CMakeGeneratorKitAspect::createConfigWidget(Kit *k) const
|
2016-01-22 17:17:36 +01:00
|
|
|
{
|
2019-02-06 15:04:17 +01:00
|
|
|
return new CMakeGeneratorKitAspectWidget(k, this);
|
2016-01-22 17:17:36 +01:00
|
|
|
}
|
|
|
|
|
|
2016-02-12 12:23:18 +01:00
|
|
|
// --------------------------------------------------------------------
|
2019-02-06 12:50:51 +01:00
|
|
|
// CMakeConfigurationKitAspect:
|
2016-02-12 12:23:18 +01:00
|
|
|
// --------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
static const char CONFIGURATION_ID[] = "CMake.ConfigurationKitInformation";
|
|
|
|
|
|
2016-07-18 02:08:25 -07:00
|
|
|
static const char CMAKE_C_TOOLCHAIN_KEY[] = "CMAKE_C_COMPILER";
|
|
|
|
|
static const char CMAKE_CXX_TOOLCHAIN_KEY[] = "CMAKE_CXX_COMPILER";
|
2016-09-19 11:53:30 +02:00
|
|
|
static const char CMAKE_QMAKE_KEY[] = "QT_QMAKE_EXECUTABLE";
|
|
|
|
|
static const char CMAKE_PREFIX_PATH_KEY[] = "CMAKE_PREFIX_PATH";
|
2016-02-12 12:23:18 +01:00
|
|
|
|
2019-02-06 15:04:17 +01:00
|
|
|
class CMakeConfigurationKitAspectWidget : public KitAspectWidget
|
|
|
|
|
{
|
|
|
|
|
Q_DECLARE_TR_FUNCTIONS(CMakeProjectManager::Internal::CMakeConfigurationKitAspect)
|
|
|
|
|
public:
|
|
|
|
|
CMakeConfigurationKitAspectWidget(Kit *kit, const KitAspect *ki)
|
|
|
|
|
: KitAspectWidget(kit, ki),
|
|
|
|
|
m_summaryLabel(new Utils::ElidingLabel),
|
|
|
|
|
m_manageButton(new QPushButton)
|
|
|
|
|
{
|
|
|
|
|
refresh();
|
|
|
|
|
m_manageButton->setText(tr("Change..."));
|
|
|
|
|
connect(m_manageButton, &QAbstractButton::clicked,
|
|
|
|
|
this, &CMakeConfigurationKitAspectWidget::editConfigurationChanges);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
// KitAspectWidget interface
|
|
|
|
|
QWidget *mainWidget() const override { return m_summaryLabel; }
|
|
|
|
|
QWidget *buttonWidget() const override { return m_manageButton; }
|
|
|
|
|
|
|
|
|
|
void makeReadOnly() override
|
|
|
|
|
{
|
|
|
|
|
m_manageButton->setEnabled(false);
|
|
|
|
|
if (m_dialog)
|
|
|
|
|
m_dialog->reject();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void refresh() override
|
|
|
|
|
{
|
|
|
|
|
const QStringList current = CMakeConfigurationKitAspect::toStringList(kit());
|
|
|
|
|
|
|
|
|
|
m_summaryLabel->setText(current.join("; "));
|
|
|
|
|
if (m_editor)
|
|
|
|
|
m_editor->setPlainText(current.join('\n'));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void editConfigurationChanges()
|
|
|
|
|
{
|
|
|
|
|
if (m_dialog) {
|
|
|
|
|
m_dialog->activateWindow();
|
|
|
|
|
m_dialog->raise();
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QTC_ASSERT(!m_editor, return);
|
|
|
|
|
|
|
|
|
|
m_dialog = new QDialog(m_summaryLabel->window());
|
|
|
|
|
m_dialog->setWindowTitle(tr("Edit CMake Configuration"));
|
|
|
|
|
auto layout = new QVBoxLayout(m_dialog);
|
|
|
|
|
m_editor = new QPlainTextEdit;
|
|
|
|
|
m_editor->setToolTip(tr("Enter one variable per line with the variable name "
|
|
|
|
|
"separated from the variable value by \"=\".<br>"
|
|
|
|
|
"You may provide a type hint by adding \":TYPE\" before the \"=\"."));
|
|
|
|
|
m_editor->setMinimumSize(800, 200);
|
|
|
|
|
|
|
|
|
|
auto chooser = new Core::VariableChooser(m_dialog);
|
|
|
|
|
chooser->addSupportedWidget(m_editor);
|
|
|
|
|
chooser->addMacroExpanderProvider([this]() { return kit()->macroExpander(); });
|
|
|
|
|
|
|
|
|
|
auto buttons = new QDialogButtonBox(QDialogButtonBox::Ok|QDialogButtonBox::Apply
|
|
|
|
|
|QDialogButtonBox::Reset|QDialogButtonBox::Cancel);
|
|
|
|
|
|
|
|
|
|
layout->addWidget(m_editor);
|
|
|
|
|
layout->addWidget(buttons);
|
|
|
|
|
|
|
|
|
|
connect(buttons, &QDialogButtonBox::accepted, m_dialog, &QDialog::accept);
|
|
|
|
|
connect(buttons, &QDialogButtonBox::rejected, m_dialog, &QDialog::reject);
|
|
|
|
|
connect(buttons, &QDialogButtonBox::clicked, m_dialog, [buttons, this](QAbstractButton *button) {
|
|
|
|
|
if (button != buttons->button(QDialogButtonBox::Reset))
|
|
|
|
|
return;
|
|
|
|
|
CMakeConfigurationKitAspect::setConfiguration(kit(),
|
|
|
|
|
CMakeConfigurationKitAspect::defaultConfiguration(kit()));
|
|
|
|
|
});
|
|
|
|
|
connect(m_dialog, &QDialog::accepted, this, &CMakeConfigurationKitAspectWidget::acceptChangesDialog);
|
|
|
|
|
connect(m_dialog, &QDialog::rejected, this, &CMakeConfigurationKitAspectWidget::closeChangesDialog);
|
|
|
|
|
connect(buttons->button(QDialogButtonBox::Apply), &QAbstractButton::clicked,
|
|
|
|
|
this, &CMakeConfigurationKitAspectWidget::applyChanges);
|
|
|
|
|
|
|
|
|
|
refresh();
|
|
|
|
|
m_dialog->show();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void applyChanges()
|
|
|
|
|
{
|
|
|
|
|
QTC_ASSERT(m_editor, return);
|
|
|
|
|
CMakeConfigurationKitAspect::fromStringList(kit(), m_editor->toPlainText().split(QLatin1Char('\n')));
|
|
|
|
|
}
|
|
|
|
|
void closeChangesDialog()
|
|
|
|
|
{
|
|
|
|
|
m_dialog->deleteLater();
|
|
|
|
|
m_dialog = nullptr;
|
|
|
|
|
m_editor = nullptr;
|
|
|
|
|
}
|
|
|
|
|
void acceptChangesDialog()
|
|
|
|
|
{
|
|
|
|
|
applyChanges();
|
|
|
|
|
closeChangesDialog();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QLabel *m_summaryLabel;
|
|
|
|
|
QPushButton *m_manageButton;
|
|
|
|
|
QDialog *m_dialog = nullptr;
|
|
|
|
|
QPlainTextEdit *m_editor = nullptr;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
2019-02-06 12:50:51 +01:00
|
|
|
CMakeConfigurationKitAspect::CMakeConfigurationKitAspect()
|
2016-02-12 12:23:18 +01:00
|
|
|
{
|
2019-02-06 12:50:51 +01:00
|
|
|
setObjectName(QLatin1String("CMakeConfigurationKitAspect"));
|
2016-02-12 12:23:18 +01:00
|
|
|
setId(CONFIGURATION_ID);
|
2019-02-06 16:16:07 +01:00
|
|
|
setDisplayName(tr("CMake Configuration"));
|
|
|
|
|
setDescription(tr("Default configuration passed to CMake when setting up a project."));
|
2016-02-12 12:23:18 +01:00
|
|
|
setPriority(18000);
|
|
|
|
|
}
|
|
|
|
|
|
2019-02-06 12:50:51 +01:00
|
|
|
CMakeConfig CMakeConfigurationKitAspect::configuration(const Kit *k)
|
2016-02-12 12:23:18 +01:00
|
|
|
{
|
|
|
|
|
if (!k)
|
|
|
|
|
return CMakeConfig();
|
|
|
|
|
const QStringList tmp = k->value(CONFIGURATION_ID).toStringList();
|
2018-05-28 11:05:37 +02:00
|
|
|
return Utils::transform(tmp, &CMakeConfigItem::fromString);
|
2016-02-12 12:23:18 +01:00
|
|
|
}
|
|
|
|
|
|
2019-02-06 12:50:51 +01:00
|
|
|
void CMakeConfigurationKitAspect::setConfiguration(Kit *k, const CMakeConfig &config)
|
2016-02-12 12:23:18 +01:00
|
|
|
{
|
|
|
|
|
if (!k)
|
|
|
|
|
return;
|
|
|
|
|
const QStringList tmp = Utils::transform(config, [](const CMakeConfigItem &i) { return i.toString(); });
|
|
|
|
|
k->setValue(CONFIGURATION_ID, tmp);
|
|
|
|
|
}
|
|
|
|
|
|
2019-02-06 12:50:51 +01:00
|
|
|
QStringList CMakeConfigurationKitAspect::toStringList(const Kit *k)
|
2016-02-12 12:23:18 +01:00
|
|
|
{
|
|
|
|
|
QStringList current
|
2019-02-06 12:50:51 +01:00
|
|
|
= Utils::transform(CMakeConfigurationKitAspect::configuration(k),
|
2016-02-12 12:23:18 +01:00
|
|
|
[](const CMakeConfigItem &i) { return i.toString(); });
|
2016-04-08 14:08:13 +02:00
|
|
|
current = Utils::filtered(current, [](const QString &s) { return !s.isEmpty(); });
|
2016-02-12 12:23:18 +01:00
|
|
|
Utils::sort(current);
|
|
|
|
|
return current;
|
|
|
|
|
}
|
|
|
|
|
|
2019-02-06 12:50:51 +01:00
|
|
|
void CMakeConfigurationKitAspect::fromStringList(Kit *k, const QStringList &in)
|
2016-02-12 12:23:18 +01:00
|
|
|
{
|
|
|
|
|
CMakeConfig result;
|
|
|
|
|
foreach (const QString &s, in) {
|
|
|
|
|
const CMakeConfigItem item = CMakeConfigItem::fromString(s);
|
|
|
|
|
if (!item.key.isEmpty())
|
|
|
|
|
result << item;
|
|
|
|
|
}
|
|
|
|
|
setConfiguration(k, result);
|
|
|
|
|
}
|
|
|
|
|
|
2019-02-06 12:50:51 +01:00
|
|
|
CMakeConfig CMakeConfigurationKitAspect::defaultConfiguration(const Kit *k)
|
2016-02-12 12:23:18 +01:00
|
|
|
{
|
2019-07-23 10:58:00 +02:00
|
|
|
Q_UNUSED(k)
|
2016-02-12 12:23:18 +01:00
|
|
|
CMakeConfig config;
|
2016-09-19 11:53:30 +02:00
|
|
|
// Qt4:
|
2016-03-16 13:39:41 +01:00
|
|
|
config << CMakeConfigItem(CMAKE_QMAKE_KEY, "%{Qt:qmakeExecutable}");
|
2016-09-19 11:53:30 +02:00
|
|
|
// Qt5:
|
2016-11-08 11:56:53 +01:00
|
|
|
config << CMakeConfigItem(CMAKE_PREFIX_PATH_KEY, "%{Qt:QT_INSTALL_PREFIX}");
|
2016-09-19 11:53:30 +02:00
|
|
|
|
2016-07-18 02:08:25 -07:00
|
|
|
config << CMakeConfigItem(CMAKE_C_TOOLCHAIN_KEY, "%{Compiler:Executable:C}");
|
|
|
|
|
config << CMakeConfigItem(CMAKE_CXX_TOOLCHAIN_KEY, "%{Compiler:Executable:Cxx}");
|
2016-02-12 12:23:18 +01:00
|
|
|
|
2016-04-06 15:29:39 +02:00
|
|
|
return config;
|
|
|
|
|
}
|
|
|
|
|
|
2019-02-06 12:50:51 +01:00
|
|
|
QVariant CMakeConfigurationKitAspect::defaultValue(const Kit *k) const
|
2016-04-06 15:29:39 +02:00
|
|
|
{
|
2019-07-23 10:58:00 +02:00
|
|
|
Q_UNUSED(k)
|
2016-04-06 15:29:39 +02:00
|
|
|
|
|
|
|
|
// FIXME: Convert preload scripts
|
|
|
|
|
CMakeConfig config = defaultConfiguration(k);
|
2016-02-12 12:23:18 +01:00
|
|
|
const QStringList tmp
|
|
|
|
|
= Utils::transform(config, [](const CMakeConfigItem &i) { return i.toString(); });
|
|
|
|
|
return tmp;
|
|
|
|
|
}
|
|
|
|
|
|
2019-05-27 16:09:44 +02:00
|
|
|
Tasks CMakeConfigurationKitAspect::validate(const Kit *k) const
|
2016-02-12 12:23:18 +01:00
|
|
|
{
|
2019-05-27 16:09:44 +02:00
|
|
|
QTC_ASSERT(k, return Tasks());
|
2018-02-12 12:49:22 +01:00
|
|
|
|
2019-02-06 12:50:51 +01:00
|
|
|
const QtSupport::BaseQtVersion *const version = QtSupport::QtKitAspect::qtVersion(k);
|
|
|
|
|
const ToolChain *const tcC = ToolChainKitAspect::toolChain(k, ProjectExplorer::Constants::C_LANGUAGE_ID);
|
|
|
|
|
const ToolChain *const tcCxx = ToolChainKitAspect::toolChain(k, ProjectExplorer::Constants::CXX_LANGUAGE_ID);
|
2016-02-12 12:23:18 +01:00
|
|
|
const CMakeConfig config = configuration(k);
|
|
|
|
|
|
2016-09-19 11:53:30 +02:00
|
|
|
const bool isQt4 = version && version->qtVersion() < QtSupport::QtVersionNumber(5, 0, 0);
|
2019-05-28 13:49:26 +02:00
|
|
|
Utils::FilePath qmakePath;
|
2016-11-08 11:56:53 +01:00
|
|
|
QStringList qtInstallDirs;
|
2019-05-28 13:49:26 +02:00
|
|
|
Utils::FilePath tcCPath;
|
|
|
|
|
Utils::FilePath tcCxxPath;
|
2016-02-12 12:23:18 +01:00
|
|
|
foreach (const CMakeConfigItem &i, config) {
|
2018-10-22 16:34:31 +02:00
|
|
|
// Do not use expand(QByteArray) as we cannot be sure the input is latin1
|
2019-05-28 13:49:26 +02:00
|
|
|
const Utils::FilePath expandedValue
|
|
|
|
|
= Utils::FilePath::fromString(k->macroExpander()->expand(QString::fromUtf8(i.value)));
|
2016-02-12 12:23:18 +01:00
|
|
|
if (i.key == CMAKE_QMAKE_KEY)
|
2016-03-16 13:39:41 +01:00
|
|
|
qmakePath = expandedValue;
|
2016-07-18 02:08:25 -07:00
|
|
|
else if (i.key == CMAKE_C_TOOLCHAIN_KEY)
|
|
|
|
|
tcCPath = expandedValue;
|
|
|
|
|
else if (i.key == CMAKE_CXX_TOOLCHAIN_KEY)
|
|
|
|
|
tcCxxPath = expandedValue;
|
2016-09-19 11:53:30 +02:00
|
|
|
else if (i.key == CMAKE_PREFIX_PATH_KEY)
|
2016-11-08 11:56:53 +01:00
|
|
|
qtInstallDirs = CMakeConfigItem::cmakeSplitValue(expandedValue.toString());
|
2016-02-12 12:23:18 +01:00
|
|
|
}
|
|
|
|
|
|
2019-05-27 16:09:44 +02:00
|
|
|
Tasks result;
|
2020-01-15 08:56:11 +01:00
|
|
|
const auto addWarning = [&result](const QString &desc) {
|
|
|
|
|
result << BuildSystemTask(Task::Warning, desc);
|
|
|
|
|
};
|
|
|
|
|
|
2016-02-12 12:23:18 +01:00
|
|
|
// Validate Qt:
|
|
|
|
|
if (qmakePath.isEmpty()) {
|
2016-09-19 11:53:30 +02:00
|
|
|
if (version && version->isValid() && isQt4) {
|
2020-01-15 08:56:11 +01:00
|
|
|
addWarning(tr("CMake configuration has no path to qmake binary set, "
|
|
|
|
|
"even though the kit has a valid Qt version."));
|
2016-02-12 12:23:18 +01:00
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
if (!version || !version->isValid()) {
|
2020-01-15 08:56:11 +01:00
|
|
|
addWarning(tr("CMake configuration has a path to a qmake binary set, "
|
|
|
|
|
"even though the kit has no valid Qt version."));
|
2016-09-19 11:53:30 +02:00
|
|
|
} else if (qmakePath != version->qmakeCommand() && isQt4) {
|
2020-01-15 08:56:11 +01:00
|
|
|
addWarning(tr("CMake configuration has a path to a qmake binary set "
|
|
|
|
|
"that does not match the qmake binary path "
|
|
|
|
|
"configured in the Qt version."));
|
2016-02-12 12:23:18 +01:00
|
|
|
}
|
2016-09-19 11:53:30 +02:00
|
|
|
}
|
2019-09-30 14:34:31 +02:00
|
|
|
if (version && !qtInstallDirs.contains(version->prefix().toString()) && !isQt4) {
|
2016-09-30 11:35:12 +02:00
|
|
|
if (version->isValid()) {
|
2020-01-15 08:56:11 +01:00
|
|
|
addWarning(tr("CMake configuration has no CMAKE_PREFIX_PATH set "
|
|
|
|
|
"that points to the kit Qt version."));
|
2016-09-19 11:53:30 +02:00
|
|
|
}
|
2016-02-12 12:23:18 +01:00
|
|
|
}
|
|
|
|
|
|
2016-07-18 02:08:25 -07:00
|
|
|
// Validate Toolchains:
|
|
|
|
|
if (tcCPath.isEmpty()) {
|
|
|
|
|
if (tcC && tcC->isValid()) {
|
2020-01-15 08:56:11 +01:00
|
|
|
addWarning(tr("CMake configuration has no path to a C compiler set, "
|
|
|
|
|
"even though the kit has a valid tool chain."));
|
2016-07-18 02:08:25 -07:00
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
if (!tcC || !tcC->isValid()) {
|
2020-01-15 08:56:11 +01:00
|
|
|
addWarning(tr("CMake configuration has a path to a C compiler set, "
|
|
|
|
|
"even though the kit has no valid tool chain."));
|
2016-07-18 02:08:25 -07:00
|
|
|
} else if (tcCPath != tcC->compilerCommand()) {
|
2020-01-15 08:56:11 +01:00
|
|
|
addWarning(tr("CMake configuration has a path to a C compiler set "
|
|
|
|
|
"that does not match the compiler path "
|
|
|
|
|
"configured in the tool chain of the kit."));
|
2016-07-18 02:08:25 -07:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (tcCxxPath.isEmpty()) {
|
|
|
|
|
if (tcCxx && tcCxx->isValid()) {
|
2020-01-15 08:56:11 +01:00
|
|
|
addWarning(tr("CMake configuration has no path to a C++ compiler set, "
|
|
|
|
|
"even though the kit has a valid tool chain."));
|
2016-02-12 12:23:18 +01:00
|
|
|
}
|
|
|
|
|
} else {
|
2016-07-18 02:08:25 -07:00
|
|
|
if (!tcCxx || !tcCxx->isValid()) {
|
2020-01-15 08:56:11 +01:00
|
|
|
addWarning(tr("CMake configuration has a path to a C++ compiler set, "
|
|
|
|
|
"even though the kit has no valid tool chain."));
|
2016-07-18 02:08:25 -07:00
|
|
|
} else if (tcCxxPath != tcCxx->compilerCommand()) {
|
2020-01-15 08:56:11 +01:00
|
|
|
addWarning(tr("CMake configuration has a path to a C++ compiler set "
|
|
|
|
|
"that does not match the compiler path "
|
|
|
|
|
"configured in the tool chain of the kit."));
|
2016-02-12 12:23:18 +01:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
2019-02-06 12:50:51 +01:00
|
|
|
void CMakeConfigurationKitAspect::setup(Kit *k)
|
2016-02-12 12:23:18 +01:00
|
|
|
{
|
2016-12-21 11:50:43 +01:00
|
|
|
if (k && !k->hasValue(CONFIGURATION_ID))
|
2016-02-12 12:23:18 +01:00
|
|
|
k->setValue(CONFIGURATION_ID, defaultValue(k));
|
|
|
|
|
}
|
|
|
|
|
|
2019-02-06 12:50:51 +01:00
|
|
|
void CMakeConfigurationKitAspect::fix(Kit *k)
|
2016-02-12 12:23:18 +01:00
|
|
|
{
|
2019-07-23 10:58:00 +02:00
|
|
|
Q_UNUSED(k)
|
2016-02-12 12:23:18 +01:00
|
|
|
}
|
|
|
|
|
|
2019-02-06 12:50:51 +01:00
|
|
|
KitAspect::ItemList CMakeConfigurationKitAspect::toUserOutput(const Kit *k) const
|
2016-02-12 12:23:18 +01:00
|
|
|
{
|
2019-05-28 08:28:51 +02:00
|
|
|
return {{tr("CMake Configuration"), toStringList(k).join("<br>")}};
|
2016-02-12 12:23:18 +01:00
|
|
|
}
|
|
|
|
|
|
2019-02-06 12:50:51 +01:00
|
|
|
KitAspectWidget *CMakeConfigurationKitAspect::createConfigWidget(Kit *k) const
|
2016-02-12 12:23:18 +01:00
|
|
|
{
|
|
|
|
|
if (!k)
|
2018-02-12 12:49:22 +01:00
|
|
|
return nullptr;
|
2019-02-06 15:04:17 +01:00
|
|
|
return new CMakeConfigurationKitAspectWidget(k, this);
|
2016-02-12 12:23:18 +01:00
|
|
|
}
|
|
|
|
|
|
2015-02-24 21:57:00 +01:00
|
|
|
} // namespace CMakeProjectManager
|