summaryrefslogtreecommitdiffstats
path: root/Modules/FindOpenSSL.cmake
diff options
context:
space:
mode:
authorRolf Eike Beer <eike@sf-mail.de>2012-01-27 16:35:12 (GMT)
committerRolf Eike Beer <eike@sf-mail.de>2012-01-27 16:51:29 (GMT)
commit0bee3d95397497cb85a689d8f463b63858d50ebd (patch)
tree1580d709e3324130d490f5e51f0d1ebe991e72d4 /Modules/FindOpenSSL.cmake
parent2184cc6469c9c2803ef73c4e677e0658cf42e8cd (diff)
downloadCMake-0bee3d95397497cb85a689d8f463b63858d50ebd.zip
CMake-0bee3d95397497cb85a689d8f463b63858d50ebd.tar.gz
CMake-0bee3d95397497cb85a689d8f463b63858d50ebd.tar.bz2
FindOpenSSL: properly parse the hex version components
Diffstat (limited to 'Modules/FindOpenSSL.cmake')
-rw-r--r--Modules/FindOpenSSL.cmake40
1 files changed, 36 insertions, 4 deletions
diff --git a/Modules/FindOpenSSL.cmake b/Modules/FindOpenSSL.cmake
index 59efe4b..d1fc2d2 100644
--- a/Modules/FindOpenSSL.cmake
+++ b/Modules/FindOpenSSL.cmake
@@ -213,6 +213,37 @@ ELSE(WIN32 AND NOT CYGWIN)
ENDIF(WIN32 AND NOT CYGWIN)
+function(from_hex HEX DEC)
+ string(TOUPPER "${HEX}" HEX)
+ set(_res 0)
+ string(LENGTH "${HEX}" _strlen)
+
+ while (_strlen GREATER 0)
+ math(EXPR _res "${_res} * 16")
+ string(SUBSTRING "${HEX}" 0 1 NIBBLE)
+ string(SUBSTRING "${HEX}" 1 -1 HEX)
+ if (NIBBLE STREQUAL "A")
+ math(EXPR _res "${_res} + 10")
+ elseif (NIBBLE STREQUAL "B")
+ math(EXPR _res "${_res} + 11")
+ elseif (NIBBLE STREQUAL "C")
+ math(EXPR _res "${_res} + 12")
+ elseif (NIBBLE STREQUAL "D")
+ math(EXPR _res "${_res} + 13")
+ elseif (NIBBLE STREQUAL "E")
+ math(EXPR _res "${_res} + 14")
+ elseif (NIBBLE STREQUAL "F")
+ math(EXPR _res "${_res} + 15")
+ else()
+ math(EXPR _res "${_res} + ${NIBBLE}")
+ endif()
+
+ string(LENGTH "${HEX}" _strlen)
+ endwhile()
+
+ set(${DEC} ${_res} PARENT_SCOPE)
+endfunction(from_hex)
+
if (OPENSSL_INCLUDE_DIR)
if (_OPENSSL_VERSION)
set(OPENSSL_VERSION "${_OPENSSL_VERSION}")
@@ -231,15 +262,16 @@ if (OPENSSL_INCLUDE_DIR)
"\\1;\\2;\\3;\\4;\\5" OPENSSL_VERSION_LIST "${openssl_version_str}")
list(GET OPENSSL_VERSION_LIST 0 OPENSSL_VERSION_MAJOR)
list(GET OPENSSL_VERSION_LIST 1 OPENSSL_VERSION_MINOR)
+ from_hex("${OPENSSL_VERSION_MINOR}" OPENSSL_VERSION_MINOR)
list(GET OPENSSL_VERSION_LIST 2 OPENSSL_VERSION_FIX)
+ from_hex("${OPENSSL_VERSION_FIX}" OPENSSL_VERSION_FIX)
list(GET OPENSSL_VERSION_LIST 3 OPENSSL_VERSION_PATCH)
- string(REGEX REPLACE "^0(.)" "\\1" OPENSSL_VERSION_MINOR "${OPENSSL_VERSION_MINOR}")
- string(REGEX REPLACE "^0(.)" "\\1" OPENSSL_VERSION_FIX "${OPENSSL_VERSION_FIX}")
-
if (NOT OPENSSL_VERSION_PATCH STREQUAL "00")
+ from_hex("${OPENSSL_VERSION_PATCH}" _tmp)
# 96 is the ASCII code of 'a' minus 1
- math(EXPR OPENSSL_VERSION_PATCH_ASCII "${OPENSSL_VERSION_PATCH} + 96")
+ math(EXPR OPENSSL_VERSION_PATCH_ASCII "${_tmp} + 96")
+ unset(_tmp)
# Once anyone knows how OpenSSL would call the patch versions beyond 'z'
# this should be updated to handle that, too. This has not happened yet
# so it is simply ignored here for now.