CMakePM: Always create build directories

Having two configurations for a project, one in /tmp and one in the
right build directory is confusing and for big projects can take some
time.

Fixes: QTCREATORBUG-25532
Change-Id: Ib0dad267117b3c025d668646ef076b0f77bff166
Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
Cristian Adam
2021-06-09 15:08:13 +02:00
parent 4465fd06ae
commit 0e613918b6
8 changed files with 42 additions and 110 deletions

View File

@@ -54,7 +54,6 @@ public:
Utils::FilePath sourceDirectory; Utils::FilePath sourceDirectory;
Utils::FilePath buildDirectory; Utils::FilePath buildDirectory;
Utils::FilePath workDirectory; // either buildDirectory or a QTemporaryDirectory!
QString cmakeBuildType; QString cmakeBuildType;
Utils::Environment environment; Utils::Environment environment;

View File

@@ -273,7 +273,7 @@ void CMakeBuildSystem::triggerParsing()
qCDebug(cmakeBuildSystemLog) << "Parse called with flags:" qCDebug(cmakeBuildSystemLog) << "Parse called with flags:"
<< reparseParametersString(reparseParameters); << reparseParametersString(reparseParameters);
const QString cache = m_parameters.workDirectory.pathAppended("CMakeCache.txt").toString(); const QString cache = m_parameters.buildDirectory.pathAppended("CMakeCache.txt").toString();
if (!QFileInfo::exists(cache)) { if (!QFileInfo::exists(cache)) {
reparseParameters |= REPARSE_FORCE_INITIAL_CONFIGURATION | REPARSE_FORCE_CMAKE_RUN; reparseParameters |= REPARSE_FORCE_INITIAL_CONFIGURATION | REPARSE_FORCE_CMAKE_RUN;
qCDebug(cmakeBuildSystemLog) qCDebug(cmakeBuildSystemLog)
@@ -402,7 +402,7 @@ void CMakeBuildSystem::setParametersAndRequestParse(const BuildDirParameters &pa
QTC_ASSERT(parameters.isValid(), return ); QTC_ASSERT(parameters.isValid(), return );
m_parameters = parameters; m_parameters = parameters;
m_parameters.workDirectory = workDirectory(parameters); m_parameters.buildDirectory = buildDirectory(parameters);
updateReparseParameters(reparseParameters); updateReparseParameters(reparseParameters);
m_reader.setParameters(m_parameters); m_reader.setParameters(m_parameters);
@@ -479,21 +479,20 @@ bool CMakeBuildSystem::persistCMakeState()
BuildDirParameters parameters(cmakeBuildConfiguration()); BuildDirParameters parameters(cmakeBuildConfiguration());
QTC_ASSERT(parameters.isValid(), return false); QTC_ASSERT(parameters.isValid(), return false);
parameters.workDirectory = workDirectory(parameters); const bool hadBuildDirectory = parameters.buildDirectory.exists();
parameters.buildDirectory = buildDirectory(parameters);
int reparseFlags = REPARSE_DEFAULT; int reparseFlags = REPARSE_DEFAULT;
qCDebug(cmakeBuildSystemLog) << "Checking whether build system needs to be persisted:" qCDebug(cmakeBuildSystemLog) << "Checking whether build system needs to be persisted:"
<< "workdir:" << parameters.workDirectory
<< "buildDir:" << parameters.buildDirectory << "buildDir:" << parameters.buildDirectory
<< "Has extraargs:" << !parameters.extraCMakeArguments.isEmpty(); << "Has extraargs:" << !parameters.extraCMakeArguments.isEmpty();
if (parameters.workDirectory == parameters.buildDirectory if (parameters.buildDirectory == parameters.buildDirectory
&& mustApplyExtraArguments(parameters)) { && mustApplyExtraArguments(parameters)) {
reparseFlags = REPARSE_FORCE_EXTRA_CONFIGURATION; reparseFlags = REPARSE_FORCE_EXTRA_CONFIGURATION;
qCDebug(cmakeBuildSystemLog) << " -> must run CMake with extra arguments."; qCDebug(cmakeBuildSystemLog) << " -> must run CMake with extra arguments.";
} }
if (parameters.workDirectory != parameters.buildDirectory if (!hadBuildDirectory) {
&& buildConfiguration()->createBuildDirectory()) {
reparseFlags = REPARSE_FORCE_INITIAL_CONFIGURATION; reparseFlags = REPARSE_FORCE_INITIAL_CONFIGURATION;
qCDebug(cmakeBuildSystemLog) << " -> must run CMake with initial arguments."; qCDebug(cmakeBuildSystemLog) << " -> must run CMake with initial arguments.";
} }
@@ -501,9 +500,6 @@ bool CMakeBuildSystem::persistCMakeState()
if (reparseFlags == REPARSE_DEFAULT) if (reparseFlags == REPARSE_DEFAULT)
return false; return false;
if (reparseFlags == REPARSE_FORCE_INITIAL_CONFIGURATION)
parameters.workDirectory.clear();
qCDebug(cmakeBuildSystemLog) << "Requesting parse to persist CMake State"; qCDebug(cmakeBuildSystemLog) << "Requesting parse to persist CMake State";
setParametersAndRequestParse(parameters, setParametersAndRequestParse(parameters,
REPARSE_URGENT | REPARSE_FORCE_CMAKE_RUN | reparseFlags); REPARSE_URGENT | REPARSE_FORCE_CMAKE_RUN | reparseFlags);
@@ -518,11 +514,11 @@ void CMakeBuildSystem::clearCMakeCache()
stopParsingAndClearState(); stopParsingAndClearState();
const QList<FilePath> pathsToDelete = { const QList<FilePath> pathsToDelete = {
m_parameters.workDirectory / "CMakeCache.txt", m_parameters.buildDirectory / "CMakeCache.txt",
m_parameters.workDirectory / "CMakeCache.txt.prev", m_parameters.buildDirectory / "CMakeCache.txt.prev",
m_parameters.workDirectory / "CMakeFiles", m_parameters.buildDirectory / "CMakeFiles",
m_parameters.workDirectory / ".cmake/api/v1/reply", m_parameters.buildDirectory / ".cmake/api/v1/reply",
m_parameters.workDirectory / ".cmake/api/v1/reply.prev" m_parameters.buildDirectory / ".cmake/api/v1/reply.prev"
}; };
for (const FilePath &path : pathsToDelete) { for (const FilePath &path : pathsToDelete) {
@@ -740,7 +736,7 @@ void CMakeBuildSystem::handleParsingSucceeded()
m_buildTargets = Utils::transform(CMakeBuildStep::specialTargets(m_reader.usesAllCapsTargets()), [this](const QString &t) { m_buildTargets = Utils::transform(CMakeBuildStep::specialTargets(m_reader.usesAllCapsTargets()), [this](const QString &t) {
CMakeBuildTarget result; CMakeBuildTarget result;
result.title = t; result.title = t;
result.workingDirectory = m_parameters.workDirectory; result.workingDirectory = m_parameters.buildDirectory;
result.sourceDirectory = m_parameters.sourceDirectory; result.sourceDirectory = m_parameters.sourceDirectory;
return result; return result;
}); });
@@ -863,41 +859,16 @@ void CMakeBuildSystem::wireUpConnections()
} }
} }
FilePath CMakeBuildSystem::workDirectory(const BuildDirParameters &parameters) FilePath CMakeBuildSystem::buildDirectory(const BuildDirParameters &parameters)
{ {
const FilePath bdir = parameters.buildDirectory; const FilePath bdir = parameters.buildDirectory;
const CMakeTool *cmake = parameters.cmakeTool();
// use the build directory if it already exists anyhow
if (bdir.exists()) {
m_buildDirToTempDir.erase(bdir);
return bdir;
}
// use the build directory if the cmake tool settings are set to automatically create them,
// or if the configuration was changed by the user
if ((cmake && cmake->autoCreateBuildDirectory()) || !parameters.extraCMakeArguments.isEmpty()) {
if (!cmakeBuildConfiguration()->createBuildDirectory()) if (!cmakeBuildConfiguration()->createBuildDirectory())
handleParsingFailed( handleParsingFailed(
tr("Failed to create build directory \"%1\".").arg(bdir.toUserOutput())); tr("Failed to create build directory \"%1\".").arg(bdir.toUserOutput()));
return bdir;
}
auto tmpDirIt = m_buildDirToTempDir.find(bdir);
if (tmpDirIt == m_buildDirToTempDir.end()) {
auto ret = m_buildDirToTempDir.emplace(
std::make_pair(bdir, std::make_unique<TemporaryDirectory>("qtc-cmake-XXXXXXXX")));
QTC_ASSERT(ret.second, return bdir);
tmpDirIt = ret.first;
if (!tmpDirIt->second->isValid()) {
handleParsingFailed(tr("Failed to create temporary directory \"%1\".")
.arg(QDir::toNativeSeparators(tmpDirIt->second->path())));
return bdir; return bdir;
} }
}
return FilePath::fromString(tmpDirIt->second->path());
}
void CMakeBuildSystem::stopParsingAndClearState() void CMakeBuildSystem::stopParsingAndClearState()
{ {
@@ -941,7 +912,7 @@ void CMakeBuildSystem::runCTest()
QTC_ASSERT(parameters.isValid(), return); QTC_ASSERT(parameters.isValid(), return);
const CommandLine cmd { m_ctestPath, { "-N", "--show-only=json-v1" } }; const CommandLine cmd { m_ctestPath, { "-N", "--show-only=json-v1" } };
const QString workingDirectory = workDirectory(parameters).toString(); const QString workingDirectory = buildDirectory(parameters).toString();
const QStringList environment = cmakeBuildConfiguration()->environment().toStringList(); const QStringList environment = cmakeBuildConfiguration()->environment().toStringList();
auto future = Utils::runAsync([cmd, workingDirectory, environment] auto future = Utils::runAsync([cmd, workingDirectory, environment]

View File

@@ -149,7 +149,7 @@ private:
void wireUpConnections(); void wireUpConnections();
Utils::FilePath workDirectory(const BuildDirParameters &parameters); Utils::FilePath buildDirectory(const BuildDirParameters &parameters);
void stopParsingAndClearState(); void stopParsingAndClearState();
void becameDirty(); void becameDirty();
@@ -175,8 +175,6 @@ private:
// Parsing state: // Parsing state:
BuildDirParameters m_parameters; BuildDirParameters m_parameters;
int m_reparseParameters = REPARSE_DEFAULT; int m_reparseParameters = REPARSE_DEFAULT;
mutable std::unordered_map<Utils::FilePath, std::unique_ptr<Utils::TemporaryDirectory>>
m_buildDirToTempDir;
FileApiReader m_reader; FileApiReader m_reader;
mutable bool m_isHandlingError = false; mutable bool m_isHandlingError = false;

View File

@@ -86,8 +86,8 @@ void CMakeProcess::run(const BuildDirParameters &parameters, const QStringList &
CMakeTool *cmake = parameters.cmakeTool(); CMakeTool *cmake = parameters.cmakeTool();
QTC_ASSERT(parameters.isValid() && cmake, return); QTC_ASSERT(parameters.isValid() && cmake, return);
const Utils::FilePath workDirectory = parameters.workDirectory; const Utils::FilePath buildDirectory = parameters.buildDirectory;
QTC_ASSERT(workDirectory.exists(), return); QTC_ASSERT(buildDirectory.exists(), return);
const QString srcDir = parameters.sourceDirectory.path(); const QString srcDir = parameters.sourceDirectory.path();
@@ -103,7 +103,7 @@ void CMakeProcess::run(const BuildDirParameters &parameters, const QStringList &
m_cancelTimer.start(); m_cancelTimer.start();
process->setWorkingDirectory(workDirectory); process->setWorkingDirectory(buildDirectory);
process->setEnvironment(parameters.environment); process->setEnvironment(parameters.environment);
connect(process.get(), &QtcProcess::readyReadStandardOutput, connect(process.get(), &QtcProcess::readyReadStandardOutput,
@@ -113,12 +113,12 @@ void CMakeProcess::run(const BuildDirParameters &parameters, const QStringList &
connect(process.get(), &QtcProcess::finished, connect(process.get(), &QtcProcess::finished,
this, &CMakeProcess::handleProcessFinished); this, &CMakeProcess::handleProcessFinished);
CommandLine commandLine(cmake->cmakeExecutable(), QStringList({"-S", srcDir, "-B", workDirectory.path()}) + arguments); CommandLine commandLine(cmake->cmakeExecutable(), QStringList({"-S", srcDir, "-B", buildDirectory.path()}) + arguments);
TaskHub::clearTasks(ProjectExplorer::Constants::TASK_CATEGORY_BUILDSYSTEM); TaskHub::clearTasks(ProjectExplorer::Constants::TASK_CATEGORY_BUILDSYSTEM);
BuildSystem::startNewBuildSystemOutput( BuildSystem::startNewBuildSystemOutput(
tr("Running %1 in %2.").arg(commandLine.toUserOutput()).arg(workDirectory.toUserOutput())); tr("Running %1 in %2.").arg(commandLine.toUserOutput()).arg(buildDirectory.toUserOutput()));
auto future = std::make_unique<QFutureInterface<void>>(); auto future = std::make_unique<QFutureInterface<void>>();
future->setProgressRange(0, 1); future->setProgressRange(0, 1);

View File

@@ -77,7 +77,6 @@ public:
const FilePath &executable, const FilePath &executable,
const FilePath &qchFile, const FilePath &qchFile,
const bool autoRun, const bool autoRun,
const bool autoCreate,
const bool isAutoDetected); const bool isAutoDetected);
void addCMakeTool(const CMakeTool *item, bool changed); void addCMakeTool(const CMakeTool *item, bool changed);
TreeItem *autoGroupItem() const; TreeItem *autoGroupItem() const;
@@ -87,8 +86,7 @@ public:
const QString &displayName, const QString &displayName,
const FilePath &executable, const FilePath &executable,
const FilePath &qchFile, const FilePath &qchFile,
bool autoRun, bool autoRun);
bool autoCreate);
void removeCMakeTool(const Utils::Id &id); void removeCMakeTool(const Utils::Id &id);
void apply(); void apply();
@@ -112,7 +110,6 @@ public:
, m_executable(item->filePath()) , m_executable(item->filePath())
, m_qchFile(item->qchFilePath()) , m_qchFile(item->qchFilePath())
, m_isAutoRun(item->isAutoRun()) , m_isAutoRun(item->isAutoRun())
, m_autoCreateBuildDirectory(item->autoCreateBuildDirectory())
, m_autodetected(item->isAutoDetected()) , m_autodetected(item->isAutoDetected())
, m_isSupported(item->hasFileApi()) , m_isSupported(item->hasFileApi())
, m_changed(changed) , m_changed(changed)
@@ -124,14 +121,12 @@ public:
const FilePath &executable, const FilePath &executable,
const FilePath &qchFile, const FilePath &qchFile,
bool autoRun, bool autoRun,
bool autoCreate,
bool autodetected) bool autodetected)
: m_id(Utils::Id::fromString(QUuid::createUuid().toString())) : m_id(Utils::Id::fromString(QUuid::createUuid().toString()))
, m_name(name) , m_name(name)
, m_executable(executable) , m_executable(executable)
, m_qchFile(qchFile) , m_qchFile(qchFile)
, m_isAutoRun(autoRun) , m_isAutoRun(autoRun)
, m_autoCreateBuildDirectory(autoCreate)
, m_autodetected(autodetected) , m_autodetected(autodetected)
{ {
updateErrorFlags(); updateErrorFlags();
@@ -229,7 +224,6 @@ public:
bool m_pathExists = false; bool m_pathExists = false;
bool m_pathIsFile = false; bool m_pathIsFile = false;
bool m_pathIsExecutable = false; bool m_pathIsExecutable = false;
bool m_autoCreateBuildDirectory = false;
bool m_autodetected = false; bool m_autodetected = false;
bool m_isSupported = false; bool m_isSupported = false;
bool m_changed = true; bool m_changed = true;
@@ -259,10 +253,9 @@ QModelIndex CMakeToolItemModel::addCMakeTool(const QString &name,
const FilePath &executable, const FilePath &executable,
const FilePath &qchFile, const FilePath &qchFile,
const bool autoRun, const bool autoRun,
const bool autoCreate,
const bool isAutoDetected) const bool isAutoDetected)
{ {
auto item = new CMakeToolTreeItem(name, executable, qchFile, autoRun, autoCreate, isAutoDetected); auto item = new CMakeToolTreeItem(name, executable, qchFile, autoRun, isAutoDetected);
if (isAutoDetected) if (isAutoDetected)
autoGroupItem()->appendChild(item); autoGroupItem()->appendChild(item);
else else
@@ -317,8 +310,7 @@ void CMakeToolItemModel::updateCMakeTool(const Utils::Id &id,
const QString &displayName, const QString &displayName,
const FilePath &executable, const FilePath &executable,
const FilePath &qchFile, const FilePath &qchFile,
bool autoRun, bool autoRun)
bool autoCreate)
{ {
CMakeToolTreeItem *treeItem = cmakeToolItem(id); CMakeToolTreeItem *treeItem = cmakeToolItem(id);
QTC_ASSERT(treeItem, return ); QTC_ASSERT(treeItem, return );
@@ -327,7 +319,6 @@ void CMakeToolItemModel::updateCMakeTool(const Utils::Id &id,
treeItem->m_executable = executable; treeItem->m_executable = executable;
treeItem->m_qchFile = qchFile; treeItem->m_qchFile = qchFile;
treeItem->m_isAutoRun = autoRun; treeItem->m_isAutoRun = autoRun;
treeItem->m_autoCreateBuildDirectory = autoCreate;
treeItem->updateErrorFlags(); treeItem->updateErrorFlags();
@@ -369,7 +360,6 @@ void CMakeToolItemModel::apply()
cmake->setFilePath(item->m_executable); cmake->setFilePath(item->m_executable);
cmake->setQchFilePath(item->m_qchFile); cmake->setQchFilePath(item->m_qchFile);
cmake->setAutorun(item->m_isAutoRun); cmake->setAutorun(item->m_isAutoRun);
cmake->setAutoCreateBuildDirectory(item->m_autoCreateBuildDirectory);
} else { } else {
toRegister.append(item); toRegister.append(item);
} }
@@ -438,7 +428,6 @@ private:
CMakeToolItemModel *m_model; CMakeToolItemModel *m_model;
QLineEdit *m_displayNameLineEdit; QLineEdit *m_displayNameLineEdit;
QCheckBox *m_autoRunCheckBox; QCheckBox *m_autoRunCheckBox;
QCheckBox *m_autoCreateBuildDirectoryCheckBox;
PathChooser *m_binaryChooser; PathChooser *m_binaryChooser;
PathChooser *m_qchFileChooser; PathChooser *m_qchFileChooser;
Utils::Id m_id; Utils::Id m_id;
@@ -467,17 +456,12 @@ CMakeToolItemConfigWidget::CMakeToolItemConfigWidget(CMakeToolItemModel *model)
m_autoRunCheckBox->setText(tr("Autorun CMake")); m_autoRunCheckBox->setText(tr("Autorun CMake"));
m_autoRunCheckBox->setToolTip(tr("Automatically run CMake after changes to CMake project files.")); m_autoRunCheckBox->setToolTip(tr("Automatically run CMake after changes to CMake project files."));
m_autoCreateBuildDirectoryCheckBox = new QCheckBox;
m_autoCreateBuildDirectoryCheckBox->setText(tr("Auto-create build directories"));
m_autoCreateBuildDirectoryCheckBox->setToolTip(tr("Automatically create build directories for CMake projects."));
auto formLayout = new QFormLayout(this); auto formLayout = new QFormLayout(this);
formLayout->setFieldGrowthPolicy(QFormLayout::AllNonFixedFieldsGrow); formLayout->setFieldGrowthPolicy(QFormLayout::AllNonFixedFieldsGrow);
formLayout->addRow(new QLabel(tr("Name:")), m_displayNameLineEdit); formLayout->addRow(new QLabel(tr("Name:")), m_displayNameLineEdit);
formLayout->addRow(new QLabel(tr("Path:")), m_binaryChooser); formLayout->addRow(new QLabel(tr("Path:")), m_binaryChooser);
formLayout->addRow(new QLabel(tr("Help file:")), m_qchFileChooser); formLayout->addRow(new QLabel(tr("Help file:")), m_qchFileChooser);
formLayout->addRow(m_autoRunCheckBox); formLayout->addRow(m_autoRunCheckBox);
formLayout->addRow(m_autoCreateBuildDirectoryCheckBox);
connect(m_binaryChooser, &PathChooser::rawPathChanged, this, [this]() { connect(m_binaryChooser, &PathChooser::rawPathChanged, this, [this]() {
updateQchFilePath(); updateQchFilePath();
@@ -488,8 +472,6 @@ CMakeToolItemConfigWidget::CMakeToolItemConfigWidget(CMakeToolItemModel *model)
connect(m_displayNameLineEdit, &QLineEdit::textChanged, this, &CMakeToolItemConfigWidget::store); connect(m_displayNameLineEdit, &QLineEdit::textChanged, this, &CMakeToolItemConfigWidget::store);
connect(m_autoRunCheckBox, &QCheckBox::toggled, connect(m_autoRunCheckBox, &QCheckBox::toggled,
this, &CMakeToolItemConfigWidget::store); this, &CMakeToolItemConfigWidget::store);
connect(m_autoCreateBuildDirectoryCheckBox, &QCheckBox::toggled,
this, &CMakeToolItemConfigWidget::store);
} }
void CMakeToolItemConfigWidget::store() const void CMakeToolItemConfigWidget::store() const
@@ -499,8 +481,7 @@ void CMakeToolItemConfigWidget::store() const
m_displayNameLineEdit->text(), m_displayNameLineEdit->text(),
m_binaryChooser->filePath(), m_binaryChooser->filePath(),
m_qchFileChooser->filePath(), m_qchFileChooser->filePath(),
m_autoRunCheckBox->checkState() == Qt::Checked, m_autoRunCheckBox->checkState() == Qt::Checked);
m_autoCreateBuildDirectoryCheckBox->checkState() == Qt::Checked);
} }
void CMakeToolItemConfigWidget::updateQchFilePath() void CMakeToolItemConfigWidget::updateQchFilePath()
@@ -530,7 +511,6 @@ void CMakeToolItemConfigWidget::load(const CMakeToolTreeItem *item)
m_qchFileChooser->setFilePath(item->m_qchFile); m_qchFileChooser->setFilePath(item->m_qchFile);
m_autoRunCheckBox->setChecked(item->m_isAutoRun); m_autoRunCheckBox->setChecked(item->m_isAutoRun);
m_autoCreateBuildDirectoryCheckBox->setChecked(item->m_autoCreateBuildDirectory);
m_id = item->m_id; m_id = item->m_id;
m_loadingItem = false; m_loadingItem = false;
@@ -641,7 +621,6 @@ void CMakeToolConfigWidget::cloneCMakeTool()
m_currentItem->m_executable, m_currentItem->m_executable,
m_currentItem->m_qchFile, m_currentItem->m_qchFile,
m_currentItem->m_isAutoRun, m_currentItem->m_isAutoRun,
m_currentItem->m_autoCreateBuildDirectory,
false); false);
m_cmakeToolsView->setCurrentIndex(newItem); m_cmakeToolsView->setCurrentIndex(newItem);
@@ -653,7 +632,6 @@ void CMakeToolConfigWidget::addCMakeTool()
FilePath(), FilePath(),
FilePath(), FilePath(),
true, true,
false,
false); false);
m_cmakeToolsView->setCurrentIndex(newItem); m_cmakeToolsView->setCurrentIndex(newItem);

View File

@@ -50,6 +50,7 @@ const char CMAKE_INFORMATION_COMMAND[] = "Binary";
const char CMAKE_INFORMATION_DISPLAYNAME[] = "DisplayName"; const char CMAKE_INFORMATION_DISPLAYNAME[] = "DisplayName";
const char CMAKE_INFORMATION_AUTORUN[] = "AutoRun"; const char CMAKE_INFORMATION_AUTORUN[] = "AutoRun";
const char CMAKE_INFORMATION_QCH_FILE_PATH[] = "QchFile"; const char CMAKE_INFORMATION_QCH_FILE_PATH[] = "QchFile";
// obsolete since Qt Creator 5. Kept for backward compatibility
const char CMAKE_INFORMATION_AUTO_CREATE_BUILD_DIRECTORY[] = "AutoCreateBuildDirectory"; const char CMAKE_INFORMATION_AUTO_CREATE_BUILD_DIRECTORY[] = "AutoCreateBuildDirectory";
const char CMAKE_INFORMATION_AUTODETECTED[] = "AutoDetected"; const char CMAKE_INFORMATION_AUTODETECTED[] = "AutoDetected";
const char CMAKE_INFORMATION_READERTYPE[] = "ReaderType"; const char CMAKE_INFORMATION_READERTYPE[] = "ReaderType";
@@ -172,15 +173,6 @@ void CMakeTool::setAutorun(bool autoRun)
CMakeToolManager::notifyAboutUpdate(this); CMakeToolManager::notifyAboutUpdate(this);
} }
void CMakeTool::setAutoCreateBuildDirectory(bool autoBuildDir)
{
if (m_autoCreateBuildDirectory == autoBuildDir)
return;
m_autoCreateBuildDirectory = autoBuildDir;
CMakeToolManager::notifyAboutUpdate(this);
}
bool CMakeTool::isValid() const bool CMakeTool::isValid() const
{ {
if (!m_id.isValid() || !m_introspection) if (!m_id.isValid() || !m_introspection)
@@ -265,11 +257,6 @@ bool CMakeTool::isAutoRun() const
return m_isAutoRun; return m_isAutoRun;
} }
bool CMakeTool::autoCreateBuildDirectory() const
{
return m_autoCreateBuildDirectory;
}
QList<CMakeTool::Generator> CMakeTool::supportedGenerators() const QList<CMakeTool::Generator> CMakeTool::supportedGenerators() const
{ {
return isValid() ? m_introspection->m_generators : QList<CMakeTool::Generator>(); return isValid() ? m_introspection->m_generators : QList<CMakeTool::Generator>();

View File

@@ -83,7 +83,6 @@ public:
QVariantMap toMap () const; QVariantMap toMap () const;
void setAutorun(bool autoRun); void setAutorun(bool autoRun);
void setAutoCreateBuildDirectory(bool autoBuildDir);
void setFilePath(const Utils::FilePath &executable); void setFilePath(const Utils::FilePath &executable);
Utils::FilePath filePath() const; Utils::FilePath filePath() const;

View File

@@ -77,13 +77,13 @@ void FileApiReader::setParameters(const BuildDirParameters &p)
// Update: // Update:
m_parameters = p; m_parameters = p;
qCDebug(cmakeFileApiMode) << "Work directory:" << m_parameters.workDirectory.toUserOutput(); qCDebug(cmakeFileApiMode) << "Work directory:" << m_parameters.buildDirectory.toUserOutput();
// Reset watcher: // Reset watcher:
m_watcher.removeFiles(m_watcher.files()); m_watcher.removeFiles(m_watcher.files());
m_watcher.removeDirectories(m_watcher.directories()); m_watcher.removeDirectories(m_watcher.directories());
FileApiParser::setupCMakeFileApi(m_parameters.workDirectory, m_watcher); FileApiParser::setupCMakeFileApi(m_parameters.buildDirectory, m_watcher);
resetData(); resetData();
} }
@@ -116,7 +116,7 @@ void FileApiReader::parse(bool forceCMakeRun,
: QStringList()); : QStringList());
qCDebug(cmakeFileApiMode) << "Parameters request these CMake arguments:" << args; qCDebug(cmakeFileApiMode) << "Parameters request these CMake arguments:" << args;
const FilePath replyFile = FileApiParser::scanForCMakeReplyFile(m_parameters.workDirectory); const FilePath replyFile = FileApiParser::scanForCMakeReplyFile(m_parameters.buildDirectory);
// Only need to update when one of the following conditions is met: // Only need to update when one of the following conditions is met:
// * The user forces the cmake run, // * The user forces the cmake run,
// * The user provided arguments, // * The user provided arguments,
@@ -130,7 +130,7 @@ void FileApiReader::parse(bool forceCMakeRun,
&& anyOf(m_cmakeFiles, [&replyFile](const FilePath &f) { && anyOf(m_cmakeFiles, [&replyFile](const FilePath &f) {
return f.lastModified() > replyFile.lastModified(); return f.lastModified() > replyFile.lastModified();
}); });
const bool queryFileChanged = anyOf(FileApiParser::cmakeQueryFilePaths(m_parameters.workDirectory), const bool queryFileChanged = anyOf(FileApiParser::cmakeQueryFilePaths(m_parameters.buildDirectory),
[&replyFile](const FilePath &qf) { [&replyFile](const FilePath &qf) {
return qf.lastModified() > replyFile.lastModified(); return qf.lastModified() > replyFile.lastModified();
}); });
@@ -249,7 +249,7 @@ void FileApiReader::endState(const FilePath &replyFilePath)
QTC_ASSERT(!m_future.has_value(), return ); QTC_ASSERT(!m_future.has_value(), return );
const FilePath sourceDirectory = m_parameters.sourceDirectory; const FilePath sourceDirectory = m_parameters.sourceDirectory;
const FilePath buildDirectory = m_parameters.workDirectory; const FilePath buildDirectory = m_parameters.buildDirectory;
const FilePath topCmakeFile = m_cmakeFiles.size() == 1 ? *m_cmakeFiles.begin() : FilePath{}; const FilePath topCmakeFile = m_cmakeFiles.size() == 1 ? *m_cmakeFiles.begin() : FilePath{};
const QString cmakeBuildType = m_parameters.cmakeBuildType == "Build" ? "" : m_parameters.cmakeBuildType; const QString cmakeBuildType = m_parameters.cmakeBuildType == "Build" ? "" : m_parameters.cmakeBuildType;
@@ -304,8 +304,8 @@ void FileApiReader::endState(const FilePath &replyFilePath)
void FileApiReader::makeBackupConfiguration(bool store) void FileApiReader::makeBackupConfiguration(bool store)
{ {
FilePath reply = m_parameters.workDirectory.pathAppended(".cmake/api/v1/reply"); FilePath reply = m_parameters.buildDirectory.pathAppended(".cmake/api/v1/reply");
FilePath replyPrev = m_parameters.workDirectory.pathAppended(".cmake/api/v1/reply.prev"); FilePath replyPrev = m_parameters.buildDirectory.pathAppended(".cmake/api/v1/reply.prev");
if (!store) if (!store)
std::swap(reply, replyPrev); std::swap(reply, replyPrev);
@@ -319,8 +319,8 @@ void FileApiReader::makeBackupConfiguration(bool store)
} }
FilePath cmakeCacheTxt = m_parameters.workDirectory.pathAppended("CMakeCache.txt"); FilePath cmakeCacheTxt = m_parameters.buildDirectory.pathAppended("CMakeCache.txt");
FilePath cmakeCacheTxtPrev = m_parameters.workDirectory.pathAppended("CMakeCache.txt.prev"); FilePath cmakeCacheTxtPrev = m_parameters.buildDirectory.pathAppended("CMakeCache.txt.prev");
if (!store) if (!store)
std::swap(cmakeCacheTxt, cmakeCacheTxtPrev); std::swap(cmakeCacheTxt, cmakeCacheTxtPrev);
@@ -333,7 +333,7 @@ void FileApiReader::makeBackupConfiguration(bool store)
void FileApiReader::writeConfigurationIntoBuildDirectory(const QStringList &configurationArguments) void FileApiReader::writeConfigurationIntoBuildDirectory(const QStringList &configurationArguments)
{ {
const FilePath buildDir = m_parameters.workDirectory; const FilePath buildDir = m_parameters.buildDirectory;
QTC_ASSERT(buildDir.exists(), buildDir.ensureWritableDir()); QTC_ASSERT(buildDir.exists(), buildDir.ensureWritableDir());
if (!buildDir.exists()) if (!buildDir.exists())
buildDir.ensureWritableDir(); buildDir.ensureWritableDir();
@@ -384,9 +384,9 @@ void FileApiReader::cmakeFinishedState()
if (m_lastCMakeExitCode != 0) if (m_lastCMakeExitCode != 0)
makeBackupConfiguration(false); makeBackupConfiguration(false);
FileApiParser::setupCMakeFileApi(m_parameters.workDirectory, m_watcher); FileApiParser::setupCMakeFileApi(m_parameters.buildDirectory, m_watcher);
endState(FileApiParser::scanForCMakeReplyFile(m_parameters.workDirectory)); endState(FileApiParser::scanForCMakeReplyFile(m_parameters.buildDirectory));
} }
void FileApiReader::replyDirectoryHasChanged(const QString &directory) const void FileApiReader::replyDirectoryHasChanged(const QString &directory) const
@@ -394,7 +394,7 @@ void FileApiReader::replyDirectoryHasChanged(const QString &directory) const
if (m_isParsing) if (m_isParsing)
return; // This has been triggered by ourselves, ignore. return; // This has been triggered by ourselves, ignore.
const FilePath reply = FileApiParser::scanForCMakeReplyFile(m_parameters.workDirectory); const FilePath reply = FileApiParser::scanForCMakeReplyFile(m_parameters.buildDirectory);
const FilePath dir = reply.absolutePath(); const FilePath dir = reply.absolutePath();
if (dir.isEmpty()) if (dir.isEmpty())
return; // CMake started to fill the result dir, but has not written a result file yet return; // CMake started to fill the result dir, but has not written a result file yet