From 39858d70172e9e17bb2d6ec455ab243b9b784c15 Mon Sep 17 00:00:00 2001 From: Davide Beatrici Date: Thu, 13 Sep 2018 22:54:03 +0200 Subject: [PATCH] CMake: fix date/time leading 0 removal regex and print both during configuration The previous regex expression removed all the 0s present in the input string, meaning that it caused the build to fail in case one of the date/time values was effectively 0. --- src/Cedar/CMakeLists.txt | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/src/Cedar/CMakeLists.txt b/src/Cedar/CMakeLists.txt index 19d5b60e..19b191bf 100644 --- a/src/Cedar/CMakeLists.txt +++ b/src/Cedar/CMakeLists.txt @@ -42,12 +42,15 @@ string(TIMESTAMP BUILD_MINUTE "%M" UTC) string(TIMESTAMP BUILD_SECOND "%S" UTC) ## Remove leading 0 -string(REGEX REPLACE "^0" "" BUILD_DAY "${BUILD_DAY}") -string(REGEX REPLACE "^0" "" BUILD_MONTH "${BUILD_MONTH}") -string(REGEX REPLACE "^0" "" BUILD_YEAR "${BUILD_YEAR}") -string(REGEX REPLACE "^0" "" BUILD_HOUR "${BUILD_HOUR}") -string(REGEX REPLACE "^0" "" BUILD_MINUTE "${BUILD_MINUTE}") -string(REGEX REPLACE "^0" "" BUILD_SECOND "${BUILD_SECOND}") +string(REGEX REPLACE "^0([^ ]*)" "\\1" BUILD_DAY "${BUILD_DAY}") +string(REGEX REPLACE "^0([^ ]*)" "\\1" BUILD_MONTH "${BUILD_MONTH}") +string(REGEX REPLACE "^0([^ ]*)" "\\1" BUILD_YEAR "${BUILD_YEAR}") +string(REGEX REPLACE "^0([^ ]*)" "\\1" BUILD_HOUR "${BUILD_HOUR}") +string(REGEX REPLACE "^0([^ ]*)" "\\1" BUILD_MINUTE "${BUILD_MINUTE}") +string(REGEX REPLACE "^0([^ ]*)" "\\1" BUILD_SECOND "${BUILD_SECOND}") + +message(STATUS "Build date: ${BUILD_DAY}/${BUILD_MONTH}/${BUILD_YEAR}") +message(STATUS "Build time: ${BUILD_HOUR}:${BUILD_MINUTE}:${BUILD_SECOND}") add_definitions(-DBUILD_DATE_D=${BUILD_DAY} -DBUILD_DATE_M=${BUILD_MONTH} -DBUILD_DATE_Y=${BUILD_YEAR}) add_definitions(-DBUILD_DATE_HO=${BUILD_HOUR} -DBUILD_DATE_MI=${BUILD_MINUTE} -DBUILD_DATE_SE=${BUILD_SECOND})