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 /Configurations | |
parent | Clean up exporters, specifically those we have for pkg-config (diff) | |
download | openssl-c768ccebc718ea0ed6afc5147fe4079fff632cd6.tar.xz openssl-c768ccebc718ea0ed6afc5147fe4079fff632cd6.zip |
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 'Configurations')
-rw-r--r-- | Configurations/unix-Makefile.tmpl | 19 | ||||
-rw-r--r-- | Configurations/windows-makefile.tmpl | 9 |
2 files changed, 28 insertions, 0 deletions
diff --git a/Configurations/unix-Makefile.tmpl b/Configurations/unix-Makefile.tmpl index 18c32d0bae..536a316a13 100644 --- a/Configurations/unix-Makefile.tmpl +++ b/Configurations/unix-Makefile.tmpl @@ -205,6 +205,12 @@ INSTALL_EXPORTERS_PKGCONFIG={- grep { $unified_info{attributes}->{generate}->{$_}->{exporter} eq 'pkg-config'} sort keys %{$unified_info{generate}})) -} +INSTALL_EXPORTERS_CMAKE={- + join(" \\\n" . ' ' x 24, + fill_lines(" ", $COLUMNS - 24, + grep { $unified_info{attributes}->{generate}->{$_}->{exporter} eq 'cmake'} + sort keys %{$unified_info{generate}})) +-} BIN_SCRIPTS={- join(" \\\n" . ' ' x 12, fill_lines(" ", $COLUMNS - 12, @@ -327,6 +333,7 @@ bindir={- file_name_is_absolute($bindir) ? $bindir : '$(INSTALLTOP)/$(BINDIR)' -} PKGCONFIGDIR=$(libdir)/pkgconfig +CMAKECONFIGDIR=$(libdir)/cmake/OpenSSL MANDIR=$(INSTALLTOP)/share/man DOCDIR=$(INSTALLTOP)/share/doc/$(BASENAME) @@ -790,6 +797,13 @@ install_dev: install_runtime_libs cp $$e "$(DESTDIR)$(PKGCONFIGDIR)/$$fn"; \ chmod 644 "$(DESTDIR)$(PKGCONFIGDIR)/$$fn"; \ done + @$(PERL) $(SRCDIR)/util/mkdir-p.pl $(DESTDIR)$(CMAKECONFIGDIR) + @for e in $(INSTALL_EXPORTERS_CMAKE); do \ + fn=`basename $$e`; \ + $(ECHO) "install $$e -> $(DESTDIR)$(CMAKECONFIGDIR)/$$fn"; \ + cp $$e $(DESTDIR)$(CMAKECONFIGDIR)/$$fn; \ + chmod 644 $(DESTDIR)$(CMAKECONFIGDIR)/$$fn; \ + done uninstall_dev: uninstall_runtime_libs @$(ECHO) "*** Uninstalling development files" @@ -837,7 +851,12 @@ uninstall_dev: uninstall_runtime_libs fn=`basename "$$e"`; \ $(RM) "$(DESTDIR)$(PKGCONFIGDIR)/$$fn"; \ done + @for e in $(INSTALL_EXPORTERS_CMAKE); do \ + fn=`basename "$$e"`; \ + $(RM) "$(DESTDIR)$(CMAKECONFIGDIR)/$$fn"; \ + done -$(RMDIR) "$(DESTDIR)$(PKGCONFIGDIR)" + -$(RMDIR) "$(DESTDIR)$(CMAKECONFIGDIR)" -$(RMDIR) "$(DESTDIR)$(libdir)" _install_modules_deps: install_runtime_libs build_modules diff --git a/Configurations/windows-makefile.tmpl b/Configurations/windows-makefile.tmpl index 7fd87e81cf..66550e1f82 100644 --- a/Configurations/windows-makefile.tmpl +++ b/Configurations/windows-makefile.tmpl @@ -155,6 +155,11 @@ MISC_SCRIPTS={- && $unified_info{attributes}->{scripts}->{$_}->{misc} } @{$unified_info{scripts}}) -} +INSTALL_EXPORTERS_CMAKE={- + join(" ", map { quotify1($_) } + grep { $unified_info{attributes}->{generate}->{$_}->{exporter} eq 'cmake'} + sort keys %{$unified_info{generate}}) +-} IMAGEDOCS1={- our @IMAGEDOCS1 = @{$unified_info{imagedocs}->{man1}}; join(" ", @IMAGEDOCS1) -} IMAGEDOCS3={- our @IMAGEDOCS3 = @{$unified_info{imagedocs}->{man3}}; @@ -249,6 +254,8 @@ MODULESDIR=$(MODULESDIR_dev)$(MODULESDIR_dir) libdir={- file_name_is_absolute($libdir) ? $libdir : '$(INSTALLTOP)\$(LIBDIR)' -} +CMAKECONFIGDIR=$(libdir)\cmake\OpenSSL + ##### User defined commands and flags ################################ CC="{- $config{CC} -}" @@ -557,6 +564,8 @@ install_dev: install_runtime_libs @"$(PERL)" "$(SRCDIR)\util\copy.pl" $(INSTALL_LIBS) "$(libdir)" @if "$(SHLIBS)"=="" \ "$(PERL)" "$(SRCDIR)\util\copy.pl" ossl_static.pdb "$(libdir)" + @"$(PERL)" "$(SRCDIR)\util\mkdir-p.pl" "$(CMAKECONFIGDIR)" + @"$(PERL)" "$(SRCDIR)\util\copy.pl" $(INSTALL_EXPORTERS_CMAKE) "$(CMAKECONFIGDIR)" uninstall_dev: |