From 05955d64034002db93b43b6ed373d91d825a8c2b Mon Sep 17 00:00:00 2001 From: Ken Martin Date: Thu, 9 Jan 2003 12:18:22 -0500 Subject: [PATCH] fix bug in env settings --- Source/cmGlobalGenerator.cxx | 37 +----------------------------------- Source/cmGlobalGenerator.h | 2 -- Source/cmake.cxx | 37 ++++++++++++++++++++++++++++++++++++ Source/cmake.h | 2 ++ 4 files changed, 40 insertions(+), 38 deletions(-) diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx index 035525693..56b21da79 100644 --- a/Source/cmGlobalGenerator.cxx +++ b/Source/cmGlobalGenerator.cxx @@ -21,46 +21,11 @@ cmGlobalGenerator::cmGlobalGenerator() { - // Save the environment variables CXX and CC - m_CXXEnvironment = getenv("CXX"); - m_CCEnvironment = getenv("CC"); +// do nothing duh } cmGlobalGenerator::~cmGlobalGenerator() { - // restore the original environment variables CXX and CC - // Restor CC - static char envCC[5000]; - std::string env = "CC="; - if(m_CCEnvironment) - { - env += m_CCEnvironment; - } - std::string::size_type size = env.size(); - if(size > 4999) - { - size = 4999; - } - strncpy(envCC, env.c_str(), size); - envCC[4999] = 0; - putenv(envCC); - - // Restore CXX - static char envCXX[5000]; - env = "CXX="; - if(m_CXXEnvironment) - { - env += m_CXXEnvironment; - } - size = env.size(); - if(size > 4999) - { - size = 4999; - } - strncpy(envCXX, env.c_str(), size); - envCXX[4999] = 0; - putenv(envCXX); - // Delete any existing cmLocalGenerators unsigned int i; for (i = 0; i < m_LocalGenerators.size(); ++i) diff --git a/Source/cmGlobalGenerator.h b/Source/cmGlobalGenerator.h index 3d61d9d30..ee2a1cb74 100644 --- a/Source/cmGlobalGenerator.h +++ b/Source/cmGlobalGenerator.h @@ -109,8 +109,6 @@ protected: private: std::map m_LanguageEnabled; - const char* m_CXXEnvironment; - const char* m_CCEnvironment; }; #endif diff --git a/Source/cmake.cxx b/Source/cmake.cxx index 4200de854..8aff9e3f1 100644 --- a/Source/cmake.cxx +++ b/Source/cmake.cxx @@ -708,9 +708,46 @@ void cmake::SetGlobalGenerator(cmGlobalGenerator *gg) if (m_GlobalGenerator) { delete m_GlobalGenerator; + // restore the original environment variables CXX and CC + // Restor CC + static char envCC[5000]; + std::string env = "CC="; + if(m_CCEnvironment) + { + env += m_CCEnvironment; + } + std::string::size_type size = env.size(); + if(size > 4999) + { + size = 4999; + } + strncpy(envCC, env.c_str(), size); + envCC[4999] = 0; + putenv(envCC); + + // Restore CXX + static char envCXX[5000]; + env = "CXX="; + if(m_CXXEnvironment) + { + env += m_CXXEnvironment; + } + size = env.size(); + if(size > 4999) + { + size = 4999; + } + strncpy(envCXX, env.c_str(), size); + envCXX[4999] = 0; + putenv(envCXX); } + // set the new m_GlobalGenerator = gg; + // Save the environment variables CXX and CC + m_CXXEnvironment = getenv("CXX"); + m_CCEnvironment = getenv("CC"); + // set the cmake instance just to be sure gg->SetCMakeInstance(this); } diff --git a/Source/cmake.h b/Source/cmake.h index d6ecbe53f..143f1e1dd 100644 --- a/Source/cmake.h +++ b/Source/cmake.h @@ -266,5 +266,7 @@ private: bool m_Local; bool m_InTryCompile; std::string m_CMakeCommand; + const char* m_CXXEnvironment; + const char* m_CCEnvironment; };