summaryrefslogtreecommitdiffstats
path: root/Source
diff options
context:
space:
mode:
authorAndy Cedilnik <andy.cedilnik@kitware.com>2006-03-17 20:46:20 (GMT)
committerAndy Cedilnik <andy.cedilnik@kitware.com>2006-03-17 20:46:20 (GMT)
commitb20cb780495630fa8088f9c95309597af22734c1 (patch)
tree2747cff8befd423ac960dcec3caab1dc3ed121e4 /Source
parentca8d1bc99b68f39fb24e76ac1a546e7849248771 (diff)
downloadCMake-b20cb780495630fa8088f9c95309597af22734c1.zip
CMake-b20cb780495630fa8088f9c95309597af22734c1.tar.gz
CMake-b20cb780495630fa8088f9c95309597af22734c1.tar.bz2
ENH: Handle missing unsetenv and add check for environ
Diffstat (limited to 'Source')
-rw-r--r--Source/CMakeLists.txt17
-rw-r--r--Source/cmSystemTools.cxx20
-rw-r--r--Source/cmSystemTools.h2
-rw-r--r--Source/cmake.cxx2
4 files changed, 39 insertions, 2 deletions
diff --git a/Source/CMakeLists.txt b/Source/CMakeLists.txt
index f176751..af259a5 100644
--- a/Source/CMakeLists.txt
+++ b/Source/CMakeLists.txt
@@ -23,6 +23,23 @@ INCLUDE_DIRECTORIES(
# let cmake know it is supposed to use it
ADD_DEFINITIONS(-DCMAKE_BUILD_WITH_CMAKE)
+INCLUDE(CheckSymbolExists)
+CHECK_SYMBOL_EXISTS(unsetenv "stdlib.h" HAVE_UNSETENV)
+INCLUDE("${CMAKE_ROOT}/Modules/CheckCXXSourceCompiles.cmake")
+CHECK_CXX_SOURCE_COMPILES(
+ "int main(int argc, char* argv[]) { return sizeof(environ); }"
+ HAVE_ENVIRON_WITHOUT_SIGNATURE)
+IF(NOT HAVE_ENVIRON_WITHOUT_SIGNATURE)
+ CHECK_CXX_SOURCE_COMPILES(
+ "
+ #ifdef _WIN32
+ extern __declspec( dllimport ) char** environ;
+ #else
+ extern char** environ;
+ #endif
+ int main(int argc, char* argv[]) { return sizeof(environ); }"
+ HAVE_ENVIRON_WITH_SIGNATURE)
+ENDIF(NOT HAVE_ENVIRON_WITHOUT_SIGNATURE)
OPTION(CMAKE_REGENERATE_YACCLEX
"Regenerate YACC and LEXX files" OFF)
diff --git a/Source/cmSystemTools.cxx b/Source/cmSystemTools.cxx
index b047547..8903cc3 100644
--- a/Source/cmSystemTools.cxx
+++ b/Source/cmSystemTools.cxx
@@ -56,7 +56,14 @@
# pragma set woff 1375 /* base class destructor not virtual */
#endif
-extern char** environ; // For GetEnvironmentVariables
+#if !defined(HAVE_ENVIRON_WITHOUT_SIGNATURE)
+// For GetEnvironmentVariables
+# if defined(_WIN32)
+extern __declspec( dllimport ) char** environ;
+# else
+extern char** environ;
+# endif
+#endif
bool cmSystemTools::s_RunCommandHideConsole = false;
bool cmSystemTools::s_DisableRunCommandOutput = false;
@@ -1280,9 +1287,17 @@ bool cmSystemTools::PutEnv(const char* value)
return ret == 0;
}
+#ifdef CMAKE_BUILD_WITH_CMAKE
bool cmSystemTools::UnsetEnv(const char* value)
{
- return false;
+#if !defined(HAVE_UNSETENV)
+ std::string var = value;
+ var += "=";
+ return cmSystemTools::PutEnv(var.c_str());
+#else
+ unsetenv(value);
+ return true;
+#endif
}
std::vector<std::string> cmSystemTools::GetEnvironmentVariables()
@@ -1295,6 +1310,7 @@ std::vector<std::string> cmSystemTools::GetEnvironmentVariables()
}
return env;
}
+#endif
void cmSystemTools::EnableVSConsoleOutput()
{
diff --git a/Source/cmSystemTools.h b/Source/cmSystemTools.h
index 6988139..0973a07 100644
--- a/Source/cmSystemTools.h
+++ b/Source/cmSystemTools.h
@@ -295,11 +295,13 @@ public:
of the form var=value */
static bool PutEnv(const char* value);
+#ifdef CMAKE_BUILD_WITH_CMAKE
/** Remove an environment variable */
static bool UnsetEnv(const char* value);
/** Get the list of all environment variables */
static std::vector<std::string> GetEnvironmentVariables();
+#endif
/** Setup the environment to enable VS 8 IDE output. */
static void EnableVSConsoleOutput();
diff --git a/Source/cmake.cxx b/Source/cmake.cxx
index ef43c61..a66e83b 100644
--- a/Source/cmake.cxx
+++ b/Source/cmake.cxx
@@ -831,6 +831,7 @@ int cmake::ExecuteCMakeCommand(std::vector<std::string>& args)
return 0;
}
+#if defined(CMAKE_BUILD_WITH_CMAKE)
// Command to create a symbolic link. Fails on platforms not
// supporting them.
else if (args[1] == "environment" )
@@ -843,6 +844,7 @@ int cmake::ExecuteCMakeCommand(std::vector<std::string>& args)
}
return 0;
}
+#endif
// Remove file
else if (args[1] == "remove" && args.size() > 2)