Skip to content

FindOpenSSL: Add component support

Harry Mallon requested to merge hjmallon/cmake:master into master

I had a problem a long time ago that OPENSSL_LIBRARIES includes the OPENSSL_SSL_LIBRARY but OPENSSL_FOUND does not check for it. On my Windows CI machine this condition is hit and cmake failures occur.

I made merge request !371 (merged) which was in 3.8.0. However this was reversed in 3.8.2 due to #16882 (closed), which I didn't notice until I tried to remove our local hacky fix this week.

Maybe this Pull Req would be a more suitable fix for the long term. The behaviour is intended to be:

  • OPENSSL_FOUND set if OPENSSL_CRYPTO_LIBRARY is found (old behaviour). This behaviour is now documented.
  • COMPONENTS can be sent in find_package. These are SSL and Crypto to match the existing targets. If you send COMPONENTS then OPENSSL_FOUND will only be TRUE if all are available. This is new behaviour.
  • OpenSSL::SSL and/or OpenSSL::Crypto imported targets will only be created if OPENSSL_FOUND is TRUE (existing behavior maintained).
  • OPENSSL_VERSION is sent to find_package_handle_standard_args without checking it exists as the function does that for us I believe. This is a change in behaviour, but should be backwards compatible.

Topic-rename: FindOpenSSL-components

Edited by Craig Scott

Merge request reports