From af4e74a9721a5fff29d3f11df6ab70b9890b64be Mon Sep 17 00:00:00 2001 From: Eike Ziller Date: Thu, 26 Nov 2020 09:27:00 +0100 Subject: [PATCH] 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 --- src/plugins/cmakeprojectmanager/cmakebuildsystem.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/plugins/cmakeprojectmanager/cmakebuildsystem.cpp b/src/plugins/cmakeprojectmanager/cmakebuildsystem.cpp index 2f332dc7e9a..88d1b561388 100644 --- a/src/plugins/cmakeprojectmanager/cmakebuildsystem.cpp +++ b/src/plugins/cmakeprojectmanager/cmakebuildsystem.cpp @@ -807,12 +807,16 @@ FilePath CMakeBuildSystem::workDirectory(const BuildDirParameters ¶meters) { 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()));