summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVitezslav Cizek <vcizek@suse.com>2020-05-27 14:52:17 +0200
committerBrad King <brad.king@kitware.com>2020-05-27 09:08:10 -0400
commit61d746e5922de50310558364f157b261f3e7917a (patch)
tree760bcf828ad02a710b346e79f1223b63b85eac36
parent615129f3ebd308abeaaee7f5f0689e7fc4616c28 (diff)
downloadcmake-61d746e5922de50310558364f157b261f3e7917a.tar.gz
FindOpenSSL: Detect OpenSSL 3.0.0
The OpenSSL versioning is changing with the upcoming 3.0.0 release. https://www.openssl.org/blog/blog/2018/11/28/version/ Since 3.0.0, the patch letters are being dropped. The new format is: MAJOR.MINOR.PATCH The OPENSSL_VERSION variable can now be directly derived from the new OPENSSL_VERSION_STR macro. https://www.openssl.org/docs/manmaster/man3/OPENSSL_VERSION_NUMBER.html
-rw-r--r--Modules/FindOpenSSL.cmake9
1 files changed, 9 insertions, 0 deletions
diff --git a/Modules/FindOpenSSL.cmake b/Modules/FindOpenSSL.cmake
index af713d6a84..45b641ddef 100644
--- a/Modules/FindOpenSSL.cmake
+++ b/Modules/FindOpenSSL.cmake
@@ -415,6 +415,15 @@ 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}")
+ else ()
+ # Since OpenSSL 3.0.0, the new version format is MAJOR.MINOR.PATCH and
+ # a new OPENSSL_VERSION_STR macro contains exactly that
+ file(STRINGS "${OPENSSL_INCLUDE_DIR}/openssl/opensslv.h" OPENSSL_VERSION_STR
+ REGEX "^#[\t ]*define[\t ]+OPENSSL_VERSION_STR[\t ]+\"([0-9])+\.([0-9])+\.([0-9])+\".*")
+ string(REGEX REPLACE "^.*OPENSSL_VERSION_STR[\t ]+\"([0-9]+\.[0-9]+\.[0-9]+)\".*$"
+ "\\1" OPENSSL_VERSION_STR "${OPENSSL_VERSION_STR}")
+
+ set(OPENSSL_VERSION "${OPENSSL_VERSION_STR}")
endif ()
endif ()