diff options
author | Brad King <brad.king@kitware.com> | 2018-10-09 11:42:38 (GMT) |
---|---|---|
committer | Kitware Robot <kwrobot@kitware.com> | 2018-10-09 11:42:45 (GMT) |
commit | 03e381cb8a95b804ee30f94130a5f07ab2a00768 (patch) | |
tree | 21ddfe26365eda3d6045944fe772d913a025fe18 /Source | |
parent | 092a0b104a4aa1c4e6df5db11fab5221fd1e9331 (diff) | |
parent | f23760ffac85f4cee6206c654265df9b3a46bf90 (diff) | |
download | CMake-03e381cb8a95b804ee30f94130a5f07ab2a00768.zip CMake-03e381cb8a95b804ee30f94130a5f07ab2a00768.tar.gz CMake-03e381cb8a95b804ee30f94130a5f07ab2a00768.tar.bz2 |
Merge topic 'string-TIMESTAMP-unset-TZ'
f23760ffac string(TIMESTAMP): Fix unset TZ
Acked-by: Kitware Robot <kwrobot@kitware.com>
Acked-by: Attila Krasznahorkay <attila.krasznahorkay@gmail.com>
Merge-request: !2464
Diffstat (limited to 'Source')
-rw-r--r-- | Source/cmTimestamp.cxx | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/Source/cmTimestamp.cxx b/Source/cmTimestamp.cxx index 14cf6e9..da5d21e 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(); |