ProjectExplorer: Use different build dir when copying build config

...into another target.
Using the same build directory in two different targets will likely lead
to errors.

Fixes: QTCREATORBUG-23462
Change-Id: I7daa510b3128a344adb51772d44a79415419acc3
Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
Christian Kandeler
2020-01-15 16:47:54 +01:00
parent 1eb72aabef
commit 38cd7b1aa0

View File

@@ -33,6 +33,7 @@
#include "kit.h"
#include "makestep.h"
#include "projectexplorer.h"
#include "projectmacroexpander.h"
#include "projectnodes.h"
#include "runconfiguration.h"
#include "runcontrol.h"
@@ -405,13 +406,19 @@ bool Project::copySteps(Target *sourceTarget, Target *newTarget)
QStringList deployconfigurationError;
QStringList runconfigurationError;
const Project * const project = newTarget->project();
foreach (BuildConfiguration *sourceBc, sourceTarget->buildConfigurations()) {
ProjectMacroExpander expander(project->projectFilePath(), project->displayName(),
newTarget->kit(), sourceBc->displayName(),
sourceBc->buildType());
BuildConfiguration *newBc = BuildConfigurationFactory::clone(newTarget, sourceBc);
if (!newBc) {
buildconfigurationError << sourceBc->displayName();
continue;
}
newBc->setDisplayName(sourceBc->displayName());
newBc->setBuildDirectory(project->projectDirectory()
.resolvePath(expander.expand(ProjectExplorerPlugin::buildDirectoryTemplate())));
newTarget->addBuildConfiguration(newBc);
if (sourceTarget->activeBuildConfiguration() == sourceBc)
SessionManager::setActiveBuildConfiguration(newTarget, newBc, SetActive::NoCascade);