# FindOpenSSL

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.

## Optional COMPONENTS

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:

`OpenSSL::SSL`

  The OpenSSL `ssl` library, if found.

`OpenSSL::Crypto`

  The OpenSSL `crypto` library, if found.

`OpenSSL::applink`

  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:

`OPENSSL_FOUND`

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

`OPENSSL_INCLUDE_DIR`

  The OpenSSL include directory.

`OPENSSL_CRYPTO_LIBRARY`

  The OpenSSL crypto library.

`OPENSSL_CRYPTO_LIBRARIES`

  The OpenSSL crypto library and its dependencies.

`OPENSSL_SSL_LIBRARY`

  The OpenSSL SSL library.

`OPENSSL_SSL_LIBRARIES`

  The OpenSSL SSL library and its dependencies.

`OPENSSL_LIBRARIES`

  All OpenSSL libraries and their dependencies.

`OPENSSL_VERSION`

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

`OPENSSL_APPLINK_SOURCE`

  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.

## Hints

Set `OPENSSL_ROOT_DIR` to the root directory of an OpenSSL installation.

New in version 3.4: Set `OPENSSL_USE_STATIC_LIBS` to `TRUE` to look for static libraries.

New in version 3.5: Set `OPENSSL_MSVC_STATIC_RT` set `TRUE` to choose the MT version of the lib.