Fixed generation of configure header, now replacing date fields

with current date.
Added CMake script to generate a variable containing the current
date.
Removed last argument (the terminating NULL element) from output.
This commit is contained in:
Armin Novak
2013-08-06 10:23:43 +02:00
parent 3fa1407c09
commit 38be366a67
4 changed files with 39 additions and 7 deletions

16
cmake/today.cmake Normal file
View File

@@ -0,0 +1,16 @@
# This script returns the current date in ISO format
#
# YYYY-MM-DD
#
MACRO (TODAY RESULT)
IF (WIN32)
EXECUTE_PROCESS(COMMAND "cmd" " /C date +%Y-%m-%d" OUTPUT_VARIABLE ${RESULT})
string(REGEX REPLACE "(..)/(..)/..(..).*" "\\1/\\2/\\3" ${RESULT} ${${RESULT}})
ELSEIF(UNIX)
EXECUTE_PROCESS(COMMAND "date" "+%Y-%m-%d" OUTPUT_VARIABLE ${RESULT})
string(REGEX REPLACE "(..)/(..)/..(..).*" "\\1/\\2/\\3" ${RESULT} ${${RESULT}})
ELSE (WIN32)
MESSAGE(SEND_ERROR "date not implemented")
SET(${RESULT} 000000)
ENDIF (WIN32)
ENDMACRO (TODAY)