CMake: Create build directory when user changes configuration

When opening and configuring a project, Qt Creator first tries to
configure the project in a temporary directory (if the build directory
doesn't exist anyhow). This is nice if you just open a project for
browsing, and the initial arguments are set up correctly for parsing a
project.

But if the user starts changing the configuration, either by changing
variables and applying the change, or by choosing a "QML debugging and
profiling" option, we should create the actual build directory and do
the configuration there.
Otherwise we have issues with redoing the correct configuration in the
actual build directory later on.

Fixes: QTCREATORBUG-24936
Change-Id: I54013a14f68eb7785e866cc2a9c09bbc43b44233
Reviewed-by: Cristian Adam <cristian.adam@qt.io>
This commit is contained in:
Eike Ziller
2020-11-26 09:27:00 +01:00
parent e6873b5b24
commit af4e74a972

View File

@@ -807,12 +807,16 @@ FilePath CMakeBuildSystem::workDirectory(const BuildDirParameters &parameters)
{
const Utils::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;
}
if (cmake && cmake->autoCreateBuildDirectory()) {
// 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())
handleParsingFailed(
tr("Failed to create build directory \"%1\".").arg(bdir.toUserOutput()));