forked from qt-creator/qt-creator
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:
@@ -807,12 +807,16 @@ FilePath CMakeBuildSystem::workDirectory(const BuildDirParameters ¶meters)
|
|||||||
{
|
{
|
||||||
const Utils::FilePath bdir = parameters.buildDirectory;
|
const Utils::FilePath bdir = parameters.buildDirectory;
|
||||||
const CMakeTool *cmake = parameters.cmakeTool();
|
const CMakeTool *cmake = parameters.cmakeTool();
|
||||||
|
|
||||||
|
// use the build directory if it already exists anyhow
|
||||||
if (bdir.exists()) {
|
if (bdir.exists()) {
|
||||||
m_buildDirToTempDir.erase(bdir);
|
m_buildDirToTempDir.erase(bdir);
|
||||||
return 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())
|
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()));
|
||||||
|
Reference in New Issue
Block a user