From: Richard Levitte Date: Wed, 17 Jul 2024 09:09:11 +0000 (+0200) Subject: fix: exporters/cmake/OpenSSLConfig.cmake.in to work for build config X-Git-Tag: openssl-3.3.2~13 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=27b00ac152a1d6940b9838f81b6daefdfcd84dbe;p=thirdparty%2Fopenssl.git fix: exporters/cmake/OpenSSLConfig.cmake.in to work for build config This template file is made to make both: 1. OpenSSLConfig.cmake (CMake config used when building a CMake package against an uninstalled OpenSSL build) 2. exporters/OpenSSLConfig.cmake (CMake config that's to be installed alongside OpenSSL, and is used when building a CMake package against an OpenSSL installation). Variant 1 was unfortunately getting the internal '_ossl_prefix' variable wrong, which is due to how the perl snippet builds the command(s) to figure out its value. That needed some correction. Reviewed-by: Neil Horman Reviewed-by: Tomas Mraz (Merged from https://github.com/openssl/openssl/pull/24918) (cherry picked from commit a82d9e572cc757e4fa50d484bfbb7115f2d027dd) --- diff --git a/exporters/cmake/OpenSSLConfig.cmake.in b/exporters/cmake/OpenSSLConfig.cmake.in index b35a58152db..dc9927a7627 100644 --- a/exporters/cmake/OpenSSLConfig.cmake.in +++ b/exporters/cmake/OpenSSLConfig.cmake.in @@ -91,11 +91,13 @@ get_filename_component(_ossl_prefix "${CMAKE_CURRENT_LIST_FILE}" PATH) {- # For each component in $OpenSSL::safe::installdata::CMAKECONFIGDIR relative to # $OpenSSL::safe::installdata::PREFIX, have CMake figure out the parent directory. - my $d = join('/', unixify($OpenSSL::safe::installdata::LIBDIR_REL_PREFIX), - unixify($OpenSSL::safe::installdata::CMAKECONFIGDIR_REL_LIBDIR)); + my $d = join('/', unixify(catdir($OpenSSL::safe::installdata::LIBDIR_REL_PREFIX, + $OpenSSL::safe::installdata::CMAKECONFIGDIR_REL_LIBDIR), 1)); $OUT = ''; - $OUT .= 'get_filename_component(_ossl_prefix "${_ossl_prefix}" PATH)' . "\n" - foreach (split '/', $d); + if ($d ne '.') { + $OUT .= 'get_filename_component(_ossl_prefix "${_ossl_prefix}" PATH)' . "\n" + foreach (split '/', $d); + } -} if(_ossl_prefix STREQUAL "/") set(_ossl_prefix "")