diff options
-rw-r--r-- | .gitignore | 2 | ||||
-rw-r--r-- | Configurations/unix-Makefile.tmpl | 19 | ||||
-rw-r--r-- | Configurations/windows-makefile.tmpl | 9 | ||||
-rw-r--r-- | build.info | 8 | ||||
-rw-r--r-- | exporters/build.info | 12 | ||||
-rw-r--r-- | exporters/cmake/OpenSSLConfig.cmake.in | 237 | ||||
-rw-r--r-- | exporters/cmake/OpenSSLConfigVersion.cmake.in | 17 | ||||
-rw-r--r-- | util/mkinstallvars.pl | 64 |
8 files changed, 351 insertions, 17 deletions
diff --git a/.gitignore b/.gitignore index 97551e937b..98184721f2 100644 --- a/.gitignore +++ b/.gitignore @@ -17,7 +17,9 @@ # Exporters /*.pc +/OpenSSLConfig*.cmake /exporters/*.pc +/exporters/OpenSSLConfig*.cmake # Links under apps /apps/CA.pl 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: diff --git a/build.info b/build.info index 7149c8cd3a..790f2421e5 100644 --- a/build.info +++ b/build.info @@ -101,6 +101,14 @@ IF[{- $config{target} =~ /^(?:Cygwin|mingw|VC-|BC-)/ -}] SHARED_SOURCE[libssl]=libssl.rc ENDIF +# This file sets the build directory up for CMake inclusion +GENERATE[OpenSSLConfig.cmake]=exporters/cmake/OpenSSLConfig.cmake.in +DEPEND[OpenSSLConfig.cmake]=builddata.pm +GENERATE[OpenSSLConfigVersion.cmake]=exporters/cmake/OpenSSLConfigVersion.cmake.in +DEPEND[OpenSSLConfigVersion.cmake]=builddata.pm +DEPEND[OpenSSLConfigVersion.cmake]=OpenSSLConfig.cmake +DEPEND[""]=OpenSSLConfigVersion.cmake + # This file sets the build directory up for pkg-config GENERATE[libcrypto.pc]=exporters/pkg-config/libcrypto.pc.in DEPEND[libcrypto.pc]=builddata.pm diff --git a/exporters/build.info b/exporters/build.info index 503e15e8e8..86acf2df94 100644 --- a/exporters/build.info +++ b/exporters/build.info @@ -1,3 +1,12 @@ +# For installation: OpenSSLConfig.cmake, OpenSSLConfigVersion.cmake +GENERATE[OpenSSLConfig.cmake]{exporter=cmake}=cmake/OpenSSLConfig.cmake.in +DEPEND[OpenSSLConfig.cmake]=../installdata.pm +GENERATE[OpenSSLConfigVersion.cmake]{exporter=cmake}=cmake/OpenSSLConfigVersion.cmake.in +DEPEND[OpenSSLConfigVersion.cmake]=../installdata.pm +DEPEND[OpenSSLConfigVersion.cmake]=OpenSSLConfig.cmake + +DEPEND[""]=OpenSSLConfigVersion.cmake + # For installation: libcrypto.pc, libssl.pc, and openssl.pc GENERATE[libcrypto.pc]{exporter=pkg-config}=pkg-config/libcrypto.pc.in DEPEND[libcrypto.pc]=../installdata.pm @@ -13,4 +22,5 @@ GENERATE[../installdata.pm]=../util/mkinstallvars.pl \ "PREFIX=$(INSTALLTOP)" BINDIR=bin "LIBDIR=$(LIBDIR)" \ INCLUDEDIR=include APPLINKDIR=include/openssl \ "ENGINESDIR=$(ENGINESDIR)" "MODULESDIR=$(MODULESDIR)" \ - "VERSION=$(VERSION)" "LDLIBS=$(LIB_EX_LIBS)" + "PKGCONFIGDIR=$(PKGCONFIGDIR)" "CMAKECONFIGDIR=$(CMAKECONFIGDIR)" \ + "LDLIBS=$(LIB_EX_LIBS)" "VERSION=$(VERSION)" diff --git a/exporters/cmake/OpenSSLConfig.cmake.in b/exporters/cmake/OpenSSLConfig.cmake.in new file mode 100644 index 0000000000..606773ff27 --- /dev/null +++ b/exporters/cmake/OpenSSLConfig.cmake.in @@ -0,0 +1,237 @@ +# Generated by OpenSSL +{- + use lib catdir($config{sourcedir}, 'Configurations'); + use platform; + use Data::Dumper; + + our %lib_info = ( + map { my %x = (); + my $lib_static = platform->staticlib($_); + my $lib_shared = + (platform->can("sharedlib_simple") + ? platform->sharedlib_simple($_) + : undef) + // platform->sharedlib($_); + my $lib_shared_import = platform->sharedlib_import($_); + $x{static} = $lib_static if $lib_static; + $x{shared} = $lib_shared if $lib_shared; + $x{shared_import} = $lib_shared_import if $lib_shared_import; + %x ? ( $_ => \%x ) : () } + grep { !$unified_info{attributes}->{libraries}->{$_}->{noinst} } + @{$unified_info{libraries}} + ); + our $no_static = !$disabled{shared} && !$lib_info{libcrypto}->{static}; + our $no_shared = $disabled{shared}; + + # Unixifying of paths, because that's what CMake understands. + # This assumes that the given path is absolute. + sub unixify { + use File::Spec; + use File::Spec::Unix; + + my $path = shift; + my $no_file = shift; + (my $volume, $directories, $file) = File::Spec->splitpath($path, $no_file // ()); + $directories = File::Spec::Unix->catdir(File::Spec->splitdir($directories)); + + # We know that $volume is ignored by File::Spec::Unix, so we handle it specially + # according to the conventions of the platform. + $volume =~ s|^(.*?):$|/$1| if $^O eq "vms"; # On VMS, DEV: -> /DEV + + return $volume . File::Spec::Unix->catpath('', $directories, $no_file ? () : $file); + } + "" +-} +# Commands may need to know the format version. +set(CMAKE_IMPORT_FILE_VERSION 1) + +# Avoid duplicate find_package() +set(_ossl_expected_targets OpenSSL::Crypto OpenSSL::SSL + {- output_off() if $disabled{uplink}; "" -}OpenSSL::applink{- output_on() if $disabled{uplink}; "" -}) +set(_ossl_defined_targets) +set(_ossl_undefined_targets) +foreach(t IN LISTS _ossl_expected_targets) + if(TARGET "${t}") + LIST(APPEND _ossl_defined_targets "${t}") + else() + LIST(APPEND _ossl_undefined_targets "${t}") + endif() +endforeach() +message(DEBUG "_ossl_expected_targets = ${_ossl_expected_targets}") +message(DEBUG "_ossl_defined_targets = ${_ossl_defined_targets}") +message(DEBUG "_ossl_undefined_targets = ${_ossl_undefined_targets}") +if(NOT _ossl_undefined_targets) + # All targets are defined, we're good, just undo everything and return + unset(_ossl_expected_targets) + unset(_ossl_defined_targets) + unset(_ossl_undefined_targets) + unset(CMAKE_IMPORT_FILE_VERSION) + return() +endif() +if(_ossl_defined_targets) + # We have a mix of defined and undefined targets. This is hard to reconcile, + # and probably the result of another config, or FindOpenSSL.cmake having been + # called, or whatever. Therefore, the best course of action is to quit with a + # hard error. + message(FATAL_ERROR "Some targets defined, others not:\nNot defined: ${_ossl_undefined_targets}\nDefined: ${_ossl_defined_targets}") +endif() +unset(_ossl_expected_targets) +unset(_ossl_defined_targets) +unset(_ossl_undefined_targets) + +{- + # It can be argued that 'cmake_path' would be the better choice here. However, + # cmake_path is relatively new, while get_filename_component has been around + # since before CMake 3.0 +-} +# Set up the import path, so all other import paths are made relative this file +get_filename_component(_ossl_prefix "${CMAKE_CURRENT_LIST_FILE}" PATH) +{- + # For each component in $OpenSSL::safe::installdata::CMAKECONFIGDIR_REL, have CMake + # out the parent directory. + my $d = unixify($OpenSSL::safe::installdata::CMAKECONFIGDIR_REL); + $OUT = ''; + $OUT .= 'get_filename_component(_ossl_prefix "${_ossl_prefix}" PATH)' . "\n" + foreach (split '/', $d); +-} +if(_ossl_prefix STREQUAL "/") + set(_ossl_prefix "") +endif() + +{- output_off() unless $disabled{shared}; "" -} +set(_ossl_use_static_libs True) +{- output_on() unless $disabled{shared}; "" -} +if(OPENSSL_USE_STATIC_LIBS) + set(_ossl_use_static_libs True) +elseif(DEFINED OPENSSL_USE_STATIC_LIBS) + # We know OPENSSL_USE_STATIC_LIBS is defined and False + if(_ossl_use_static_libs) + # OPENSSL_USE_STATIC_LIBS is explicitly false, indicating that shared libraries are + # required. However, _ossl_use_static_libs indicates that no shared libraries are + # available. The best course of action is to simply return and leave it to CMake to + # use another OpenSSL config. + unset(_ossl_use_static_libs) + unset(CMAKE_IMPORT_FILE_VERSION) + return() + endif() +endif() + +# Version, copied from what find_package() gives, for compatibility with FindOpenSSL.cmake +set(OPENSSL_VERSION "${OpenSSL_VERSION}") +set(OPENSSL_VERSION_MAJOR "${OpenSSL_VERSION_MAJOR}") +set(OPENSSL_VERSION_MINOR "${OpenSSL_VERSION_MINOR}") +set(OPENSSL_VERSION_FIX "${OpenSSL_VERSION_PATCH}") +set(OPENSSL_FOUND YES) + +# Directories and names +set(OPENSSL_INCLUDE_DIR "${_ossl_prefix}/{- unixify($OpenSSL::safe::installdata::INCLUDEDIR_REL, 1); -}") +set(OPENSSL_LIBRARY_DIR "${_ossl_prefix}/{- unixify($OpenSSL::safe::installdata::LIBDIR_REL, 1); -}") +set(OPENSSL_ENGINES_DIR "${_ossl_prefix}/{- unixify($OpenSSL::safe::installdata::ENGINESDIR_REL, 1); -}") +set(OPENSSL_MODULES_DIR "${_ossl_prefix}/{- unixify($OpenSSL::safe::installdata::MODULESDIR_REL, 1); -}") +set(OPENSSL_RUNTIME_DIR "${_ossl_prefix}/{- unixify($OpenSSL::safe::installdata::BINDIR_REL, 1); -}") +{- output_off() if $disabled{uplink}; "" -} +set(OPENSSL_APPLINK_SOURCE "${_ossl_prefix}/{- unixify($OpenSSL::safe::installdata::APPLINKDIR_REL, 1); -}/applink.c") +{- output_on() if $disabled{uplink}; "" -} +set(OPENSSL_PROGRAM "${OPENSSL_RUNTIME_DIR}/{- platform->bin('openssl') -}") + +# Set up the imported targets +if(_ossl_use_static_libs) +{- output_off() unless $no_static; "" -} + # Static libraries are UNSUPPORTED in this configuration +{- output_on() unless $no_static; output_off() if $no_static; "" -} + add_library(OpenSSL::Crypto STATIC IMPORTED) + add_library(OpenSSL::SSL STATIC IMPORTED) + + set(OPENSSL_LIBCRYPTO_STATIC "${OPENSSL_LIBRARY_DIR}/{- $lib_info{libcrypto}->{static} -}") + set(OPENSSL_LIBCRYPTO_DEPENDENCIES {- join(' ', @OpenSSL::safe::installdata::LDLIBS) -}) + set_target_properties(OpenSSL::Crypto PROPERTIES + IMPORTED_LINK_INTERFACE_LANGUAGES "C" + IMPORTED_LOCATION ${OPENSSL_LIBCRYPTO_STATIC}) + set_property(TARGET OpenSSL::Crypto + PROPERTY INTERFACE_LINK_LIBRARIES ${OPENSSL_LIBCRYPTO_DEPENDENCIES}) + + set(OPENSSL_LIBSSL_STATIC "${OPENSSL_LIBRARY_DIR}/{- $lib_info{libssl}->{static} -}") + set(OPENSSL_LIBSSL_DEPENDENCIES OpenSSL::Crypto) + set_target_properties(OpenSSL::SSL PROPERTIES + IMPORTED_LINK_INTERFACE_LANGUAGES "C" + IMPORTED_LOCATION ${OPENSSL_LIBSSL_STATIC}) + set_property(TARGET OpenSSL::SSL + PROPERTY INTERFACE_LINK_LIBRARIES ${OPENSSL_LIBSSL_DEPENDENCIES}) + + # Directories and names compatible with CMake's FindOpenSSL.cmake + set(OPENSSL_CRYPTO_LIBRARY ${OPENSSL_LIBCRYPTO_STATIC}) + set(OPENSSL_CRYPTO_LIBRARIES ${OPENSSL_CRYPTO_LIBRARY} ${OPENSSL_LIBCRYPTO_DEPENDENCIES}) + set(OPENSSL_SSL_LIBRARY ${OPENSSL_LIBSSL_STATIC}) + set(OPENSSL_SSL_LIBRARIES ${OPENSSL_SSL_LIBRARY} ${OPENSSL_LIBSSL_DEPENDENCIES}) + set(OPENSSL_LIBRARIES ${OPENSSL_SSL_LIBRARY} ${OPENSSL_LIBSSL_DEPENDENCIES} ${OPENSSL_LIBCRYPTO_DEPENDENCIES}) +{- output_on(); "" -} +else() +{- output_off() unless $no_shared; "" -} + # Shared libraries are UNSUPPORTED in this configuration +{- output_on() unless $no_shared; + output_off() if $no_shared; "" -} + add_library(OpenSSL::Crypto SHARED IMPORTED) + add_library(OpenSSL::SSL SHARED IMPORTED) +{- output_off() unless $lib_info{libcrypto}->{shared_import}; "" -} + set(OPENSSL_LIBCRYPTO_SHARED "${OPENSSL_RUNTIME_DIR}/{- $lib_info{libcrypto}->{shared} -}") + set(OPENSSL_LIBCRYPTO_IMPORT "${OPENSSL_LIBRARY_DIR}/{- $lib_info{libcrypto}->{shared_import} -}") + set(OPENSSL_LIBCRYPTO_DEPENDENCIES {- join(' ', @LDLIBS) -}) + set_target_properties(OpenSSL::Crypto PROPERTIES + IMPORTED_LINK_INTERFACE_LANGUAGES "C" + IMPORTED_IMPLIB ${OPENSSL_LIBCRYPTO_IMPORT} + IMPORTED_LOCATION ${OPENSSL_LIBCRYPTO_SHARED}) + set_property(TARGET OpenSSL::Crypto + PROPERTY INTERFACE_LINK_LIBRARIES ${OPENSSL_LIBCRYPTO_DEPENDENCIES}) + + set(OPENSSL_LIBSSL_SHARED "${OPENSSL_RUNTIME_DIR}/{- $lib_info{libssl}->{shared} -}") + set(OPENSSL_LIBSSL_IMPORT "${OPENSSL_LIBRARY_DIR}/{- $lib_info{libssl}->{shared_import} -}") + set(OPENSSL_LIBSSL_DEPENDENCIES OpenSSL::Crypto {- join(' ', @LDLIBS) -}) + set_target_properties(OpenSSL::SSL PROPERTIES + IMPORTED_LINK_INTERFACE_LANGUAGES "C" + IMPORTED_IMPLIB ${OPENSSL_LIBSSL_IMPORT} + IMPORTED_LOCATION ${OPENSSL_LIBSSL_SHARED}) + set_property(TARGET OpenSSL::SSL + PROPERTY INTERFACE_LINK_LIBRARIES ${OPENSSL_LIBSSL_DEPENDENCIES}) + + # Directories and names compatible with CMake's FindOpenSSL.cmake + set(OPENSSL_CRYPTO_LIBRARY ${OPENSSL_LIBCRYPTO_IMPORT}) + set(OPENSSL_CRYPTO_LIBRARIES ${OPENSSL_CRYPTO_LIBRARY} ${OPENSSL_LIBCRYPTO_DEPENDENCIES}) + set(OPENSSL_SSL_LIBRARY ${OPENSSL_LIBSSL_IMPORT}) + set(OPENSSL_SSL_LIBRARIES ${OPENSSL_SSL_LIBRARY} ${OPENSSL_LIBSSL_DEPENDENCIES}) + set(OPENSSL_LIBRARIES ${OPENSSL_SSL_LIBRARY} ${OPENSSL_LIBSSL_DEPENDENCIES} ${OPENSSL_LIBCRYPTO_DEPENDENCIES}) +{- output_on() unless $lib_info{libcrypto}->{shared_import}; + output_off() if $lib_info{libcrypto}->{shared_import}; "" -} + # Dependencies are assumed to be implied in the shared libraries + set(OPENSSL_LIBCRYPTO_SHARED "${OPENSSL_LIBRARY_DIR}/{- $lib_info{libcrypto}->{shared} -}") + set_target_properties(OpenSSL::Crypto PROPERTIES + IMPORTED_LINK_INTERFACE_LANGUAGES "C" + IMPORTED_LOCATION ${OPENSSL_LIBCRYPTO_SHARED}) + + set(OPENSSL_LIBSSL_SHARED "${OPENSSL_LIBRARY_DIR}/{- $lib_info{libssl}->{shared} -}") + set_target_properties(OpenSSL::SSL PROPERTIES + IMPORTED_LINK_INTERFACE_LANGUAGES "C" + IMPORTED_LOCATION ${OPENSSL_LIBSSL_SHARED}) + + # Directories and names compatible with CMake's FindOpenSSL.cmake + set(OPENSSL_CRYPTO_LIBRARY ${OPENSSL_LIBCRYPTO_SHARED}) + set(OPENSSL_CRYPTO_LIBRARIES ${OPENSSL_CRYPTO_LIBRARY}) + set(OPENSSL_SSL_LIBRARY ${OPENSSL_LIBSSL_SHARED}) + set(OPENSSL_SSL_LIBRARIES ${OPENSSL_SSL_LIBRARY}) + set(OPENSSL_LIBRARIES ${OPENSSL_SSL_LIBRARIES}) +{- output_on() if $lib_info{libcrypto}->{shared_import}; "" -} +{- output_on() if $no_shared; "" -} +endif() + +set_target_properties(OpenSSL::Crypto PROPERTIES + INTERFACE_INCLUDE_DIRECTORIES "${OPENSSL_INCLUDE_DIR}") +set_target_properties(OpenSSL::SSL PROPERTIES + INTERFACE_INCLUDE_DIRECTORIES "${OPENSSL_INCLUDE_DIR}") + +{- output_off() if $disabled{uplink}; "" -} +add_library(OpenSSL::applink INTERFACE IMPORTED) +set_property(TARGET OpenSSL::applink PROPERTY + INTERFACE_SOURCES "${OPENSSL_APPLINK_SOURCE}") +{- output_on() if $disabled{uplink}; "" -} + +unset(_ossl_prefix) +unset(_ossl_use_static_libs) diff --git a/exporters/cmake/OpenSSLConfigVersion.cmake.in b/exporters/cmake/OpenSSLConfigVersion.cmake.in new file mode 100644 index 0000000000..b1290a9eec --- /dev/null +++ b/exporters/cmake/OpenSSLConfigVersion.cmake.in @@ -0,0 +1,17 @@ +# Generated by OpenSSL + +set(PACKAGE_VERSION {- $config{version} -}) + +if(NOT PACKAGE_FIND_VERSION) + # find_package() was called without any version information. This is assumed to + # mean that the caller accepts whatever they get. + set(PACKAGE_VERSION_COMPATIBLE 1) +elseif(PACKAGE_FIND_VERSION_MAJOR LESS {- my $x = $config{version}; $x =~ s/\..*//; $x -} + OR PACKAGE_FIND_VERSION VERSION_GREATER {- $config{version} -}) + set(PACKAGE_VERSION_UNSUITABLE 1) +else() + set(PACKAGE_VERSION_COMPATIBLE 1) + if(PACKAGE_FIND_VERSION VERSION_EQUAL {- $config{version} -}) + set(PACKAGE_VERSION_EXACT 1) + endif() +endif() 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}'); |