forked from qt-creator/qt-creator
CMake: Fix build directory for "Add Buildconfiguration"
Task-number: QTCREATORBUG-8425 Change-Id: I58a47895fa882bcc53cad1ef764a307c714f2a1b Reviewed-by: Tobias Hunger <tobias.hunger@digia.com>
This commit is contained in:
committed by
Tobias Hunger
parent
4fd25854de
commit
66bc398183
@@ -57,7 +57,10 @@ const char USE_NINJA_KEY[] = "CMakeProjectManager.CMakeBuildConfiguration.UseNin
|
|||||||
CMakeBuildConfiguration::CMakeBuildConfiguration(ProjectExplorer::Target *parent) :
|
CMakeBuildConfiguration::CMakeBuildConfiguration(ProjectExplorer::Target *parent) :
|
||||||
BuildConfiguration(parent, Core::Id(Constants::CMAKE_BC_ID)), m_useNinja(false)
|
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,
|
CMakeBuildConfiguration::CMakeBuildConfiguration(ProjectExplorer::Target *parent,
|
||||||
@@ -184,7 +187,9 @@ CMakeBuildConfiguration *CMakeBuildConfigurationFactory::create(ProjectExplorer:
|
|||||||
info.sourceDirectory = project->projectDirectory();
|
info.sourceDirectory = project->projectDirectory();
|
||||||
info.environment = Utils::Environment::systemEnvironment();
|
info.environment = Utils::Environment::systemEnvironment();
|
||||||
parent->kit()->addToEnvironment(info.environment);
|
parent->kit()->addToEnvironment(info.environment);
|
||||||
info.buildDirectory = project->defaultBuildDirectory();
|
info.buildDirectory = project->shadowBuildDirectory(project->document()->fileName(),
|
||||||
|
parent->kit(),
|
||||||
|
buildConfigurationName);
|
||||||
info.kit = parent->kit();
|
info.kit = parent->kit();
|
||||||
info.useNinja = false; // This is ignored anyway
|
info.useNinja = false; // This is ignored anyway
|
||||||
|
|
||||||
|
@@ -48,7 +48,10 @@
|
|||||||
#include <projectexplorer/toolchain.h>
|
#include <projectexplorer/toolchain.h>
|
||||||
#include <projectexplorer/target.h>
|
#include <projectexplorer/target.h>
|
||||||
#include <projectexplorer/deployconfiguration.h>
|
#include <projectexplorer/deployconfiguration.h>
|
||||||
|
#include <projectexplorer/projectmacroexpander.h>
|
||||||
#include <qtsupport/customexecutablerunconfiguration.h>
|
#include <qtsupport/customexecutablerunconfiguration.h>
|
||||||
|
#include <qtsupport/baseqtversion.h>
|
||||||
|
#include <qtsupport/qtkitinformation.h>
|
||||||
#include <cpptools/ModelManagerInterface.h>
|
#include <cpptools/ModelManagerInterface.h>
|
||||||
#include <extensionsystem/pluginmanager.h>
|
#include <extensionsystem/pluginmanager.h>
|
||||||
#include <utils/qtcassert.h>
|
#include <utils/qtcassert.h>
|
||||||
@@ -196,10 +199,21 @@ void CMakeProject::changeBuildDirectory(CMakeBuildConfiguration *bc, const QStri
|
|||||||
parseCMakeLists();
|
parseCMakeLists();
|
||||||
}
|
}
|
||||||
|
|
||||||
QString CMakeProject::defaultBuildDirectory() const
|
QString CMakeProject::shadowBuildDirectory(const QString &projectFilePath, const Kit *k, const QString &bcName)
|
||||||
{
|
{
|
||||||
return Utils::expandMacros(Core::DocumentManager::instance()->buildDirectory(),
|
if (projectFilePath.isEmpty())
|
||||||
Core::VariableManager::instance()->macroExpander());
|
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()
|
bool CMakeProject::parseCMakeLists()
|
||||||
|
@@ -94,8 +94,8 @@ public:
|
|||||||
|
|
||||||
CMakeBuildTarget buildTargetForTitle(const QString &title);
|
CMakeBuildTarget buildTargetForTitle(const QString &title);
|
||||||
|
|
||||||
QString defaultBuildDirectory() const;
|
QString shadowBuildDirectory(const QString &projectFilePath, const ProjectExplorer::Kit *k,
|
||||||
|
const QString &bcName);
|
||||||
|
|
||||||
QString uicCommand() const;
|
QString uicCommand() const;
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user