diff options
author | Trulsrock <87703144+Trulsrock@users.noreply.github.com> | 2021-07-21 19:00:49 +0100 |
---|---|---|
committer | Shauren <shauren.trinity@gmail.com> | 2022-03-11 19:08:48 +0100 |
commit | 65521a40d274ce73769371b00d71c4b83e5ec319 (patch) | |
tree | 2e4fc0d8cf0694c9ed57278cc39f1aba0a4d7a1d | |
parent | 6cc8bebdd6973920e80d98ff19ac8ec50f70e76c (diff) |
Added from_hex for OpenSSL version parsing (#26730)
(cherry picked from commit 657970fb69ddb70b0650bc726a0065b38f6dbd29)
-rw-r--r-- | cmake/macros/FindOpenSSL.cmake | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/cmake/macros/FindOpenSSL.cmake b/cmake/macros/FindOpenSSL.cmake index 1214e13f48f..3a07ccaccc3 100644 --- a/cmake/macros/FindOpenSSL.cmake +++ b/cmake/macros/FindOpenSSL.cmake @@ -439,6 +439,36 @@ else() mark_as_advanced(OPENSSL_CRYPTO_LIBRARY OPENSSL_SSL_LIBRARY) endif() +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) set(OPENSSL_SSL_LIBRARIES ${OPENSSL_SSL_LIBRARY}) set(OPENSSL_CRYPTO_LIBRARIES ${OPENSSL_CRYPTO_LIBRARY}) |