From 4ca28fb6eb31ca8efb8f41ff764e9ef9177297f6 Mon Sep 17 00:00:00 2001 From: Michael Wallner Date: Mon, 21 Dec 2020 13:02:22 +0100 Subject: [PATCH] fix #96: LIB*_VERSION_HEX format --- CMakeVersions.txt | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/CMakeVersions.txt b/CMakeVersions.txt index dd2e7ed6..965c1106 100644 --- a/CMakeVersions.txt +++ b/CMakeVersions.txt @@ -1,15 +1,18 @@ function(to_hex HEX) + # mind you, not really hexadecimal, but just a decimal in hex notation, huh?! set(XNUMBER 0x) - set(XDIGITS 0 1 2 3 4 5 6 7 8 9 a b c d e f) foreach(DEC IN LISTS ARGN) - if(${DEC} GREATER 255) - message(WARNING "to_hex(HEX ${DEC}): decimal number out of uint8 range (>=256)") + while(1) + string(LENGTH "${DEC}" LEN) + if(LEN GREATER_EQUAL 3) + break() + endif() + string(CONCAT DEC "0" "${DEC}") + endwhile() + if(DEC GREATER 999) + message(WARNING "to_hex(HEX ${DEC}): decimal wider than 3 digits") endif() - math(EXPR HIDEC "${DEC} / 16") - math(EXPR LODEC "${DEC} % 16") - list(GET XDIGITS ${HIDEC} HIHEX) - list(GET XDIGITS ${LODEC} LOHEX) - string(APPEND XNUMBER ${HIHEX}${LOHEX}) + string(APPEND XNUMBER ${DEC}) endforeach() set(${HEX} ${XNUMBER} PARENT_SCOPE) endfunction() -- 2.30.2