Skip to content

FindOpenSSL: cannot parse and generate OPENSSL_VERSION with openssl-3.1.2 release

Dear CMake Maintainers, The "OPENSSL_VERSION_NUMBER" definition [1] [2] in openssl-3.1.2 has changed, so the code logic [3] in FindOpenSSL.cmake does not parse and generate the OPENSSL_VERSION. Could you please help resolve the issue?

[1] openssl/opensslv.h in openssl-1.1.1

42 # define OPENSSL_VERSION_NUMBER  0x1010106fL
43 # define OPENSSL_VERSION_TEXT    "OpenSSL 1.1.1f  31 Mar 2020"

[2] openssl/opensslv.h in openssl-3.1.2

# define OPENSSL_VERSION_NUMBER          \
    ( (OPENSSL_VERSION_MAJOR<<28)        \
      |(OPENSSL_VERSION_MINOR<<20)       \
      |(OPENSSL_VERSION_PATCH<<4)        \
      |_OPENSSL_VERSION_PRE_RELEASE )

[3] /usr/share/cmake-3.16/Modules/FindOpenSSL.cmake

if(OPENSSL_INCLUDE_DIR AND EXISTS "${OPENSSL_INCLUDE_DIR}/openssl/opensslv.h")
  file(STRINGS "${OPENSSL_INCLUDE_DIR}/openssl/opensslv.h" openssl_version_str
       REGEX "^#[\t ]*define[\t ]+OPENSSL_VERSION_NUMBER[\t ]+0x([0-9a-fA-F])+.*")

Thanks.

Edited by Brad King
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information