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 <nhorman@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/24918)
This commit is contained in:
Richard Levitte 2024-07-17 11:09:11 +02:00 committed by Tomas Mraz
parent 0acb32052a
commit a82d9e572c

View File

@ -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 "")