diff options
author | Brad King <brad.king@kitware.com> | 2022-12-06 13:05:40 (GMT) |
---|---|---|
committer | Kitware Robot <kwrobot@kitware.com> | 2022-12-06 13:05:53 (GMT) |
commit | e094bff98328226080685e2585fffffbaeee13ea (patch) | |
tree | 61b8cce54753520b3894655ba98ced290955fb11 /Modules | |
parent | f1f064b7b2c93048897014e096217e1a00f668c7 (diff) | |
parent | 1b7804edd0f4470d1a024902ccb8ffabc98bd5c7 (diff) | |
download | CMake-e094bff98328226080685e2585fffffbaeee13ea.zip CMake-e094bff98328226080685e2585fffffbaeee13ea.tar.gz CMake-e094bff98328226080685e2585fffffbaeee13ea.tar.bz2 |
Merge topic 'FindOpenSSL-static-z'
1b7804edd0 FindOpenSSL: use extra dependencies from pkg-config as well
Acked-by: Kitware Robot <kwrobot@kitware.com>
Acked-by: buildbot <buildbot@kitware.com>
Merge-request: !7986
Diffstat (limited to 'Modules')
-rw-r--r-- | Modules/FindOpenSSL.cmake | 42 |
1 files changed, 38 insertions, 4 deletions
diff --git a/Modules/FindOpenSSL.cmake b/Modules/FindOpenSSL.cmake index f66ffcf..78b1919 100644 --- a/Modules/FindOpenSSL.cmake +++ b/Modules/FindOpenSSL.cmake @@ -112,11 +112,31 @@ The following variables may be set to control search behavior: #]=======================================================================] macro(_OpenSSL_test_and_find_dependencies ssl_library crypto_library) + unset(_OpenSSL_extra_static_deps) if((CMAKE_SYSTEM_NAME STREQUAL "Linux") AND (("${ssl_library}" MATCHES "\\${CMAKE_STATIC_LIBRARY_SUFFIX}$") OR ("${crypto_library}" MATCHES "\\${CMAKE_STATIC_LIBRARY_SUFFIX}$"))) set(_OpenSSL_has_dependencies TRUE) - find_package(Threads) + unset(_OpenSSL_has_dependency_zlib) + if(_OPENSSL_LIBRARIES) + unset(_OpenSSL_has_dependency_dl) + foreach(_OPENSSL_DEP_LIB IN LISTS _OPENSSL_LIBRARIES) + if (_OPENSSL_DEP_LIB STREQUAL "ssl" OR _OPENSSL_DEP_LIB STREQUAL "crypto") + # ignoring: these are the targets + elseif(_OPENSSL_DEP_LIB STREQUAL CMAKE_DL_LIBS) + set(_OpenSSL_has_dependency_dl TRUE) + elseif(_OPENSSL_DEP_LIB STREQUAL "z") + find_package(ZLIB) + set(_OpenSSL_has_dependency_zlib TRUE) + else() + list(APPEND _OpenSSL_extra_static_deps "${_OPENSSL_DEP_LIB}") + endif() + endforeach() + unset(_OPENSSL_DEP_LIB) + else() + set(_OpenSSL_has_dependency_dl TRUE) + find_package(Threads) + endif() else() set(_OpenSSL_has_dependencies FALSE) endif() @@ -126,14 +146,25 @@ function(_OpenSSL_add_dependencies libraries_var) if(CMAKE_THREAD_LIBS_INIT) list(APPEND ${libraries_var} ${CMAKE_THREAD_LIBS_INIT}) endif() - list(APPEND ${libraries_var} ${CMAKE_DL_LIBS}) + if(_OpenSSL_has_dependency_zlib) + list(APPEND ${libraries_var} ${ZLIB_LIBRARY}) + endif() + if(_OpenSSL_has_dependency_dl) + list(APPEND ${libraries_var} ${CMAKE_DL_LIBS}) + endif() + list(APPEND ${libraries_var} ${_OpenSSL_extra_static_deps}) set(${libraries_var} ${${libraries_var}} PARENT_SCOPE) endfunction() function(_OpenSSL_target_add_dependencies target) if(_OpenSSL_has_dependencies) - set_property( TARGET ${target} APPEND PROPERTY INTERFACE_LINK_LIBRARIES Threads::Threads ) - set_property( TARGET ${target} APPEND PROPERTY INTERFACE_LINK_LIBRARIES ${CMAKE_DL_LIBS} ) + set_property( TARGET ${target} APPEND PROPERTY INTERFACE_LINK_LIBRARIES Threads::Threads ${_OpenSSL_extra_static_deps}) + if(_OpenSSL_has_dependency_dl) + set_property( TARGET ${target} APPEND PROPERTY INTERFACE_LINK_LIBRARIES ${CMAKE_DL_LIBS} ) + endif() + if(_OpenSSL_has_dependency_zlib) + set_property( TARGET ${target} APPEND PROPERTY INTERFACE_LINK_LIBRARIES ZLIB::ZLIB ) + endif() endif() if(WIN32 AND OPENSSL_USE_STATIC_LIBS) if(WINCE) @@ -719,3 +750,6 @@ endif() unset(_OPENSSL_FIND_PATH_SUFFIX) unset(_OPENSSL_NAME_POSTFIX) +unset(_OpenSSL_extra_static_deps) +unset(_OpenSSL_has_dependency_dl) +unset(_OpenSSL_has_dependency_zlib) |