summaryrefslogtreecommitdiffstats
path: root/cmake/today.cmake
diff options
context:
space:
mode:
Diffstat (limited to 'cmake/today.cmake')
-rw-r--r--cmake/today.cmake11
1 files changed, 11 insertions, 0 deletions
diff --git a/cmake/today.cmake b/cmake/today.cmake
new file mode 100644
index 0000000..9e88801
--- /dev/null
+++ b/cmake/today.cmake
@@ -0,0 +1,11 @@
+# This script returns the current date in ISO format
+#
+# YYYY-MM-DD
+#
+MACRO (TODAY RESULT)
+ if (DEFINED ENV{SOURCE_DATE_EPOCH} AND NOT WIN32)
+ EXECUTE_PROCESS(COMMAND "date" "-u" "-d" "@$ENV{SOURCE_DATE_EPOCH}" "+%Y-%m-%d"
+ OUTPUT_VARIABLE ${RESULT} OUTPUT_STRIP_TRAILING_WHITESPACE)
+ STRING(TIMESTAMP ${RESULT} "%Y-%m-%d" UTC)
+ endif()
+ENDMACRO (TODAY)