cmake/fix-messy-code-for-openssl-1.1.1wa-version.patch
wk333 a724163170 Fix messy code for openssl-1.1.1wa version
(cherry picked from commit 09dedd8c9820bb369b2d722505659f379c6d2c70)
2024-04-28 16:01:23 +08:00

33 lines
1.5 KiB
Diff

diff --git a/Modules/FindOpenSSL.cmake b/Modules/FindOpenSSL.cmake
index 8474e05c..ac742855 100644
--- a/Modules/FindOpenSSL.cmake
+++ b/Modules/FindOpenSSL.cmake
@@ -520,7 +520,6 @@ if(OPENSSL_INCLUDE_DIR AND EXISTS "${OPENSSL_INCLUDE_DIR}/openssl/opensslv.h")
from_hex("${OPENSSL_VERSION_PATCH}" _tmp)
# 96 is the ASCII code of 'a' minus 1
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.
@@ -528,6 +527,16 @@ if(OPENSSL_INCLUDE_DIR AND EXISTS "${OPENSSL_INCLUDE_DIR}/openssl/opensslv.h")
endif ()
set(OPENSSL_VERSION "${OPENSSL_VERSION_MAJOR}.${OPENSSL_VERSION_MINOR}.${OPENSSL_VERSION_FIX}${OPENSSL_VERSION_PATCH_STRING}")
+
+ if ("${_tmp}" GREATER 26)
+ # openssl version 1.1.1wa get text directly
+ file(STRINGS "${OPENSSL_INCLUDE_DIR}/openssl/opensslv.h" openssl_version_text
+ REGEX "^#[\t ]*define[\t ]+OPENSSL_VERSION_TEXT[\t ]+\"OpenSSL[^\"]*\".*")
+ string(REGEX MATCH "[0-9]+\\.[0-9]+\\.[0-9]+[a-zA-Z]+" version_number ${openssl_version_text})
+ set(OPENSSL_VERSION "${version_number}")
+ endif ()
+ unset(_tmp)
+
else ()
# Since OpenSSL 3.0.0, the new version format is MAJOR.MINOR.PATCH and
# a new OPENSSL_VERSION_STR macro contains exactly that
--
2.33.0