]> git.ipfire.org Git - thirdparty/openssl.git/commitdiff
fix: exporters/cmake/OpenSSLConfig.cmake.in to work for build config
authorRichard Levitte <levitte@openssl.org>
Wed, 17 Jul 2024 09:09:11 +0000 (11:09 +0200)
committerTomas Mraz <tomas@openssl.org>
Tue, 27 Aug 2024 15:20:12 +0000 (17:20 +0200)
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)

exporters/cmake/OpenSSLConfig.cmake.in

index b35a58152dbf4cfd2376224daf8bee2567304472..dc9927a7627229cb00b2074417921eeeb124f8ed 100644 (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 "")