diff options
author | dcommander <dcommander@632fc199-4ca6-4c93-a231-07263d6284db> | 2012-10-12 09:29:44 +0000 |
---|---|---|
committer | dcommander <dcommander@632fc199-4ca6-4c93-a231-07263d6284db> | 2012-10-12 09:29:44 +0000 |
commit | 557407dbf1502b36f5e0f845a6c7f1f67c792895 (patch) | |
tree | 749a348bbb0ff8c6713117a5628823bc6711af53 | |
parent | eaf44a15cc32026eccb8188e39ec0dda38b79a53 (diff) |
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://svn.code.sf.net/p/libjpeg-turbo/code/trunk@867 632fc199-4ca6-4c93-a231-07263d6284db
-rw-r--r-- | CMakeLists.txt | 12 | ||||
-rw-r--r-- | cmakescripts/getdate.bat | 3 |
2 files changed, 9 insertions, 6 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index f25f3e9..de458a5 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% |