diff options
author | Richard Levitte <levitte@openssl.org> | 2023-05-03 12:36:09 +0200 |
---|---|---|
committer | Richard Levitte <levitte@openssl.org> | 2023-11-15 08:22:29 +0100 |
commit | c768ccebc718ea0ed6afc5147fe4079fff632cd6 (patch) | |
tree | f9ad63ab2a131144ad0740429fda4ab8a58b024c /util | |
parent | 2ac569a67b9d0980efa2d8061a6a61e0645f37a7 (diff) |
Add exporters for CMake
CMake's older package finder, FindOpenSSL.cmake, does a best guess effort
and doesn't always get it right.
By CMake's own documentation, that's what such modules are (best effort
attempts), and package producers are (strongly) encouraged to help out by
producing and installing <PackageName>Config.cmake files to get a more
deterministic configuration.
The resulting OpenSSLConfig.cmake tries to mimic the result from CMake's
FindOpenSSL.cmake, by using the same variable and imported target names.
It also adds a few extra variables of its own, such as:
OPENSSL_MODULES_DIR Indicates the default installation directory
for OpenSSL loadable modules, such as providers.
OPENSSL_RUNTIME_DIR Indicates the default runtime directory, where
for example the openssl program is located.
OPENSSL_PROGRAM Is the full directory-and-filename of the
openssl program.
The imported targets OpenSSL::Crypto and OpenSSL::SSL are as precisely
specified as possible, so for example, they are specified with the both the
import library and the DLL on Windows, which should make life easier on that
platform.
For the moment, one of the following must be done in your CMake project for
this CMake configuration to take priority over CMake's FindOpenSSL.cmake:
- The variable CMAKE_FIND_PACKAGE_PREFER_CONFIG must be set to true prior
to the 'find_package(OpenSSL)' call.
- The 'find_package' call itself must use the "Full Signature". If you
don't know any better, simply add the 'CONFIG' option, i.e. from this
example:
find_package(OpenSSL 3.0 REQUIRED)
to this:
find_package(OpenSSL 3.0 REQUIRED CONFIG)
Just as with the 'pkg-config' exporters, two variants of the .cmake files
are produced:
- Those in 'exporters/' are installed in the location that 'pkg-config'
itself prefers for installed packages.
- Those in the top directory are to be used when it's desirable to build
directly against an OpenSSL build tree.
Reviewed-by: Paul Dale <pauli@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/20878)
Diffstat (limited to 'util')
-rw-r--r-- | util/mkinstallvars.pl | 64 |
1 files changed, 48 insertions, 16 deletions
diff --git a/util/mkinstallvars.pl b/util/mkinstallvars.pl index d0688cfd0b..59a432d28c 100644 --- a/util/mkinstallvars.pl +++ b/util/mkinstallvars.pl @@ -16,7 +16,8 @@ use File::Spec; my @absolutes = qw(PREFIX); # These may be absolute directories, and if not, they are expected to be set up # as subdirectories to PREFIX -my @subdirs = qw(BINDIR LIBDIR INCLUDEDIR ENGINESDIR MODULESDIR APPLINKDIR); +my @subdirs = qw(BINDIR LIBDIR INCLUDEDIR APPLINKDIR ENGINESDIR MODULESDIR + PKGCONFIGDIR CMAKECONFIGDIR); my %keys = (); foreach (@ARGV) { @@ -24,6 +25,7 @@ foreach (@ARGV) { $keys{$k} = 1; $ENV{$k} = $v; } + foreach my $k (sort keys %keys) { my $v = $ENV{$k}; $v = File::Spec->rel2abs($v) if $v && grep { $k eq $_ } @absolutes; @@ -31,9 +33,21 @@ foreach my $k (sort keys %keys) { } foreach my $k (sort keys %keys) { my $v = $ENV{$k} || '.'; - $v = File::Spec->rel2abs($v, $ENV{PREFIX}) - if ($v && !File::Spec->file_name_is_absolute($v) - && grep { $k eq $_ } @subdirs); + + # Absolute paths for the subdir variables are computed. This provides + # the usual form of values for names that have become norm, known as GNU + # installation paths. + # For the benefit of those that need it, the subdirectories are preserved + # as they are, using the same variable names, suffixed with '_REL', if they + # are indeed subdirectories. + if (grep { $k eq $_ } @subdirs) { + if (File::Spec->file_name_is_absolute($v)) { + $ENV{"${k}_REL"} = File::Spec->abs2rel($v, $ENV{PREFIX}); + } else { + $ENV{"${k}_REL"} = $v; + $v = File::Spec->rel2abs($v, $ENV{PREFIX}); + } + } $ENV{$k} = $v; } @@ -44,18 +58,36 @@ use strict; use warnings; use Exporter; our \@ISA = qw(Exporter); -our \@EXPORT = qw(\$PREFIX \$BINDIR \$LIBDIR \$INCLUDEDIR \$APPLINKDIR - \$ENGINESDIR \$MODULESDIR \$VERSION \$LDLIBS); - -our \$PREFIX = '$ENV{PREFIX}'; -our \$BINDIR = '$ENV{BINDIR}'; -our \$LIBDIR = '$ENV{LIBDIR}'; -our \$INCLUDEDIR = '$ENV{INCLUDEDIR}'; -our \$ENGINESDIR = '$ENV{ENGINESDIR}'; -our \$MODULESDIR = '$ENV{MODULESDIR}'; -our \$APPLINKDIR = '$ENV{APPLINKDIR}'; -our \$VERSION = '$ENV{VERSION}'; -our \@LDLIBS = +our \@EXPORT = qw(\$PREFIX + \$BINDIR \$BINDIR_REL + \$LIBDIR \$LIBDIR_REL + \$INCLUDEDIR \$INCLUDEDIR_REL + \$APPLINKDIR \$APPLINKDIR_REL + \$ENGINESDIR \$ENGINESDIR_REL + \$MODULESDIR \$MODULESDIR_REL + \$PKGCONFIGDIR \$PKGCONFIGDIR_REL + \$CMAKECONFIGDIR \$CMAKECONFIGDIR_REL + \$VERSION \@LDLIBS); + +our \$PREFIX = '$ENV{PREFIX}'; +our \$BINDIR = '$ENV{BINDIR}'; +our \$BINDIR_REL = '$ENV{BINDIR_REL}'; +our \$LIBDIR = '$ENV{LIBDIR}'; +our \$LIBDIR_REL = '$ENV{LIBDIR_REL}'; +our \$INCLUDEDIR = '$ENV{INCLUDEDIR}'; +our \$INCLUDEDIR_REL = '$ENV{INCLUDEDIR_REL}'; +our \$APPLINKDIR = '$ENV{APPLINKDIR}'; +our \$APPLINKDIR_REL = '$ENV{APPLINKDIR_REL}'; +our \$ENGINESDIR = '$ENV{ENGINESDIR}'; +our \$ENGINESDIR_REL = '$ENV{ENGINESDIR_REL}'; +our \$MODULESDIR = '$ENV{MODULESDIR}'; +our \$MODULESDIR_REL = '$ENV{MODULESDIR_REL}'; +our \$PKGCONFIGDIR = '$ENV{PKGCONFIGDIR}'; +our \$PKGCONFIGDIR_REL = '$ENV{PKGCONFIGDIR_REL}'; +our \$CMAKECONFIGDIR = '$ENV{CMAKECONFIGDIR}'; +our \$CMAKECONFIGDIR_REL = '$ENV{CMAKECONFIGDIR_REL}'; +our \$VERSION = '$ENV{VERSION}'; +our \@LDLIBS = # Unix and Windows use space separation, VMS uses comma separation split(/ +| *, */, '$ENV{LDLIBS}'); |