Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

openssl: update to v3 as 1.1.1 is almost eol #668

Merged
merged 5 commits into from
Apr 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion cmake/configs/default.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ hunter_default_version(OpenCV-Extra VERSION 4.5.3)
hunter_default_version(OpenEXR VERSION 3.1.5-p0)
hunter_default_version(OpenGL-Registry VERSION 0.0.0-d15191e-p0)
hunter_default_version(OpenNMTTokenizer VERSION 1.11.0-p1)
hunter_default_version(OpenSSL VERSION 1.1.1t)
hunter_default_version(OpenSSL VERSION 3.0.8)
hunter_default_version(OpenSceneGraph VERSION 3.6.3-p0)
hunter_default_version(Opus VERSION 1.3.1)
hunter_default_version(PNG VERSION 1.6.26-p6)
Expand Down
84 changes: 50 additions & 34 deletions cmake/find/FindOpenSSL.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -305,42 +305,58 @@ if(OPENSSL_INCLUDE_DIR AND EXISTS "${OPENSSL_INCLUDE_DIR}/openssl/opensslv.h")
REGEX "^#[\t ]*define[\t ]+OPENSSL_VERSION_NUMBER[\t ]+0x([0-9a-fA-F])+.*")

string(COMPARE EQUAL "${openssl_version_str}" "" _is_empty)
if(_is_empty)
message(
NeroBurner marked this conversation as resolved.
Show resolved Hide resolved
FATAL_ERROR
"Incorrect OPENSSL_VERSION_NUMBER define in header"
": ${OPENSSL_INCLUDE_DIR}/openssl/opensslv.h"
)
if(NOT _is_empty)
# Version parsing pre 3.x i.e 1.1.1 etc.
# The version number is encoded as 0xMNNFFPPS: major minor fix patch status
# The status gives if this is a developer or prerelease and is ignored here.
# Major, minor, and fix directly translate into the version numbers shown in
# the string. The patch field translates to the single character suffix that
# indicates the bug fix state, which 00 -> nothing, 01 -> a, 02 -> b and so
# on.

string(REGEX REPLACE "^.*OPENSSL_VERSION_NUMBER[\t ]+0x([0-9a-fA-F])([0-9a-fA-F][0-9a-fA-F])([0-9a-fA-F][0-9a-fA-F])([0-9a-fA-F][0-9a-fA-F])([0-9a-fA-F]).*$"
"\\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)

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 "${_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.
string(ASCII "${OPENSSL_VERSION_PATCH_ASCII}" OPENSSL_VERSION_PATCH_STRING)
endif ()

set(OPENSSL_VERSION "${OPENSSL_VERSION_MAJOR}.${OPENSSL_VERSION_MINOR}.${OPENSSL_VERSION_FIX}${OPENSSL_VERSION_PATCH_STRING}")
else()
# Version parsing post 3.x
file(STRINGS "${OPENSSL_INCLUDE_DIR}/openssl/opensslv.h" OPENSSL_VERSION_MAJOR
REGEX "^#[\t ]*define[\t ]+OPENSSL_VERSION_MAJOR[\t ]+([0-9a-fA-F])+.*")
string(COMPARE EQUAL "${OPENSSL_VERSION_MAJOR}" "" _major_is_empty)
file(STRINGS "${OPENSSL_INCLUDE_DIR}/openssl/opensslv.h" OPENSSL_VERSION_MINOR
REGEX "^#[\t ]*define[\t ]+OPENSSL_VERSION_MINOR[\t ]+([0-9a-fA-F])+.*")
string(COMPARE EQUAL "${OPENSSL_VERSION_MINOR}" "" _minor_is_empty)
file(STRINGS "${OPENSSL_INCLUDE_DIR}/openssl/opensslv.h" OPENSSL_VERSION_PATCH
REGEX "^#[\t ]*define[\t ]+OPENSSL_VERSION_PATCH[\t ]+([0-9a-fA-F])+.*")
string(COMPARE EQUAL "${OPENSSL_VERSION_PATCH}" "" _patch_is_empty)

if(_major_is_empty OR _minor_is_empty OR _patch_is_empty)
message(
FATAL_ERROR
"Incorrect OPENSSL_VERSION_NUMBER define in header"
": ${OPENSSL_INCLUDE_DIR}/openssl/opensslv.h"
)
endif()
set(OPENSSL_VERSION "${OPENSSL_VERSION_MAJOR}.${OPENSSL_VERSION_MINOR}.${OPENSSL_VERSION_PATCH}")
endif()

# The version number is encoded as 0xMNNFFPPS: major minor fix patch status
# The status gives if this is a developer or prerelease and is ignored here.
# Major, minor, and fix directly translate into the version numbers shown in
# the string. The patch field translates to the single character suffix that
# indicates the bug fix state, which 00 -> nothing, 01 -> a, 02 -> b and so
# on.

string(REGEX REPLACE "^.*OPENSSL_VERSION_NUMBER[\t ]+0x([0-9a-fA-F])([0-9a-fA-F][0-9a-fA-F])([0-9a-fA-F][0-9a-fA-F])([0-9a-fA-F][0-9a-fA-F])([0-9a-fA-F]).*$"
"\\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)

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 "${_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.
string(ASCII "${OPENSSL_VERSION_PATCH_ASCII}" OPENSSL_VERSION_PATCH_STRING)
endif ()

set(OPENSSL_VERSION "${OPENSSL_VERSION_MAJOR}.${OPENSSL_VERSION_MINOR}.${OPENSSL_VERSION_FIX}${OPENSSL_VERSION_PATCH_STRING}")
endif ()

include(FindPackageHandleStandardArgs)
Expand Down
2 changes: 1 addition & 1 deletion cmake/projects/OpenSSL/ep-stages/configure.cmake.in
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ if("@openssl_install_dir@" STREQUAL "")
endif()

execute_process(COMMAND
perl Configure @arch@ @opt@ "--prefix=@openssl_install_dir@" RESULT_VARIABLE result)
perl Configure @arch@ @opt@ "--prefix=@openssl_install_dir@" "--libdir=lib" RESULT_VARIABLE result)
NeroBurner marked this conversation as resolved.
Show resolved Hide resolved

if(NOT result EQUAL 0)
message(FATAL_ERROR "OpenSSL configure failed: ${result}")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ if("@openssl_dir@" STREQUAL "")
endif()

execute_process(COMMAND
perl Configure @arch@ @opt@ @shared@ "--prefix=@openssl_install_dir@" "--openssldir=@openssl_dir@" RESULT_VARIABLE result)
perl Configure @arch@ @opt@ @shared@ "--prefix=@openssl_install_dir@" "--libdir=lib" "--openssldir=@openssl_dir@" RESULT_VARIABLE result)

if(NOT result EQUAL 0)
message(FATAL_ERROR "OpenSSL configure failed: ${result}")
Expand Down
22 changes: 22 additions & 0 deletions cmake/projects/OpenSSL/hunter.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -649,6 +649,28 @@ hunter_add_version(
072cf2bc8e19c7c59a42e7e20977fe3037c9c9f3
)

hunter_add_version(
PACKAGE_NAME
OpenSSL
VERSION
"3.1.0"
URL
"https://github.com/openssl/openssl/archive/openssl-3.1.0.tar.gz"
SHA1
1adb0f773af645b9f54738301920e5c74360b76d
)

hunter_add_version(
PACKAGE_NAME
OpenSSL
VERSION
"3.0.8"
URL
"https://github.com/openssl/openssl/archive/openssl-3.0.8.tar.gz"
SHA1
49816d51f0c4e306f72a6928780d3fb2815d05ac
)

if(MINGW)
hunter_pick_scheme(DEFAULT url_sha1_openssl)
elseif(WIN32)
Expand Down
1 change: 1 addition & 0 deletions cmake/projects/OpenSSL/schemes/url_sha1_openssl.cmake.in
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,7 @@ ExternalProject_Add(
${configure_command}
${configure_opts}
"--prefix=@HUNTER_PACKAGE_INSTALL_PREFIX@"
"--libdir=lib"
NeroBurner marked this conversation as resolved.
Show resolved Hide resolved
BUILD_COMMAND
${build_command}
BUILD_IN_SOURCE
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,7 @@ foreach(variant @IPHONEOS_ARCHS@ @IPHONESIMULATOR_ARCHS@)
"${configure_opts}"
"no-async"
"--prefix=@HUNTER_PACKAGE_INSTALL_PREFIX@"
"--libdir=lib"
"-arch ${variant}"
"-isysroot ${SDK_ROOT}"
BUILD_COMMAND
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,7 @@ foreach(arch ${configure_architectures})
"${configure_arch}"
"${configure_opts}"
"--prefix=@HUNTER_PACKAGE_INSTALL_PREFIX@"
"--libdir=lib"
BUILD_COMMAND
"${build_command}"
BUILD_IN_SOURCE
Expand Down