Commit 747f7503 authored by Tobias Hunger's avatar Tobias Hunger
Browse files

Set BUILDDIR and SOURCEDIR environment variables

Set BUILDDIR and SOURCEDIR in the build environment.

Reviewed-by: dt
parent 27ded207
......@@ -76,10 +76,15 @@ QVariantMap CMakeBuildConfiguration::toMap() const
bool CMakeBuildConfiguration::fromMap(const QVariantMap &map)
{
if (!BuildConfiguration::fromMap(map))
return false;
m_msvcVersion = map.value(QLatin1String(MSVC_VERSION_KEY)).toString();
m_buildDirectory = map.value(QLatin1String(BUILD_DIRECTORY_KEY), cmakeTarget()->defaultBuildDirectory()).toString();
return BuildConfiguration::fromMap(map);
environment().set("BUILDDIR", m_buildDirectory);
return true;
}
CMakeBuildConfiguration::~CMakeBuildConfiguration()
......@@ -137,7 +142,9 @@ void CMakeBuildConfiguration::setBuildDirectory(const QString &buildDirectory)
if (m_buildDirectory == buildDirectory)
return;
m_buildDirectory = buildDirectory;
environment().set("BUILDDIR", m_buildDirectory);
emit buildDirectoryChanged();
emit environmentChanged();
}
QString CMakeBuildConfiguration::msvcVersion() const
......
......@@ -34,6 +34,7 @@
#include "projectexplorer.h"
#include "projectexplorerconstants.h"
#include "target.h"
#include "project.h"
#include <QtCore/QProcess>
......@@ -144,9 +145,14 @@ Target *BuildConfiguration::target() const
Environment BuildConfiguration::baseEnvironment() const
{
Environment result;
if (useSystemEnvironment())
return Environment(QProcess::systemEnvironment());
return Environment();
result = Environment(QProcess::systemEnvironment());
result.set(QLatin1String("BUILDDIR"), QDir::toNativeSeparators(target()->project()->projectDirectory()));
result.set(QLatin1String("SOURCEDIR"), QDir::toNativeSeparators(target()->project()->projectDirectory()));
return result;
}
QString BuildConfiguration::baseEnvironmentText() const
......
......@@ -165,6 +165,7 @@ bool Qt4BuildConfiguration::fromMap(const QVariantMap &map)
qWarning() << "No toolchain available for" << qtVersion()->displayName() << "used in" << target()->id() << "!";
return false;
}
return true;
}
......@@ -197,6 +198,8 @@ ProjectExplorer::Environment Qt4BuildConfiguration::baseEnvironment() const
{
Environment env = BuildConfiguration::baseEnvironment();
qtVersion()->addToEnvironment(env);
env.set(QLatin1String("BUILDDIR"), QDir::toNativeSeparators(buildDirectory()));
ToolChain *tc = toolChain();
if (tc)
tc->addToEnvironment(env);
......@@ -265,6 +268,8 @@ void Qt4BuildConfiguration::setShadowBuildAndDirectory(bool shadowBuild, const Q
m_shadowBuild = toSet;
m_buildDirectory = directoryToSet;
emit environmentChanged();
emit buildDirectoryChanged();
emit proFileEvaluateNeeded(this);
}
......
Supports Markdown
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