Find the OpenSSL encryption library.
This module finds an installed OpenSSL library and determines its version.
Added in version 3.19: When a version is requested, it can be specified as a simple value or as a
range. For a detailed description of version range usage and capabilities,
refer to the find_package() command.
Added in version 3.18: Support for OpenSSL 3.0.
Added in version 3.12.
This module supports two optional COMPONENTS: Crypto and SSL. Both
components have associated imported targets, as described below.
Added in version 3.4.
This module defines the following IMPORTED targets:
OpenSSL::SSLThe OpenSSL ssl library, if found.
OpenSSL::CryptoThe OpenSSL crypto library, if found.
OpenSSL::applinkAdded in version 3.18.
The OpenSSL applink components that might be need to be compiled into
projects under MSVC. This target is available only if found OpenSSL version
is not less than 0.9.8. By linking this target the above OpenSSL targets can
be linked even if the project has different MSVC runtime configurations with
the above OpenSSL targets. This target has no effect on platforms other than
MSVC.
NOTE: Due to how INTERFACE_SOURCES are consumed by the consuming target,
unless you certainly know what you are doing, it is always preferred to link
OpenSSL::applink target as PRIVATE and to make sure that this target is
linked at most once for the whole dependency graph of any library or
executable:
target_link_libraries(myTarget PRIVATE OpenSSL::applink)
Otherwise you would probably encounter unexpected random problems when building and linking, as both the ISO C and the ISO C++ standard claims almost nothing about what a link process should be.
This module will set the following variables in your project:
OPENSSL_FOUNDSystem has the OpenSSL library. If no components are requested it only requires the crypto library.
OPENSSL_INCLUDE_DIRThe OpenSSL include directory.
OPENSSL_CRYPTO_LIBRARYThe OpenSSL crypto library.
OPENSSL_CRYPTO_LIBRARIESThe OpenSSL crypto library and its dependencies.
OPENSSL_SSL_LIBRARYThe OpenSSL SSL library.
OPENSSL_SSL_LIBRARIESThe OpenSSL SSL library and its dependencies.
OPENSSL_LIBRARIESAll OpenSSL libraries and their dependencies.
OPENSSL_VERSIONThis is set to $major.$minor.$revision$patch (e.g. 0.9.8s).
OPENSSL_APPLINK_SOURCEThe sources in the target OpenSSL::applink that is mentioned above. This
variable shall always be undefined if found openssl version is less than
0.9.8 or if platform is not MSVC.
The following variables may be set to control search behavior:
OPENSSL_ROOT_DIRSet to the root directory of an OpenSSL installation.
OPENSSL_USE_STATIC_LIBSAdded in version 3.4.
Set to TRUE to look for static libraries.
OPENSSL_MSVC_STATIC_RTAdded in version 3.5.
Set to TRUE to choose the MT version of the lib.
ENV{PKG_CONFIG_PATH}On UNIX-like systems, pkg-config is used to locate the system OpenSSL.
Set the PKG_CONFIG_PATH environment variable to look in alternate
locations. Useful on multi-lib systems.