forked from qt-creator/qt-creator
CMake: Disable BC if there is an error during initial cmake run
* Disable the BC and give report the cmake error * Show a warning label in the BC Change-Id: If5737d033fa2682c264ab7ac1189c59947e3b28d Reviewed-by: Tim Jenssen <tim.jenssen@theqtcompany.com>
This commit is contained in:
@@ -451,6 +451,14 @@ CMakeConfig BuildDirManager::parseConfiguration() const
|
|||||||
CMakeConfigItem::Type t = fromByteArray(type);
|
CMakeConfigItem::Type t = fromByteArray(type);
|
||||||
if (t != CMakeConfigItem::INTERNAL)
|
if (t != CMakeConfigItem::INTERNAL)
|
||||||
result << CMakeConfigItem(key, t, documentation, value);
|
result << CMakeConfigItem(key, t, documentation, value);
|
||||||
|
|
||||||
|
// Sanity checks:
|
||||||
|
if (key == "CMAKE_HOME_DIRECTORY") {
|
||||||
|
const Utils::FileName actualSourceDir = Utils::FileName::fromUserInput(QString::fromUtf8(value));
|
||||||
|
if (actualSourceDir != m_sourceDir)
|
||||||
|
emit errorOccured(tr("Build directory contains a build of the wrong project (%1).")
|
||||||
|
.arg(actualSourceDir.toUserOutput()));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -100,6 +100,7 @@ private:
|
|||||||
|
|
||||||
const Utils::FileName m_sourceDir;
|
const Utils::FileName m_sourceDir;
|
||||||
Utils::FileName m_buildDir;
|
Utils::FileName m_buildDir;
|
||||||
|
Utils::FileName m_parsedSourceDir;
|
||||||
const ProjectExplorer::Kit *const m_kit;
|
const ProjectExplorer::Kit *const m_kit;
|
||||||
Utils::Environment m_environment;
|
Utils::Environment m_environment;
|
||||||
CMakeConfig m_inputConfig;
|
CMakeConfig m_inputConfig;
|
||||||
|
|||||||
@@ -81,6 +81,16 @@ CMakeBuildConfiguration::CMakeBuildConfiguration(ProjectExplorer::Target *parent
|
|||||||
displayName(), BuildConfiguration::Unknown));
|
displayName(), BuildConfiguration::Unknown));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool CMakeBuildConfiguration::isEnabled() const
|
||||||
|
{
|
||||||
|
return m_error.isEmpty();
|
||||||
|
}
|
||||||
|
|
||||||
|
QString CMakeBuildConfiguration::disabledReason() const
|
||||||
|
{
|
||||||
|
return error();
|
||||||
|
}
|
||||||
|
|
||||||
CMakeBuildConfiguration::CMakeBuildConfiguration(ProjectExplorer::Target *parent,
|
CMakeBuildConfiguration::CMakeBuildConfiguration(ProjectExplorer::Target *parent,
|
||||||
CMakeBuildConfiguration *source) :
|
CMakeBuildConfiguration *source) :
|
||||||
BuildConfiguration(parent, source),
|
BuildConfiguration(parent, source),
|
||||||
@@ -160,6 +170,20 @@ CMakeConfig CMakeBuildConfiguration::cmakeConfiguration() const
|
|||||||
return m_configuration;
|
return m_configuration;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CMakeBuildConfiguration::setError(const QString &message)
|
||||||
|
{
|
||||||
|
if (m_error == message)
|
||||||
|
return;
|
||||||
|
m_error = message;
|
||||||
|
emit enabledChanged();
|
||||||
|
emit errorOccured(m_error);
|
||||||
|
}
|
||||||
|
|
||||||
|
QString CMakeBuildConfiguration::error() const
|
||||||
|
{
|
||||||
|
return m_error;
|
||||||
|
}
|
||||||
|
|
||||||
ProjectExplorer::NamedWidget *CMakeBuildConfiguration::createConfigWidget()
|
ProjectExplorer::NamedWidget *CMakeBuildConfiguration::createConfigWidget()
|
||||||
{
|
{
|
||||||
return new CMakeBuildSettingsWidget(this);
|
return new CMakeBuildSettingsWidget(this);
|
||||||
|
|||||||
@@ -48,6 +48,9 @@ class CMakeBuildConfiguration : public ProjectExplorer::BuildConfiguration
|
|||||||
public:
|
public:
|
||||||
CMakeBuildConfiguration(ProjectExplorer::Target *parent);
|
CMakeBuildConfiguration(ProjectExplorer::Target *parent);
|
||||||
|
|
||||||
|
bool isEnabled() const override;
|
||||||
|
QString disabledReason() const override;
|
||||||
|
|
||||||
ProjectExplorer::NamedWidget *createConfigWidget() override;
|
ProjectExplorer::NamedWidget *createConfigWidget() override;
|
||||||
|
|
||||||
QVariantMap toMap() const override;
|
QVariantMap toMap() const override;
|
||||||
@@ -59,6 +62,12 @@ public:
|
|||||||
void setCMakeConfiguration(const CMakeConfig &config);
|
void setCMakeConfiguration(const CMakeConfig &config);
|
||||||
CMakeConfig cmakeConfiguration() const;
|
CMakeConfig cmakeConfiguration() const;
|
||||||
|
|
||||||
|
void setError(const QString &message);
|
||||||
|
QString error() const;
|
||||||
|
|
||||||
|
signals:
|
||||||
|
void errorOccured(const QString &message);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
CMakeBuildConfiguration(ProjectExplorer::Target *parent, CMakeBuildConfiguration *source);
|
CMakeBuildConfiguration(ProjectExplorer::Target *parent, CMakeBuildConfiguration *source);
|
||||||
bool fromMap(const QVariantMap &map) override;
|
bool fromMap(const QVariantMap &map) override;
|
||||||
@@ -66,6 +75,7 @@ protected:
|
|||||||
private:
|
private:
|
||||||
QString m_initialArguments;
|
QString m_initialArguments;
|
||||||
CMakeConfig m_configuration;
|
CMakeConfig m_configuration;
|
||||||
|
QString m_error;
|
||||||
|
|
||||||
friend class CMakeProjectManager::CMakeProject;
|
friend class CMakeProjectManager::CMakeProject;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -29,6 +29,7 @@
|
|||||||
#include "cmakeproject.h"
|
#include "cmakeproject.h"
|
||||||
#include "cmakebuildconfiguration.h"
|
#include "cmakebuildconfiguration.h"
|
||||||
|
|
||||||
|
#include <coreplugin/coreicons.h>
|
||||||
#include <coreplugin/icore.h>
|
#include <coreplugin/icore.h>
|
||||||
#include <coreplugin/find/itemviewfind.h>
|
#include <coreplugin/find/itemviewfind.h>
|
||||||
#include <projectexplorer/projectexplorer.h>
|
#include <projectexplorer/projectexplorer.h>
|
||||||
@@ -94,7 +95,21 @@ CMakeBuildSettingsWidget::CMakeBuildSettingsWidget(CMakeBuildConfiguration *bc)
|
|||||||
mainLayout->addWidget(buildDirChooser->buttonAtIndex(0), row, 2);
|
mainLayout->addWidget(buildDirChooser->buttonAtIndex(0), row, 2);
|
||||||
|
|
||||||
++row;
|
++row;
|
||||||
mainLayout->addItem(new QSpacerItem(20, 20), row, 0);
|
mainLayout->addItem(new QSpacerItem(20, 10), row, 0);
|
||||||
|
|
||||||
|
++row;
|
||||||
|
m_errorLabel = new QLabel;
|
||||||
|
m_errorLabel->setPixmap(Core::Icons::ERROR.pixmap());
|
||||||
|
m_errorLabel->setVisible(false);
|
||||||
|
m_errorMessageLabel = new QLabel;
|
||||||
|
m_errorMessageLabel->setVisible(false);
|
||||||
|
auto boxLayout = new QHBoxLayout;
|
||||||
|
boxLayout->addWidget(m_errorLabel);
|
||||||
|
boxLayout->addWidget(m_errorMessageLabel);
|
||||||
|
mainLayout->addLayout(boxLayout, row, 0, 1, 3, Qt::AlignHCenter);
|
||||||
|
|
||||||
|
++row;
|
||||||
|
mainLayout->addItem(new QSpacerItem(20, 10), row, 0);
|
||||||
|
|
||||||
++row;
|
++row;
|
||||||
auto tree = new Utils::TreeView;
|
auto tree = new Utils::TreeView;
|
||||||
@@ -145,6 +160,7 @@ CMakeBuildSettingsWidget::CMakeBuildSettingsWidget(CMakeBuildConfiguration *bc)
|
|||||||
mainLayout->addWidget(m_reconfigureButton, row, 0, 1, 3);
|
mainLayout->addWidget(m_reconfigureButton, row, 0, 1, 3);
|
||||||
|
|
||||||
updateAdvancedCheckBox();
|
updateAdvancedCheckBox();
|
||||||
|
setError(bc->error());
|
||||||
|
|
||||||
connect(project, &CMakeProject::parsingStarted, this, [this]() {
|
connect(project, &CMakeProject::parsingStarted, this, [this]() {
|
||||||
updateButtonState();
|
updateButtonState();
|
||||||
@@ -180,6 +196,24 @@ CMakeBuildSettingsWidget::CMakeBuildSettingsWidget(CMakeBuildConfiguration *bc)
|
|||||||
m_configView->setCurrentIndex(idx);
|
m_configView->setCurrentIndex(idx);
|
||||||
m_configView->edit(idx);
|
m_configView->edit(idx);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
connect(bc, &CMakeBuildConfiguration::errorOccured, this, &CMakeBuildSettingsWidget::setError);
|
||||||
|
}
|
||||||
|
|
||||||
|
void CMakeBuildSettingsWidget::setError(const QString &message)
|
||||||
|
{
|
||||||
|
bool showWarning = !message.isEmpty();
|
||||||
|
m_errorLabel->setVisible(showWarning);
|
||||||
|
m_errorLabel->setToolTip(message);
|
||||||
|
m_errorMessageLabel->setVisible(showWarning);
|
||||||
|
m_errorMessageLabel->setText(message);
|
||||||
|
m_errorMessageLabel->setToolTip(message);
|
||||||
|
|
||||||
|
m_configView->setVisible(!showWarning);
|
||||||
|
m_editButton->setVisible(!showWarning);
|
||||||
|
m_resetButton->setVisible(!showWarning);
|
||||||
|
m_showAdvancedCheckBox->setVisible(!showWarning);
|
||||||
|
m_reconfigureButton->setVisible(!showWarning);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CMakeBuildSettingsWidget::updateButtonState()
|
void CMakeBuildSettingsWidget::updateButtonState()
|
||||||
|
|||||||
@@ -33,6 +33,7 @@
|
|||||||
|
|
||||||
QT_BEGIN_NAMESPACE
|
QT_BEGIN_NAMESPACE
|
||||||
class QCheckBox;
|
class QCheckBox;
|
||||||
|
class QLabel;
|
||||||
class QPushButton;
|
class QPushButton;
|
||||||
class QTreeView;
|
class QTreeView;
|
||||||
class QSortFilterProxyModel;
|
class QSortFilterProxyModel;
|
||||||
@@ -52,6 +53,8 @@ class CMakeBuildSettingsWidget : public ProjectExplorer::NamedWidget
|
|||||||
public:
|
public:
|
||||||
CMakeBuildSettingsWidget(CMakeBuildConfiguration *bc);
|
CMakeBuildSettingsWidget(CMakeBuildConfiguration *bc);
|
||||||
|
|
||||||
|
void setError(const QString &message);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void updateButtonState();
|
void updateButtonState();
|
||||||
void updateAdvancedCheckBox();
|
void updateAdvancedCheckBox();
|
||||||
@@ -66,6 +69,8 @@ private:
|
|||||||
QCheckBox *m_showAdvancedCheckBox;
|
QCheckBox *m_showAdvancedCheckBox;
|
||||||
QPushButton *m_reconfigureButton;
|
QPushButton *m_reconfigureButton;
|
||||||
QTimer m_showProgressTimer;
|
QTimer m_showProgressTimer;
|
||||||
|
QLabel *m_errorLabel;
|
||||||
|
QLabel *m_errorMessageLabel;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace Internal
|
} // namespace Internal
|
||||||
|
|||||||
@@ -139,6 +139,8 @@ void CMakeProject::changeActiveBuildConfiguration(ProjectExplorer::BuildConfigur
|
|||||||
this, &CMakeProject::parsingStarted);
|
this, &CMakeProject::parsingStarted);
|
||||||
connect(m_buildDirManager, &BuildDirManager::dataAvailable,
|
connect(m_buildDirManager, &BuildDirManager::dataAvailable,
|
||||||
this, &CMakeProject::parseCMakeOutput);
|
this, &CMakeProject::parseCMakeOutput);
|
||||||
|
connect(m_buildDirManager, &BuildDirManager::errorOccured,
|
||||||
|
cmakebc, &CMakeBuildConfiguration::setError);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user