Find the OpenSSL encryption library.

This module finds an installed OpenSSL library and determines its version.

New 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.

New in version 3.18: Support for OpenSSL 3.0.


New in version 3.12.

This module supports two optional COMPONENTS: Crypto and SSL. Both components have associated imported targets, as described below.

Imported Targets

New in version 3.4.

This module defines the following IMPORTED targets:


The OpenSSL ssl library, if found.


The OpenSSL crypto library, if found.


New 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.

Result Variables

This module will set the following variables in your project:


System has the OpenSSL library. If no components are requested it only requires the crypto library.


The OpenSSL include directory.


The OpenSSL crypto library.


The OpenSSL crypto library and its dependencies.


The OpenSSL SSL library.


The OpenSSL SSL library and its dependencies.


All OpenSSL libraries and their dependencies.


This is set to $major.$minor.$revision$patch (e.g. 0.9.8s).


The 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:


Set to the root directory of an OpenSSL installation.


New in version 3.4.

Set to TRUE to look for static libraries.


New in version 3.5.

Set to TRUE to choose the MT version of the lib.


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.