summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Source/CTest/cmCTestScriptHandler.cxx4
-rw-r--r--Source/cmSystemTools.cxx12
-rw-r--r--Source/cmSystemTools.h14
3 files changed, 30 insertions, 0 deletions
diff --git a/Source/CTest/cmCTestScriptHandler.cxx b/Source/CTest/cmCTestScriptHandler.cxx
index 5983e68..fdf17e0 100644
--- a/Source/CTest/cmCTestScriptHandler.cxx
+++ b/Source/CTest/cmCTestScriptHandler.cxx
@@ -583,6 +583,10 @@ void cmCTestScriptHandler::SleepInSeconds(unsigned int secondsToWait)
int cmCTestScriptHandler::RunConfigurationScript
(const std::string& total_script_arg, bool pscope)
{
+#ifdef CMAKE_BUILD_WITH_CMAKE
+ cmSystemTools::SaveRestoreEnvironment sre;
+#endif
+
int result;
this->ScriptStartTime =
diff --git a/Source/cmSystemTools.cxx b/Source/cmSystemTools.cxx
index 89a241d..351e1b1 100644
--- a/Source/cmSystemTools.cxx
+++ b/Source/cmSystemTools.cxx
@@ -1673,6 +1673,18 @@ void cmSystemTools::RestoreEnv(const std::vector<std::string>& env)
PutEnv(eit->c_str());
}
}
+
+//----------------------------------------------------------------------
+cmSystemTools::SaveRestoreEnvironment::SaveRestoreEnvironment()
+{
+ this->Env = cmSystemTools::GetEnvironmentVariables();
+}
+
+//----------------------------------------------------------------------
+cmSystemTools::SaveRestoreEnvironment::~SaveRestoreEnvironment()
+{
+ cmSystemTools::RestoreEnv(this->Env);
+}
#endif
void cmSystemTools::EnableVSConsoleOutput()
diff --git a/Source/cmSystemTools.h b/Source/cmSystemTools.h
index e5bb305..ed924dd 100644
--- a/Source/cmSystemTools.h
+++ b/Source/cmSystemTools.h
@@ -358,6 +358,20 @@ public:
AppendEnv to put the environment back to the way it
was. */
static void RestoreEnv(const std::vector<std::string>& env);
+
+ /** Helper class to save and restore the environment.
+ Instantiate this class as an automatic variable on
+ the stack. Its constructor saves a copy of the current
+ environment and then its destructor restores the
+ original environment. */
+ class SaveRestoreEnvironment
+ {
+ public:
+ SaveRestoreEnvironment();
+ virtual ~SaveRestoreEnvironment();
+ private:
+ std::vector<std::string> Env;
+ };
#endif
/** Setup the environment to enable VS 8 IDE output. */