diff options
author | Brad King <brad.king@kitware.com> | 2020-05-18 16:21:01 (GMT) |
---|---|---|
committer | Kitware Robot <kwrobot@kitware.com> | 2020-05-18 16:22:24 (GMT) |
commit | 31252bd3354bf90cf57b4717afaf3cc9950ba333 (patch) | |
tree | 5a2db08a039cf64ff3dd505d45d51aeaf931a709 /Modules | |
parent | ca699e9d69a68e6c0f9ab7f7a76930c9295c1f59 (diff) | |
parent | 7b83ca816a9c51b0bbbaaf22be8c45c1c05593c9 (diff) | |
download | CMake-31252bd3354bf90cf57b4717afaf3cc9950ba333.zip CMake-31252bd3354bf90cf57b4717afaf3cc9950ba333.tar.gz CMake-31252bd3354bf90cf57b4717afaf3cc9950ba333.tar.bz2 |
Merge topic 'FindOpenSSL-applink'
7b83ca816a FindOpenSSL: add target OpenSSL::applink to support OpenSSL's applink feature
Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !4737
Diffstat (limited to 'Modules')
-rw-r--r-- | Modules/FindOpenSSL.cmake | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/Modules/FindOpenSSL.cmake b/Modules/FindOpenSSL.cmake index af713d6..a813ab5 100644 --- a/Modules/FindOpenSSL.cmake +++ b/Modules/FindOpenSSL.cmake @@ -22,6 +22,27 @@ This module defines the following :prop_tgt:`IMPORTED` targets: The OpenSSL ``ssl`` library, if found. ``OpenSSL::Crypto`` The OpenSSL ``crypto`` library, if found. +``OpenSSL::applink`` + 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 plaforms 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 prefered 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: + +.. code-block:: cmake + + 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 ^^^^^^^^^^^^^^^^ @@ -45,6 +66,10 @@ This module will set the following variables in your project: 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 ^^^^^ @@ -524,6 +549,28 @@ if(OPENSSL_FOUND) endif() _OpenSSL_target_add_dependencies(OpenSSL::SSL) endif() + + if("${OPENSSL_VERSION_MAJOR}.${OPENSSL_VERSION_MAJOR}.${OPENSSL_VERSION_FIX}" VERSION_GREATER_EQUAL "0.9.8") + if(MSVC) + if(EXISTS "${OPENSSL_INCLUDE_DIR}") + set(_OPENSSL_applink_paths PATHS ${OPENSSL_INCLUDE_DIR}) + endif() + find_file(OPENSSL_APPLINK_SOURCE + NAMES + openssl/applink.c + ${_OPENSSL_applink_paths} + NO_DEFAULT_PATH) + if(OPENSSL_APPLINK_SOURCE) + set(_OPENSSL_applink_interface_srcs ${OPENSSL_APPLINK_SOURCE}) + endif() + endif() + if(NOT TARGET OpenSSL::applink) + add_library(OpenSSL::applink INTERFACE IMPORTED) + set_property(TARGET OpenSSL::applink APPEND + PROPERTY INTERFACE_SOURCES + ${_OPENSSL_applink_interface_srcs}) + endif() + endif() endif() # Restore the original find library ordering |