Support old CMake versions without TIMESTAMP #3727

This commit is contained in:
Armin Novak 2017-01-31 16:52:20 +01:00
parent 7c5a2f4a3d
commit 9158fe0e3e

View File

@ -6,6 +6,13 @@ MACRO (TODAY RESULT)
if (DEFINED ENV{SOURCE_DATE_EPOCH} AND NOT WIN32) if (DEFINED ENV{SOURCE_DATE_EPOCH} AND NOT WIN32)
EXECUTE_PROCESS(COMMAND "date" "-u" "-d" "@$ENV{SOURCE_DATE_EPOCH}" "+%Y-%m-%d" EXECUTE_PROCESS(COMMAND "date" "-u" "-d" "@$ENV{SOURCE_DATE_EPOCH}" "+%Y-%m-%d"
OUTPUT_VARIABLE ${RESULT} OUTPUT_STRIP_TRAILING_WHITESPACE) OUTPUT_VARIABLE ${RESULT} OUTPUT_STRIP_TRAILING_WHITESPACE)
elseif(CMAKE_VERSION VERSION_LESS "2.8.11")
if (WIN32)
message(FATAL_ERROR "Your CMake version is too old. Please update to a more recent version >= 2.8.11")
else()
EXECUTE_PROCESS(COMMAND "date" "-u" "+%Y-%m-%d"
OUTPUT_VARIABLE ${RESULT} OUTPUT_STRIP_TRAILING_WHITESPACE)
endif()
else() else()
STRING(TIMESTAMP ${RESULT} "%Y-%m-%d" UTC) STRING(TIMESTAMP ${RESULT} "%Y-%m-%d" UTC)
endif() endif()