From 62824edcddf6c668f6971b59252a8227bfca901c Mon Sep 17 00:00:00 2001 From: res0nance Date: Mon, 3 Apr 2023 21:41:11 +0800 Subject: [PATCH 1/5] openssl: update to v3 as 1.1.1 is almost eol --- cmake/configs/default.cmake | 2 +- cmake/projects/OpenSSL/hunter.cmake | 22 ++++++++++++++++++++++ 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/cmake/configs/default.cmake b/cmake/configs/default.cmake index db4566a0cd..3ef53f8d36 100644 --- a/cmake/configs/default.cmake +++ b/cmake/configs/default.cmake @@ -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) diff --git a/cmake/projects/OpenSSL/hunter.cmake b/cmake/projects/OpenSSL/hunter.cmake index 345d1f2fc1..d6d244912f 100755 --- a/cmake/projects/OpenSSL/hunter.cmake +++ b/cmake/projects/OpenSSL/hunter.cmake @@ -10,6 +10,28 @@ include(hunter_cmake_args) include(hunter_download) include(hunter_pick_scheme) +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 +) + hunter_add_version( PACKAGE_NAME OpenSSL From f7e2ef2d4a0653d232a0b300193ef6cac347d832 Mon Sep 17 00:00:00 2001 From: res0nance Date: Mon, 3 Apr 2023 22:23:40 +0800 Subject: [PATCH 2/5] openssl3: update version number logic --- cmake/find/FindOpenSSL.cmake | 82 +++++++++++++++++++++--------------- 1 file changed, 48 insertions(+), 34 deletions(-) diff --git a/cmake/find/FindOpenSSL.cmake b/cmake/find/FindOpenSSL.cmake index c9265523f5..eec6c6d5da 100644 --- a/cmake/find/FindOpenSSL.cmake +++ b/cmake/find/FindOpenSSL.cmake @@ -305,42 +305,56 @@ 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( - FATAL_ERROR - "Incorrect OPENSSL_VERSION_NUMBER define in header" - ": ${OPENSSL_INCLUDE_DIR}/openssl/opensslv.h" - ) + if(NOT _is_empty) + # 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() + 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) From 2c1243ff9fdf67fbddba82c66aff65b78ccc9ecd Mon Sep 17 00:00:00 2001 From: res0nance Date: Tue, 4 Apr 2023 20:20:14 +0800 Subject: [PATCH 3/5] openssl: set libdir to lib --- cmake/projects/OpenSSL/ep-stages/configure.cmake.in | 2 +- cmake/projects/OpenSSL/ep-stages/configure_1_1_plus.cmake.in | 2 +- cmake/projects/OpenSSL/schemes/url_sha1_openssl.cmake.in | 1 + cmake/projects/OpenSSL/schemes/url_sha1_openssl_ios.cmake.in | 1 + cmake/projects/OpenSSL/schemes/url_sha1_openssl_macos.cmake.in | 1 + 5 files changed, 5 insertions(+), 2 deletions(-) diff --git a/cmake/projects/OpenSSL/ep-stages/configure.cmake.in b/cmake/projects/OpenSSL/ep-stages/configure.cmake.in index da8558f471..e9f507413c 100644 --- a/cmake/projects/OpenSSL/ep-stages/configure.cmake.in +++ b/cmake/projects/OpenSSL/ep-stages/configure.cmake.in @@ -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) if(NOT result EQUAL 0) message(FATAL_ERROR "OpenSSL configure failed: ${result}") diff --git a/cmake/projects/OpenSSL/ep-stages/configure_1_1_plus.cmake.in b/cmake/projects/OpenSSL/ep-stages/configure_1_1_plus.cmake.in index d49e53327f..ca821690b4 100644 --- a/cmake/projects/OpenSSL/ep-stages/configure_1_1_plus.cmake.in +++ b/cmake/projects/OpenSSL/ep-stages/configure_1_1_plus.cmake.in @@ -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}") diff --git a/cmake/projects/OpenSSL/schemes/url_sha1_openssl.cmake.in b/cmake/projects/OpenSSL/schemes/url_sha1_openssl.cmake.in index e53c0fea76..04b7f37c84 100644 --- a/cmake/projects/OpenSSL/schemes/url_sha1_openssl.cmake.in +++ b/cmake/projects/OpenSSL/schemes/url_sha1_openssl.cmake.in @@ -160,6 +160,7 @@ ExternalProject_Add( ${configure_command} ${configure_opts} "--prefix=@HUNTER_PACKAGE_INSTALL_PREFIX@" + "--libdir=lib" BUILD_COMMAND ${build_command} BUILD_IN_SOURCE diff --git a/cmake/projects/OpenSSL/schemes/url_sha1_openssl_ios.cmake.in b/cmake/projects/OpenSSL/schemes/url_sha1_openssl_ios.cmake.in index 947ef659bf..c02a981a78 100644 --- a/cmake/projects/OpenSSL/schemes/url_sha1_openssl_ios.cmake.in +++ b/cmake/projects/OpenSSL/schemes/url_sha1_openssl_ios.cmake.in @@ -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 diff --git a/cmake/projects/OpenSSL/schemes/url_sha1_openssl_macos.cmake.in b/cmake/projects/OpenSSL/schemes/url_sha1_openssl_macos.cmake.in index 5795b22fe3..be3b320214 100644 --- a/cmake/projects/OpenSSL/schemes/url_sha1_openssl_macos.cmake.in +++ b/cmake/projects/OpenSSL/schemes/url_sha1_openssl_macos.cmake.in @@ -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 From d88268cb99602018119b1197fbadc71e76ebe8fa Mon Sep 17 00:00:00 2001 From: res0nance Date: Thu, 13 Apr 2023 21:00:58 +0800 Subject: [PATCH 4/5] openssl: move new versions to the bottom --- cmake/projects/OpenSSL/hunter.cmake | 44 ++++++++++++++--------------- 1 file changed, 22 insertions(+), 22 deletions(-) diff --git a/cmake/projects/OpenSSL/hunter.cmake b/cmake/projects/OpenSSL/hunter.cmake index d6d244912f..13db28cb33 100755 --- a/cmake/projects/OpenSSL/hunter.cmake +++ b/cmake/projects/OpenSSL/hunter.cmake @@ -10,28 +10,6 @@ include(hunter_cmake_args) include(hunter_download) include(hunter_pick_scheme) -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 -) - hunter_add_version( PACKAGE_NAME OpenSSL @@ -671,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) From 58d734044738d8bc49affeda0cdc42d3439091d0 Mon Sep 17 00:00:00 2001 From: res0nance Date: Thu, 13 Apr 2023 22:17:25 +0800 Subject: [PATCH 5/5] openssl: add comment about version parsing --- cmake/find/FindOpenSSL.cmake | 2 ++ 1 file changed, 2 insertions(+) diff --git a/cmake/find/FindOpenSSL.cmake b/cmake/find/FindOpenSSL.cmake index eec6c6d5da..11e8913219 100644 --- a/cmake/find/FindOpenSSL.cmake +++ b/cmake/find/FindOpenSSL.cmake @@ -306,6 +306,7 @@ if(OPENSSL_INCLUDE_DIR AND EXISTS "${OPENSSL_INCLUDE_DIR}/openssl/opensslv.h") string(COMPARE EQUAL "${openssl_version_str}" "" _is_empty) 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 @@ -335,6 +336,7 @@ if(OPENSSL_INCLUDE_DIR AND EXISTS "${OPENSSL_INCLUDE_DIR}/openssl/opensslv.h") 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)