Commit 66bc3981 authored by Daniel Teske's avatar Daniel Teske Committed by Tobias Hunger
Browse files

CMake: Fix build directory for "Add Buildconfiguration"



Task-number: QTCREATORBUG-8425

Change-Id: I58a47895fa882bcc53cad1ef764a307c714f2a1b
Reviewed-by: default avatarTobias Hunger <tobias.hunger@digia.com>
parent 4fd25854
......@@ -57,7 +57,10 @@ const char USE_NINJA_KEY[] = "CMakeProjectManager.CMakeBuildConfiguration.UseNin
CMakeBuildConfiguration::CMakeBuildConfiguration(ProjectExplorer::Target *parent) :
BuildConfiguration(parent, Core::Id(Constants::CMAKE_BC_ID)), m_useNinja(false)
{
m_buildDirectory = static_cast<CMakeProject *>(parent->project())->defaultBuildDirectory();
CMakeProject *project = static_cast<CMakeProject *>(parent->project());
m_buildDirectory = project->shadowBuildDirectory(project->document()->fileName(),
parent->kit(),
displayName());
}
CMakeBuildConfiguration::CMakeBuildConfiguration(ProjectExplorer::Target *parent,
......@@ -184,7 +187,9 @@ CMakeBuildConfiguration *CMakeBuildConfigurationFactory::create(ProjectExplorer:
info.sourceDirectory = project->projectDirectory();
info.environment = Utils::Environment::systemEnvironment();
parent->kit()->addToEnvironment(info.environment);
info.buildDirectory = project->defaultBuildDirectory();
info.buildDirectory = project->shadowBuildDirectory(project->document()->fileName(),
parent->kit(),
buildConfigurationName);
info.kit = parent->kit();
info.useNinja = false; // This is ignored anyway
......
......@@ -48,7 +48,10 @@
#include <projectexplorer/toolchain.h>
#include <projectexplorer/target.h>
#include <projectexplorer/deployconfiguration.h>
#include <projectexplorer/projectmacroexpander.h>
#include <qtsupport/customexecutablerunconfiguration.h>
#include <qtsupport/baseqtversion.h>
#include <qtsupport/qtkitinformation.h>
#include <cpptools/ModelManagerInterface.h>
#include <extensionsystem/pluginmanager.h>
#include <utils/qtcassert.h>
......@@ -196,10 +199,21 @@ void CMakeProject::changeBuildDirectory(CMakeBuildConfiguration *bc, const QStri
parseCMakeLists();
}
QString CMakeProject::defaultBuildDirectory() const
QString CMakeProject::shadowBuildDirectory(const QString &projectFilePath, const Kit *k, const QString &bcName)
{
return Utils::expandMacros(Core::DocumentManager::instance()->buildDirectory(),
Core::VariableManager::instance()->macroExpander());
if (projectFilePath.isEmpty())
return QString();
QFileInfo info(projectFilePath);
QtSupport::BaseQtVersion *version = QtSupport::QtKitInformation::qtVersion(k);
if (version && !version->supportsShadowBuilds())
return info.absolutePath();
const QString projectName = QFileInfo(info.absolutePath()).fileName();
ProjectExplorer::ProjectExpander expander(projectFilePath, projectName, k, bcName);
QDir projectDir = QDir(projectDirectory(projectFilePath));
QString buildPath = Utils::expandMacros(Core::DocumentManager::buildDirectory(), &expander);
return QDir::cleanPath(projectDir.absoluteFilePath(buildPath));
}
bool CMakeProject::parseCMakeLists()
......
......@@ -94,8 +94,8 @@ public:
CMakeBuildTarget buildTargetForTitle(const QString &title);
QString defaultBuildDirectory() const;
QString shadowBuildDirectory(const QString &projectFilePath, const ProjectExplorer::Kit *k,
const QString &bcName);
QString uicCommand() const;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment