diff --git a/src/plugins/cmakeprojectmanager/cmakeopenprojectwizard.cpp b/src/plugins/cmakeprojectmanager/cmakeopenprojectwizard.cpp
index 89c53607c46ce75351d50cb230b7c143d3fdf0a8..a18e24133f5bdbcfbe83e9c3a47487f5adc8d178 100644
--- a/src/plugins/cmakeprojectmanager/cmakeopenprojectwizard.cpp
+++ b/src/plugins/cmakeprojectmanager/cmakeopenprojectwizard.cpp
@@ -55,10 +55,11 @@ using namespace CMakeProjectManager::Internal;
 //                                   |--> Already existing cbp file (and new enough) --> Page: Ready to load the project
 //                                   |--> Page: Ask for cmd options, run generator
 
-CMakeOpenProjectWizard::CMakeOpenProjectWizard(CMakeManager *cmakeManager, const QString &sourceDirectory)
+CMakeOpenProjectWizard::CMakeOpenProjectWizard(CMakeManager *cmakeManager, const QString &sourceDirectory, const ProjectExplorer::Environment &env)
     : m_cmakeManager(cmakeManager),
       m_sourceDirectory(sourceDirectory),
-      m_creatingCbpFiles(false)
+      m_creatingCbpFiles(false),
+      m_environment(env)
 {
     int startid;
     if (hasInSourceBuild()) {
@@ -80,10 +81,12 @@ CMakeOpenProjectWizard::CMakeOpenProjectWizard(CMakeManager *cmakeManager, const
 }
 
 CMakeOpenProjectWizard::CMakeOpenProjectWizard(CMakeManager *cmakeManager, const QString &sourceDirectory,
-                                               const QString &buildDirectory, CMakeOpenProjectWizard::Mode mode)
+                                               const QString &buildDirectory, CMakeOpenProjectWizard::Mode mode,
+                                               const ProjectExplorer::Environment &env)
     : m_cmakeManager(cmakeManager),
       m_sourceDirectory(sourceDirectory),
-      m_creatingCbpFiles(true)
+      m_creatingCbpFiles(true),
+      m_environment(env)
 {
     if (mode == CMakeOpenProjectWizard::NeedToCreate)
         addPage(new CMakeRunPage(this, CMakeRunPage::Recreate, buildDirectory));
@@ -94,10 +97,12 @@ CMakeOpenProjectWizard::CMakeOpenProjectWizard(CMakeManager *cmakeManager, const
 }
 
 CMakeOpenProjectWizard::CMakeOpenProjectWizard(CMakeManager *cmakeManager, const QString &sourceDirectory,
-                                               const QString &oldBuildDirectory)
+                                               const QString &oldBuildDirectory,
+                                               const ProjectExplorer::Environment &env)
     : m_cmakeManager(cmakeManager),
       m_sourceDirectory(sourceDirectory),
-      m_creatingCbpFiles(true)
+      m_creatingCbpFiles(true),
+      m_environment(env)
 {
     m_buildDirectory = oldBuildDirectory;
     addPage(new ShadowBuildPage(this, true));
@@ -177,6 +182,11 @@ void CMakeOpenProjectWizard::setArguments(const QStringList &args)
     m_arguments = args;
 }
 
+ProjectExplorer::Environment CMakeOpenProjectWizard::environment() const
+{
+    return m_environment;
+}
+
 
 InSourceBuildPage::InSourceBuildPage(CMakeOpenProjectWizard *cmakeWizard)
     : QWizardPage(cmakeWizard), m_cmakeWizard(cmakeWizard)
@@ -304,7 +314,7 @@ void CMakeRunPage::runCMake()
     m_argumentsLineEdit->setEnabled(false);
     QStringList arguments = ProjectExplorer::Environment::parseCombinedArgString(m_argumentsLineEdit->text());
     CMakeManager *cmakeManager = m_cmakeWizard->cmakeManager();
-    m_cmakeProcess = cmakeManager->createXmlFile(arguments, m_cmakeWizard->sourceDirectory(), m_buildDirectory);
+    m_cmakeProcess = cmakeManager->createXmlFile(arguments, m_cmakeWizard->sourceDirectory(), m_buildDirectory, m_cmakeWizard->environment());
     connect(m_cmakeProcess, SIGNAL(readyRead()), this, SLOT(cmakeReadyRead()));
     connect(m_cmakeProcess, SIGNAL(finished(int)), this, SLOT(cmakeFinished()));
 }
diff --git a/src/plugins/cmakeprojectmanager/cmakeopenprojectwizard.h b/src/plugins/cmakeprojectmanager/cmakeopenprojectwizard.h
index ff5018034960c2d032a808040640ae1efb18f936..487037801ebafd032a92af1f6f1ecfd4bf8b980f 100644
--- a/src/plugins/cmakeprojectmanager/cmakeopenprojectwizard.h
+++ b/src/plugins/cmakeprojectmanager/cmakeopenprojectwizard.h
@@ -30,6 +30,8 @@
 #ifndef CMAKEOPENPROJECTWIZARD_H
 #define CMAKEOPENPROJECTWIZARD_H
 
+#include <projectexplorer/environment.h>
+
 #include <QtCore/QProcess>
 #include <QtGui/QPushButton>
 #include <QtGui/QLineEdit>
@@ -66,11 +68,11 @@ public:
     };
 
     // used at importing a project without a .user file
-    CMakeOpenProjectWizard(CMakeManager *cmakeManager, const QString &sourceDirectory);
+    CMakeOpenProjectWizard(CMakeManager *cmakeManager, const QString &sourceDirectory, const ProjectExplorer::Environment &env);
     // used to update if we have already a .user file
-    CMakeOpenProjectWizard(CMakeManager *cmakeManager, const QString &sourceDirectory, const QString &buildDirectory, Mode mode);
+    CMakeOpenProjectWizard(CMakeManager *cmakeManager, const QString &sourceDirectory, const QString &buildDirectory, Mode mode, const ProjectExplorer::Environment &env);
     // used to change the build directory of one buildconfiguration
-    CMakeOpenProjectWizard(CMakeManager *cmakeManager, const QString &sourceDirectory, const QString &oldBuildDirectory);
+    CMakeOpenProjectWizard(CMakeManager *cmakeManager, const QString &sourceDirectory, const QString &oldBuildDirectory, const ProjectExplorer::Environment &env);
 
     virtual int nextId() const;
     QString buildDirectory() const;
@@ -79,6 +81,7 @@ public:
     CMakeManager *cmakeManager() const;
     QStringList arguments() const;
     void setArguments(const QStringList &args);
+    ProjectExplorer::Environment environment() const;
 private:
     bool existsUpToDateXmlFile() const;
     bool hasInSourceBuild() const;
@@ -87,6 +90,7 @@ private:
     QString m_sourceDirectory;
     QStringList m_arguments;
     bool m_creatingCbpFiles;
+    ProjectExplorer::Environment m_environment;
 };
 
 class InSourceBuildPage : public QWizardPage
diff --git a/src/plugins/cmakeprojectmanager/cmakeproject.cpp b/src/plugins/cmakeprojectmanager/cmakeproject.cpp
index 33585d220cde2d2d3415314c8819372d3c9015be..ab4887c52f2b2c19b59a0a906869dd4a86687c1a 100644
--- a/src/plugins/cmakeprojectmanager/cmakeproject.cpp
+++ b/src/plugins/cmakeprojectmanager/cmakeproject.cpp
@@ -104,7 +104,11 @@ void CMakeProject::slotActiveBuildConfiguration()
         mode = CMakeOpenProjectWizard::Nothing;
 
     if (mode != CMakeOpenProjectWizard::Nothing) {
-        CMakeOpenProjectWizard copw(m_manager, sourceFileInfo.absolutePath(), buildDirectory(activeBuildConfiguration()), mode);
+        CMakeOpenProjectWizard copw(m_manager,
+                                    sourceFileInfo.absolutePath(),
+                                    buildDirectory(activeBuildConfiguration()),
+                                    mode,
+                                    environment(activeBuildConfiguration()));
         copw.exec();
     }
     // reparse
@@ -501,7 +505,7 @@ QList<ProjectExplorer::BuildStepConfigWidget*> CMakeProject::subConfigWidgets()
      // Default to all
      makeStep()->setBuildTarget(buildConfiguration, "all", true);
 
-    CMakeOpenProjectWizard copw(projectManager(), sourceDirectory(), buildDirectory(buildConfiguration));
+    CMakeOpenProjectWizard copw(projectManager(), sourceDirectory(), buildDirectory(buildConfiguration), environment(buildConfiguration));
     if (copw.exec() == QDialog::Accepted) {
         setValue(buildConfiguration, "buildDirectory", copw.buildDirectory());
         parseCMakeLists();
@@ -544,7 +548,7 @@ void CMakeProject::restoreSettingsImpl(ProjectExplorer::PersistentSettingsReader
         // Ask the user for where he wants to build it
         // and the cmake command line
 
-        CMakeOpenProjectWizard copw(m_manager, sourceDirectory());
+        CMakeOpenProjectWizard copw(m_manager, sourceDirectory(), ProjectExplorer::Environment::systemEnvironment());
         copw.exec();
         // TODO handle cancel....
 
@@ -581,7 +585,11 @@ void CMakeProject::restoreSettingsImpl(ProjectExplorer::PersistentSettingsReader
             mode = CMakeOpenProjectWizard::NeedToUpdate;
 
         if (mode != CMakeOpenProjectWizard::Nothing) {
-            CMakeOpenProjectWizard copw(m_manager, sourceFileInfo.absolutePath(), buildDirectory(activeBuildConfiguration()), mode);
+            CMakeOpenProjectWizard copw(m_manager,
+                                        sourceFileInfo.absolutePath(),
+                                        buildDirectory(activeBuildConfiguration()),
+                                        mode,
+                                        environment(activeBuildConfiguration()));
             copw.exec();
         }
     }
@@ -692,7 +700,10 @@ void CMakeBuildSettingsWidget::init(const QString &buildConfiguration)
 
 void CMakeBuildSettingsWidget::openChangeBuildDirectoryDialog()
 {
-    CMakeOpenProjectWizard copw(m_project->projectManager(), m_project->sourceDirectory(), m_project->buildDirectory(m_buildConfiguration));
+    CMakeOpenProjectWizard copw(m_project->projectManager(),
+                                m_project->sourceDirectory(),
+                                m_project->buildDirectory(m_buildConfiguration),
+                                m_project->environment(m_buildConfiguration));
     if (copw.exec() == QDialog::Accepted) {
         m_project->changeBuildDirectory(m_buildConfiguration, copw.buildDirectory());
         m_pathLineEdit->setText(m_project->buildDirectory(m_buildConfiguration));
diff --git a/src/plugins/cmakeprojectmanager/cmakeprojectmanager.cpp b/src/plugins/cmakeprojectmanager/cmakeprojectmanager.cpp
index 77dc18c5d300a5a4a0c349579e5e82bed2c931a2..52eea3068b652658e6ed8b6174d07789ce696bb6 100644
--- a/src/plugins/cmakeprojectmanager/cmakeprojectmanager.cpp
+++ b/src/plugins/cmakeprojectmanager/cmakeprojectmanager.cpp
@@ -96,7 +96,7 @@ QString CMakeManager::cmakeExecutable() const
 // we probably want the process instead of this function
 // cmakeproject then could even run the cmake process in the background, adding the files afterwards
 // sounds like a plan
-QProcess *CMakeManager::createXmlFile(const QStringList &arguments, const QString &sourceDirectory, const QDir &buildDirectory)
+QProcess *CMakeManager::createXmlFile(const QStringList &arguments, const QString &sourceDirectory, const QDir &buildDirectory, const ProjectExplorer::Environment &env)
 {
     // We create a cbp file, only if we didn't find a cbp file in the base directory
     // Yet that can still override cbp files in subdirectories
@@ -113,6 +113,7 @@ QProcess *CMakeManager::createXmlFile(const QStringList &arguments, const QStrin
     QProcess *cmake = new QProcess;
     cmake->setWorkingDirectory(buildDirectoryPath);
     cmake->setProcessChannelMode(QProcess::MergedChannels);
+    cmake->setEnvironment(env.toStringList());
 
 #ifdef Q_OS_WIN
     const QString generator = QLatin1String("-GCodeBlocks - MinGW Makefiles");
diff --git a/src/plugins/cmakeprojectmanager/cmakeprojectmanager.h b/src/plugins/cmakeprojectmanager/cmakeprojectmanager.h
index 49c5f4576bac34b06603b0d3a20cf5055dc4eadb..37b671fe45860d4508c27b141d30ea17f4f1995b 100644
--- a/src/plugins/cmakeprojectmanager/cmakeprojectmanager.h
+++ b/src/plugins/cmakeprojectmanager/cmakeprojectmanager.h
@@ -59,7 +59,10 @@ public:
     virtual QString mimeType() const;
     QString cmakeExecutable() const;
 
-    QProcess* createXmlFile(const QStringList &arguments, const QString &sourceDirectory, const QDir &buildDirectory);
+    QProcess* createXmlFile(const QStringList &arguments,
+                            const QString &sourceDirectory,
+                            const QDir &buildDirectory,
+                            const ProjectExplorer::Environment &env);
     static QString findCbpFile(const QDir &);
 
     static QString findDumperLibrary(const ProjectExplorer::Environment &env);