Skip to content

Commit 1c1bbe0

Browse files
author
Dilawar Singh
committed
Added GetRevision macro to get current timestamp.
1 parent ba9ec99 commit 1c1bbe0

File tree

2 files changed

+24
-5
lines changed

2 files changed

+24
-5
lines changed

CMakeLists.txt

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
set(CMAKE_LEGACY_CYGWIN_WIN32 0)
2-
cmake_minimum_required(VERSION 2.6.0 FATAL_ERROR)
2+
cmake_minimum_required(VERSION 2.8 FATAL_ERROR)
33

44
if(COMMAND cmake_policy)
55
cmake_policy(SET CMP0003 NEW)
@@ -27,11 +27,9 @@ if( (NOT MOOSE_VERSION) AND GIT_EXEC)
2727
OUTPUT_VARIABLE MOOSE_VERSION
2828
OUTPUT_STRIP_TRAILING_WHITESPACE
2929
)
30-
message(STATUS "+ Writing ${MOOSE_VERSION} to ${VERSION_FILE}" )
3130
elseif( (NOT MOOSE_VERSION) AND (NOT GIT_EXEC) )
32-
message(STATUS "+ Reading ${VERSION_FILE}" )
33-
string(TIMESTAMP MOOSE_VERSION "nightly-%Y%m%d" )
34-
set(GIT_VERSION_OUTPUT "nightly" )
31+
NOW(TIMESTAMP)
32+
set(MOOSE_VERSION "nightly-${TIMESTAMP}" )
3533
elseif(MOOSE_VERSION)
3634
message(STATUS "+ Using user specified VERSION = ${MOOSE_VERSION}" )
3735
else()
@@ -41,6 +39,7 @@ add_definitions( -DMOOSE_VERSION="${MOOSE_VERSION}")
4139
message( STATUS "MOOSE Version ${MOOSE_VERSION}" )
4240

4341
# Write VERSION to a file VERSION so that setup.py can use it.
42+
message(STATUS "+ Writing ${MOOSE_VERSION} to ${VERSION_FILE}" )
4443
file(WRITE ${VERSION_FILE} ${MOOSE_VERSION} )
4544

4645
# This snippet is from LLVM project.

cmake_modules/GetRevision.cmake

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
CMAKE_MINIMUM_REQUIRED(VERSION 2.6.3)
2+
3+
MACRO(NOW RESULT)
4+
IF(CMAKE_VERSION VERSION_GREATER "2.8.10")
5+
STRING(TIMESTAMP ${RESULT} "%Y%m%d")
6+
ELSE()
7+
IF(WIN32)
8+
EXECUTE_PROCESS(COMMAND "wmic" "os" "get" "localdatetime" OUTPUT_VARIABLE DATETIME)
9+
IF(NOT DATETIME MATCHES "ERROR")
10+
STRING(REGEX REPLACE ".*\n([0-9][0-9][0-9][0-9])([0-9][0-9])([0-9][0-9])([0-9][0-9])([0-9][0-9])([0-9][0-9]).*" "\\1-\\2-\\3 \\4:\\5:\\6" ${RESULT} "${DATETIME}")
11+
ENDIF()
12+
ELSEIF(UNIX)
13+
EXECUTE_PROCESS(COMMAND "date" "+%Y%m%d" OUTPUT_VARIABLE DATETIME)
14+
STRING(REGEX REPLACE "([0-9: -]+).*" "\\1" ${RESULT} "${DATETIME}")
15+
ELSE()
16+
MESSAGE(SEND_ERROR "date not implemented")
17+
SET(${RESULT} "00000000")
18+
ENDIF()
19+
ENDIF()
20+
ENDMACRO()

0 commit comments

Comments
 (0)