1# Generated by OpenSSL 2{- 3 use lib catdir($config{sourcedir}, 'Configurations'); 4 use platform; 5 use Data::Dumper; 6 7 our %lib_info = ( 8 map { my %x = (); 9 my $lib_static = platform->staticlib($_); 10 my $lib_shared = 11 (platform->can("sharedlib_simple") 12 ? platform->sharedlib_simple($_) 13 : undef) 14 // platform->sharedlib($_); 15 $x{static} = $lib_static if $lib_static; 16 $x{shared} = $lib_shared if $lib_shared; 17 if (platform->can("sharedlib_import")) { 18 my $lib_shared_import = platform->sharedlib_import($_); 19 $x{shared_import} = $lib_shared_import if $lib_shared_import; 20 } 21 %x ? ( $_ => \%x ) : () } 22 grep { !$unified_info{attributes}->{libraries}->{$_}->{noinst} } 23 @{$unified_info{libraries}} 24 ); 25 our $no_static = !$disabled{shared} && !$lib_info{libcrypto}->{static}; 26 our $no_shared = $disabled{shared}; 27 28 # Unixifying of paths, because that's what CMake understands. 29 # This assumes that the given path is absolute. 30 sub unixify { 31 use File::Spec; 32 use File::Spec::Unix; 33 34 my $path = shift; 35 my $no_file = shift; 36 (my $volume, $directories, $file) = File::Spec->splitpath($path, $no_file // ()); 37 $directories = File::Spec::Unix->catdir(File::Spec->splitdir($directories)); 38 39 # We know that $volume is ignored by File::Spec::Unix, so we handle it specially 40 # according to the conventions of the platform. 41 $volume =~ s|^(.*?):$|/$1| if $^O eq "vms"; # On VMS, DEV: -> /DEV 42 43 return $volume . File::Spec::Unix->catpath('', $directories, $no_file ? () : $file); 44 } 45 "" 46-} 47# Commands may need to know the format version. 48set(CMAKE_IMPORT_FILE_VERSION 1) 49 50# Avoid duplicate find_package() 51set(_ossl_expected_targets OpenSSL::Crypto OpenSSL::SSL 52 {- output_off() if $disabled{uplink}; "" -}OpenSSL::applink{- output_on() if $disabled{uplink}; "" -}) 53set(_ossl_defined_targets) 54set(_ossl_undefined_targets) 55foreach(t IN LISTS _ossl_expected_targets) 56 if(TARGET "${t}") 57 LIST(APPEND _ossl_defined_targets "${t}") 58 else() 59 LIST(APPEND _ossl_undefined_targets "${t}") 60 endif() 61endforeach() 62message(DEBUG "_ossl_expected_targets = ${_ossl_expected_targets}") 63message(DEBUG "_ossl_defined_targets = ${_ossl_defined_targets}") 64message(DEBUG "_ossl_undefined_targets = ${_ossl_undefined_targets}") 65if(NOT _ossl_undefined_targets) 66 # All targets are defined, we're good, just undo everything and return 67 unset(_ossl_expected_targets) 68 unset(_ossl_defined_targets) 69 unset(_ossl_undefined_targets) 70 unset(CMAKE_IMPORT_FILE_VERSION) 71 return() 72endif() 73if(_ossl_defined_targets) 74 # We have a mix of defined and undefined targets. This is hard to reconcile, 75 # and probably the result of another config, or FindOpenSSL.cmake having been 76 # called, or whatever. Therefore, the best course of action is to quit with a 77 # hard error. 78 message(FATAL_ERROR "Some targets defined, others not:\nNot defined: ${_ossl_undefined_targets}\nDefined: ${_ossl_defined_targets}") 79endif() 80unset(_ossl_expected_targets) 81unset(_ossl_defined_targets) 82unset(_ossl_undefined_targets) 83 84{- 85 # It can be argued that 'cmake_path' would be the better choice here. However, 86 # cmake_path is relatively new, while get_filename_component has been around 87 # since before CMake 3.0 88-} 89# Set up the import path, so all other import paths are made relative this file 90get_filename_component(_ossl_prefix "${CMAKE_CURRENT_LIST_FILE}" PATH) 91{- 92 # For each component in $OpenSSL::safe::installdata::CMAKECONFIGDIR[0] relative to 93 # $OpenSSL::safe::installdata::PREFIX[0], have CMake figure out the parent directory. 94 my $d = join('/', unixify(catdir($OpenSSL::safe::installdata::LIBDIR_REL_PREFIX[0], 95 $OpenSSL::safe::installdata::CMAKECONFIGDIR_REL_LIBDIR[0]), 1)); 96 $OUT = ''; 97 if ($d ne '.') { 98 $OUT .= 'get_filename_component(_ossl_prefix "${_ossl_prefix}" PATH)' . "\n" 99 foreach (split '/', $d); 100 } 101-} 102if(_ossl_prefix STREQUAL "/") 103 set(_ossl_prefix "") 104endif() 105 106{- output_off() unless $disabled{shared}; "" -} 107set(_ossl_use_static_libs True) 108{- output_on() unless $disabled{shared}; "" -} 109if(OPENSSL_USE_STATIC_LIBS) 110 set(_ossl_use_static_libs True) 111elseif(DEFINED OPENSSL_USE_STATIC_LIBS) 112 # We know OPENSSL_USE_STATIC_LIBS is defined and False 113 if(_ossl_use_static_libs) 114 # OPENSSL_USE_STATIC_LIBS is explicitly false, indicating that shared libraries are 115 # required. However, _ossl_use_static_libs indicates that no shared libraries are 116 # available. The best course of action is to simply return and leave it to CMake to 117 # use another OpenSSL config. 118 unset(_ossl_use_static_libs) 119 unset(CMAKE_IMPORT_FILE_VERSION) 120 return() 121 endif() 122endif() 123 124# Version, copied from what find_package() gives, for compatibility with FindOpenSSL.cmake 125set(OPENSSL_VERSION "${OpenSSL_VERSION}") 126set(OPENSSL_VERSION_MAJOR "${OpenSSL_VERSION_MAJOR}") 127set(OPENSSL_VERSION_MINOR "${OpenSSL_VERSION_MINOR}") 128set(OPENSSL_VERSION_FIX "${OpenSSL_VERSION_PATCH}") 129set(OPENSSL_FOUND YES) 130 131# Directories and names 132set(OPENSSL_LIBRARY_DIR "${_ossl_prefix}/{- unixify($OpenSSL::safe::installdata::LIBDIR_REL_PREFIX[0], 1); -}") 133set(OPENSSL_INCLUDE_DIR{- $OUT = ''; 134 $OUT .= ' "${_ossl_prefix}/' . $_ . '"' 135 foreach (@OpenSSL::safe::installdata::INCLUDEDIR_REL_PREFIX); -}) 136set(OPENSSL_ENGINES_DIR "${_ossl_prefix}/{- unixify($OpenSSL::safe::installdata::LIBDIR_REL_PREFIX[0], 1); -}/{- unixify($OpenSSL::safe::installdata::ENGINESDIR_REL_LIBDIR[0], 1); -}") 137set(OPENSSL_MODULES_DIR "${_ossl_prefix}/{- unixify($OpenSSL::safe::installdata::LIBDIR_REL_PREFIX[0], 1); -}/{- unixify($OpenSSL::safe::installdata::MODULESDIR_REL_LIBDIR[0], 1); -}") 138set(OPENSSL_RUNTIME_DIR "${_ossl_prefix}/{- unixify($OpenSSL::safe::installdata::BINDIR_REL_PREFIX[0], 1); -}") 139{- output_off() if $disabled{uplink}; "" -} 140set(OPENSSL_APPLINK_SOURCE "${_ossl_prefix}/{- unixify($OpenSSL::safe::installdata::APPLINKDIR_REL_PREFIX[0], 1); -}/applink.c") 141{- output_on() if $disabled{uplink}; "" -} 142set(OPENSSL_PROGRAM "${OPENSSL_RUNTIME_DIR}/{- platform->bin('openssl') -}") 143 144# Set up the imported targets 145if(_ossl_use_static_libs) 146{- output_off() unless $no_static; "" -} 147 # Static libraries are UNSUPPORTED in this configuration 148{- output_on() unless $no_static; output_off() if $no_static; "" -} 149 add_library(OpenSSL::Crypto STATIC IMPORTED) 150 add_library(OpenSSL::SSL STATIC IMPORTED) 151 152 set(OPENSSL_LIBCRYPTO_STATIC "${OPENSSL_LIBRARY_DIR}/{- $lib_info{libcrypto}->{static} -}") 153 set(OPENSSL_LIBCRYPTO_DEPENDENCIES {- join(' ', @OpenSSL::safe::installdata::LDLIBS) -}) 154 set_target_properties(OpenSSL::Crypto PROPERTIES 155 IMPORTED_LINK_INTERFACE_LANGUAGES "C" 156 IMPORTED_LOCATION ${OPENSSL_LIBCRYPTO_STATIC}) 157 set_property(TARGET OpenSSL::Crypto 158 PROPERTY INTERFACE_LINK_LIBRARIES ${OPENSSL_LIBCRYPTO_DEPENDENCIES}) 159 160 set(OPENSSL_LIBSSL_STATIC "${OPENSSL_LIBRARY_DIR}/{- $lib_info{libssl}->{static} -}") 161 set(OPENSSL_LIBSSL_DEPENDENCIES OpenSSL::Crypto) 162 set_target_properties(OpenSSL::SSL PROPERTIES 163 IMPORTED_LINK_INTERFACE_LANGUAGES "C" 164 IMPORTED_LOCATION ${OPENSSL_LIBSSL_STATIC}) 165 set_property(TARGET OpenSSL::SSL 166 PROPERTY INTERFACE_LINK_LIBRARIES ${OPENSSL_LIBSSL_DEPENDENCIES}) 167 168 # Directories and names compatible with CMake's FindOpenSSL.cmake 169 set(OPENSSL_CRYPTO_LIBRARY ${OPENSSL_LIBCRYPTO_STATIC}) 170 set(OPENSSL_CRYPTO_LIBRARIES ${OPENSSL_CRYPTO_LIBRARY} ${OPENSSL_LIBCRYPTO_DEPENDENCIES}) 171 set(OPENSSL_SSL_LIBRARY ${OPENSSL_LIBSSL_STATIC}) 172 set(OPENSSL_SSL_LIBRARIES ${OPENSSL_SSL_LIBRARY} ${OPENSSL_LIBSSL_DEPENDENCIES}) 173 set(OPENSSL_LIBRARIES ${OPENSSL_SSL_LIBRARY} ${OPENSSL_LIBSSL_DEPENDENCIES} ${OPENSSL_LIBCRYPTO_DEPENDENCIES}) 174{- output_on(); "" -} 175else() 176{- output_off() unless $no_shared; "" -} 177 # Shared libraries are UNSUPPORTED in this configuration 178{- output_on() unless $no_shared; 179 output_off() if $no_shared; "" -} 180 add_library(OpenSSL::Crypto SHARED IMPORTED) 181 add_library(OpenSSL::SSL SHARED IMPORTED) 182{- output_off() unless $lib_info{libcrypto}->{shared_import}; "" -} 183 set(OPENSSL_LIBCRYPTO_SHARED "${OPENSSL_RUNTIME_DIR}/{- $lib_info{libcrypto}->{shared} -}") 184 set(OPENSSL_LIBCRYPTO_IMPORT "${OPENSSL_LIBRARY_DIR}/{- $lib_info{libcrypto}->{shared_import} -}") 185 set(OPENSSL_LIBCRYPTO_DEPENDENCIES {- join(' ', @LDLIBS) -}) 186 set_target_properties(OpenSSL::Crypto PROPERTIES 187 IMPORTED_LINK_INTERFACE_LANGUAGES "C" 188 IMPORTED_IMPLIB ${OPENSSL_LIBCRYPTO_IMPORT} 189 IMPORTED_LOCATION ${OPENSSL_LIBCRYPTO_SHARED}) 190 set_property(TARGET OpenSSL::Crypto 191 PROPERTY INTERFACE_LINK_LIBRARIES ${OPENSSL_LIBCRYPTO_DEPENDENCIES}) 192 193 set(OPENSSL_LIBSSL_SHARED "${OPENSSL_RUNTIME_DIR}/{- $lib_info{libssl}->{shared} -}") 194 set(OPENSSL_LIBSSL_IMPORT "${OPENSSL_LIBRARY_DIR}/{- $lib_info{libssl}->{shared_import} -}") 195 set(OPENSSL_LIBSSL_DEPENDENCIES OpenSSL::Crypto {- join(' ', @LDLIBS) -}) 196 set_target_properties(OpenSSL::SSL PROPERTIES 197 IMPORTED_LINK_INTERFACE_LANGUAGES "C" 198 IMPORTED_IMPLIB ${OPENSSL_LIBSSL_IMPORT} 199 IMPORTED_LOCATION ${OPENSSL_LIBSSL_SHARED}) 200 set_property(TARGET OpenSSL::SSL 201 PROPERTY INTERFACE_LINK_LIBRARIES ${OPENSSL_LIBSSL_DEPENDENCIES}) 202 203 # Directories and names compatible with CMake's FindOpenSSL.cmake 204 set(OPENSSL_CRYPTO_LIBRARY ${OPENSSL_LIBCRYPTO_IMPORT}) 205 set(OPENSSL_CRYPTO_LIBRARIES ${OPENSSL_CRYPTO_LIBRARY} ${OPENSSL_LIBCRYPTO_DEPENDENCIES}) 206 set(OPENSSL_SSL_LIBRARY ${OPENSSL_LIBSSL_IMPORT}) 207 set(OPENSSL_SSL_LIBRARIES ${OPENSSL_SSL_LIBRARY} ${OPENSSL_LIBSSL_DEPENDENCIES}) 208 set(OPENSSL_LIBRARIES ${OPENSSL_SSL_LIBRARY} ${OPENSSL_LIBSSL_DEPENDENCIES} ${OPENSSL_LIBCRYPTO_DEPENDENCIES}) 209{- output_on() unless $lib_info{libcrypto}->{shared_import}; 210 output_off() if $lib_info{libcrypto}->{shared_import}; "" -} 211 # Dependencies are assumed to be implied in the shared libraries 212 set(OPENSSL_LIBCRYPTO_SHARED "${OPENSSL_LIBRARY_DIR}/{- $lib_info{libcrypto}->{shared} -}") 213 set_target_properties(OpenSSL::Crypto PROPERTIES 214 IMPORTED_LINK_INTERFACE_LANGUAGES "C" 215 IMPORTED_LOCATION ${OPENSSL_LIBCRYPTO_SHARED}) 216 217 set(OPENSSL_LIBSSL_SHARED "${OPENSSL_LIBRARY_DIR}/{- $lib_info{libssl}->{shared} -}") 218 set_target_properties(OpenSSL::SSL PROPERTIES 219 IMPORTED_LINK_INTERFACE_LANGUAGES "C" 220 IMPORTED_LOCATION ${OPENSSL_LIBSSL_SHARED}) 221 222 # Directories and names compatible with CMake's FindOpenSSL.cmake 223 set(OPENSSL_CRYPTO_LIBRARY ${OPENSSL_LIBCRYPTO_SHARED}) 224 set(OPENSSL_CRYPTO_LIBRARIES ${OPENSSL_CRYPTO_LIBRARY}) 225 set(OPENSSL_SSL_LIBRARY ${OPENSSL_LIBSSL_SHARED}) 226 set(OPENSSL_SSL_LIBRARIES ${OPENSSL_SSL_LIBRARY}) 227 set(OPENSSL_LIBRARIES ${OPENSSL_SSL_LIBRARIES}) 228{- output_on() if $lib_info{libcrypto}->{shared_import}; "" -} 229{- output_on() if $no_shared; "" -} 230endif() 231 232set_target_properties(OpenSSL::Crypto PROPERTIES 233 INTERFACE_INCLUDE_DIRECTORIES "${OPENSSL_INCLUDE_DIR}") 234set_target_properties(OpenSSL::SSL PROPERTIES 235 INTERFACE_INCLUDE_DIRECTORIES "${OPENSSL_INCLUDE_DIR}") 236 237{- output_off() if $disabled{uplink}; "" -} 238add_library(OpenSSL::applink INTERFACE IMPORTED) 239set_property(TARGET OpenSSL::applink PROPERTY 240 INTERFACE_SOURCES "${OPENSSL_APPLINK_SOURCE}") 241{- output_on() if $disabled{uplink}; "" -} 242 243unset(_ossl_prefix) 244unset(_ossl_use_static_libs) 245