summaryrefslogtreecommitdiffstats
path: root/Source/cmake.cxx
diff options
context:
space:
mode:
authorBill Hoffman <bill.hoffman@kitware.com>2004-01-26 18:32:46 (GMT)
committerBill Hoffman <bill.hoffman@kitware.com>2004-01-26 18:32:46 (GMT)
commit222e9a2876fccaf5b7da399430b4ec0e4db5d4d4 (patch)
treec59ac6ae8d4ac8c5bd5f6417b8ce1f828c93039a /Source/cmake.cxx
parentdd7f85a9dc791440b48138aecfff02fb934c1027 (diff)
downloadCMake-222e9a2876fccaf5b7da399430b4ec0e4db5d4d4.zip
CMake-222e9a2876fccaf5b7da399430b4ec0e4db5d4d4.tar.gz
CMake-222e9a2876fccaf5b7da399430b4ec0e4db5d4d4.tar.bz2
BUG: fix put/get env problems
Diffstat (limited to 'Source/cmake.cxx')
-rw-r--r--Source/cmake.cxx50
1 files changed, 23 insertions, 27 deletions
diff --git a/Source/cmake.cxx b/Source/cmake.cxx
index 50170c6..c1c2698 100644
--- a/Source/cmake.cxx
+++ b/Source/cmake.cxx
@@ -84,8 +84,7 @@ cmake::cmake()
// encode the MAKEFLAGS variable in a strange way.
if(getenv("MAKEFLAGS"))
{
- static char makeflags[] = "MAKEFLAGS=";
- putenv(makeflags);
+ cmSystemTools::PutEnv("MAKEFLAGS=");
}
m_Local = false;
@@ -876,36 +875,18 @@ void cmake::SetGlobalGenerator(cmGlobalGenerator *gg)
delete m_GlobalGenerator;
// restore the original environment variables CXX and CC
// Restor CC
- static char envCC[5000];
std::string env = "CC=";
- if(m_CCEnvironment)
+ if(m_CCEnvironment.size())
{
env += m_CCEnvironment;
}
- std::string::size_type size = env.size();
- if(size > 4999)
- {
- size = 4999;
- }
- strncpy(envCC, env.c_str(), size);
- envCC[size] = 0;
- putenv(envCC);
-
- // Restore CXX
- static char envCXX[5000];
+ cmSystemTools::PutEnv(env.c_str());
env = "CXX=";
- if(m_CXXEnvironment)
+ if(m_CXXEnvironment.size())
{
env += m_CXXEnvironment;
}
- size = env.size();
- if(size > 4999)
- {
- size = 4999;
- }
- strncpy(envCXX, env.c_str(), size);
- envCXX[size] = 0;
- putenv(envCXX);
+ cmSystemTools::PutEnv(env.c_str());
}
// set the new
@@ -915,9 +896,24 @@ void cmake::SetGlobalGenerator(cmGlobalGenerator *gg)
// on windows.
cmSystemTools::SetForceUnixPaths(m_GlobalGenerator->GetForceUnixPaths());
// Save the environment variables CXX and CC
- m_CXXEnvironment = getenv("CXX");
- m_CCEnvironment = getenv("CC");
-
+ const char* cxx = getenv("CXX");
+ const char* cc = getenv("CC");
+ if(cxx)
+ {
+ m_CXXEnvironment = cxx;
+ }
+ else
+ {
+ m_CXXEnvironment = "";
+ }
+ if(cc)
+ {
+ m_CCEnvironment = cc;
+ }
+ else
+ {
+ m_CCEnvironment = "";
+ }
// set the cmake instance just to be sure
gg->SetCMakeInstance(this);
}