Skip to content

Commit 5e3bb3e

Browse files
committed
Use a more robust method of obtaining the build timestamp on Windows. 'wmic os get LocalDateTime' will always return the timestamp in the format we want (YYYYMMDD), whereas date /t is sensitive to locale. If wmic fails, then we fall back to using date /t, even though this means that the BUILD variable will end up in the incorrect format on some systems.
git-svn-id: svn+ssh://svn.code.sf.net/p/libjpeg-turbo/code/branches/1.1.x@869 632fc199-4ca6-4c93-a231-07263d6284db
1 parent 98eecb8 commit 5e3bb3e

File tree

2 files changed

+9
-6
lines changed

2 files changed

+9
-6
lines changed

CMakeLists.txt

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,15 @@ if(MINGW OR CYGWIN)
1111
execute_process(COMMAND "date" "+%Y%m%d" OUTPUT_VARIABLE BUILD)
1212
string(REGEX REPLACE "\n" "" BUILD ${BUILD})
1313
elseif(WIN32)
14-
execute_process(COMMAND "${CMAKE_SOURCE_DIR}/cmakescripts/getdate.bat"
15-
OUTPUT_VARIABLE BUILD)
16-
string(REGEX REPLACE "\n" "" BUILD ${BUILD})
14+
execute_process(COMMAND "wmic.exe" "os" "get" "LocalDateTime" OUTPUT_VARIABLE
15+
BUILD)
16+
string(REGEX REPLACE "[^0-9]" "" BUILD "${BUILD}")
17+
if (BUILD STREQUAL "")
18+
execute_process(COMMAND "cmd.exe" "/C" "DATE" "/T" OUTPUT_VARIABLE BUILD)
19+
string(REGEX REPLACE ".*[ ]([0-9]*)[/.]([0-9]*)[/.]([0-9]*).*" "\\3\\2\\1" BUILD "${BUILD}")
20+
else()
21+
string(SUBSTRING "${BUILD}" 0 8 BUILD)
22+
endif()
1723
else()
1824
message(FATAL_ERROR "Platform not supported by this build system. Use autotools instead.")
1925
endif()

cmakescripts/getdate.bat

Lines changed: 0 additions & 3 deletions
This file was deleted.

0 commit comments

Comments
 (0)