From 5e3bb3e9c8c104872f8f4fe489d2c5025326ce1b Mon Sep 17 00:00:00 2001 From: DRC Date: Fri, 12 Oct 2012 10:19:09 +0000 Subject: [PATCH] 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 --- CMakeLists.txt | 12 +++++++++--- cmakescripts/getdate.bat | 3 --- 2 files changed, 9 insertions(+), 6 deletions(-) delete mode 100644 cmakescripts/getdate.bat diff --git a/CMakeLists.txt b/CMakeLists.txt index 28f8e00..6229ea0 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -11,9 +11,15 @@ if(MINGW OR CYGWIN) execute_process(COMMAND "date" "+%Y%m%d" OUTPUT_VARIABLE BUILD) string(REGEX REPLACE "\n" "" BUILD ${BUILD}) elseif(WIN32) - execute_process(COMMAND "${CMAKE_SOURCE_DIR}/cmakescripts/getdate.bat" - OUTPUT_VARIABLE BUILD) - string(REGEX REPLACE "\n" "" BUILD ${BUILD}) + execute_process(COMMAND "wmic.exe" "os" "get" "LocalDateTime" OUTPUT_VARIABLE + BUILD) + string(REGEX REPLACE "[^0-9]" "" BUILD "${BUILD}") + if (BUILD STREQUAL "") + execute_process(COMMAND "cmd.exe" "/C" "DATE" "/T" OUTPUT_VARIABLE BUILD) + string(REGEX REPLACE ".*[ ]([0-9]*)[/.]([0-9]*)[/.]([0-9]*).*" "\\3\\2\\1" BUILD "${BUILD}") + else() + string(SUBSTRING "${BUILD}" 0 8 BUILD) + endif() else() message(FATAL_ERROR "Platform not supported by this build system. Use autotools instead.") endif() diff --git a/cmakescripts/getdate.bat b/cmakescripts/getdate.bat deleted file mode 100644 index b4251bb..0000000 --- a/cmakescripts/getdate.bat +++ /dev/null @@ -1,3 +0,0 @@ -@echo off -for /f "tokens=1-4 eol=/ DELIMS=/ " %%i in ('date /t') do set BUILD=%%l%%j%%k -echo %BUILD% -- 2.40.0