forked from qt-creator/qt-creator
CMake: Warn on build directory changes
Change-Id: I78c5e850e268f4d7d66e40961bca85ef61be0483 Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
This commit is contained in:
@@ -47,7 +47,9 @@
|
|||||||
|
|
||||||
#include <utils/qtcassert.h>
|
#include <utils/qtcassert.h>
|
||||||
|
|
||||||
|
#include <QDir>
|
||||||
#include <QLoggingCategory>
|
#include <QLoggingCategory>
|
||||||
|
#include <QMessageBox>
|
||||||
|
|
||||||
using namespace ProjectExplorer;
|
using namespace ProjectExplorer;
|
||||||
using namespace Utils;
|
using namespace Utils;
|
||||||
@@ -65,12 +67,31 @@ CMakeBuildConfiguration::CMakeBuildConfiguration(Target *target, Core::Id id)
|
|||||||
m_buildSystem = new CMakeBuildSystem(this);
|
m_buildSystem = new CMakeBuildSystem(this);
|
||||||
|
|
||||||
buildDirectoryAspect()->setFileDialogOnly(true);
|
buildDirectoryAspect()->setFileDialogOnly(true);
|
||||||
|
const auto buildDirAspect = aspect<BuildDirectoryAspect>();
|
||||||
|
buildDirAspect->setFileDialogOnly(true);
|
||||||
|
buildDirAspect->setValueAcceptor(
|
||||||
|
[this](const QString &oldDir, const QString &newDir) -> Utils::optional<QString> {
|
||||||
|
if (oldDir.isEmpty())
|
||||||
|
return newDir;
|
||||||
|
|
||||||
|
if (QDir(oldDir).exists("CMakeCache.txt")) {
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return Utils::nullopt;
|
||||||
|
});
|
||||||
|
|
||||||
appendInitialBuildStep(Constants::CMAKE_BUILD_STEP_ID);
|
appendInitialBuildStep(Constants::CMAKE_BUILD_STEP_ID);
|
||||||
appendInitialCleanStep(Constants::CMAKE_BUILD_STEP_ID);
|
appendInitialCleanStep(Constants::CMAKE_BUILD_STEP_ID);
|
||||||
|
|
||||||
setInitializer([this, target](const BuildInfo &info) {
|
setInitializer([this, target](const BuildInfo &info) {
|
||||||
|
|
||||||
CMakeConfig config;
|
CMakeConfig config;
|
||||||
config.append({"CMAKE_BUILD_TYPE", info.typeName.toUtf8()});
|
config.append({"CMAKE_BUILD_TYPE", info.typeName.toUtf8()});
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user