summaryrefslogtreecommitdiffstats
path: root/Source
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2017-01-27 14:04:53 (GMT)
committerCMake Topic Stage <kwrobot@kitware.com>2017-01-27 14:04:53 (GMT)
commit86ec0aca050f2568cea691a0ec965f6a95e06d2b (patch)
treed8937663f570164ccee6c2f8292c18c6787c1bf4 /Source
parentfa9c12933f0fc51ee577a43b51381b4d8e4a127b (diff)
parent243aed525a2fd8e5fe32139fd0f8d0cc0e40cc33 (diff)
downloadCMake-86ec0aca050f2568cea691a0ec965f6a95e06d2b.zip
CMake-86ec0aca050f2568cea691a0ec965f6a95e06d2b.tar.gz
CMake-86ec0aca050f2568cea691a0ec965f6a95e06d2b.tar.bz2
Merge topic 'topic-reproducible-build'
243aed52 cmTimestamp: Support SOURCE_DATE_EPOCH to override current time
Diffstat (limited to 'Source')
-rw-r--r--Source/cmTimestamp.cxx11
1 files changed, 11 insertions, 0 deletions
diff --git a/Source/cmTimestamp.cxx b/Source/cmTimestamp.cxx
index 4a97114..1e5ac5b 100644
--- a/Source/cmTimestamp.cxx
+++ b/Source/cmTimestamp.cxx
@@ -5,6 +5,7 @@
#include <cmConfigure.h>
#include <cstring>
#include <sstream>
+#include <stdlib.h>
#include "cmSystemTools.h"
@@ -12,6 +13,16 @@ std::string cmTimestamp::CurrentTime(const std::string& formatString,
bool utcFlag)
{
time_t currentTimeT = time(CM_NULLPTR);
+ std::string source_date_epoch;
+ cmSystemTools::GetEnv("SOURCE_DATE_EPOCH", source_date_epoch);
+ if (!source_date_epoch.empty()) {
+ std::istringstream iss(source_date_epoch);
+ iss >> currentTimeT;
+ if (iss.fail() || !iss.eof()) {
+ cmSystemTools::Error("Cannot parse SOURCE_DATE_EPOCH as integer");
+ exit(27);
+ }
+ }
if (currentTimeT == time_t(-1)) {
return std::string();
}