summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2018-10-09 07:33:56 -0400
committerBrad King <brad.king@kitware.com>2018-10-09 07:33:56 -0400
commit54f0ae5414632043ede652797d6c200e6c57dc26 (patch)
tree63960835ea67673fa4891d66bd1f959101ffd8be
parentefa5d5c781abb92e3a634541e89a72b0a520c65f (diff)
parentf23760ffac85f4cee6206c654265df9b3a46bf90 (diff)
downloadcmake-54f0ae5414632043ede652797d6c200e6c57dc26.tar.gz
Merge branch 'string-TIMESTAMP-unset-TZ' into release-3.13
Merge-request: !2464
-rw-r--r--Source/cmTimestamp.cxx12
1 files changed, 11 insertions, 1 deletions
diff --git a/Source/cmTimestamp.cxx b/Source/cmTimestamp.cxx
index 14cf6e9640..da5d21ebb3 100644
--- a/Source/cmTimestamp.cxx
+++ b/Source/cmTimestamp.cxx
@@ -96,7 +96,7 @@ time_t cmTimestamp::CreateUtcTimeTFromTm(struct tm& tm) const
// From Linux timegm() manpage.
std::string tz_old;
- cmSystemTools::GetEnv("TZ", tz_old);
+ bool const tz_was_set = cmSystemTools::GetEnv("TZ", tz_old);
tz_old = "TZ=" + tz_old;
// The standard says that "TZ=" or "TZ=[UNRECOGNIZED_TZ]" means UTC.
@@ -109,7 +109,17 @@ time_t cmTimestamp::CreateUtcTimeTFromTm(struct tm& tm) const
time_t result = mktime(&tm);
+# ifdef CMAKE_BUILD_WITH_CMAKE
+ if (tz_was_set) {
+ cmSystemTools::PutEnv(tz_old);
+ } else {
+ cmSystemTools::UnsetEnv("TZ");
+ }
+# else
+ // No UnsetEnv during bootstrap. This is good enough for CMake itself.
cmSystemTools::PutEnv(tz_old);
+ static_cast<void>(tz_was_set);
+# endif
tzset();