summaryrefslogtreecommitdiff
path: root/Modules/FindOpenSSL.cmake
diff options
context:
space:
mode:
authorRolf Eike Beer <eb@emlix.com>2022-12-05 12:43:56 +0100
committerRolf Eike Beer <eb@emlix.com>2022-12-05 13:00:41 +0100
commit1b7804edd0f4470d1a024902ccb8ffabc98bd5c7 (patch)
tree11add2d7d6a65aaaab42ebf7a4bb0497a2f6c10f /Modules/FindOpenSSL.cmake
parent2243bba402975f645430428a85cf36d614ba5ee4 (diff)
downloadcmake-1b7804edd0f4470d1a024902ccb8ffabc98bd5c7.tar.gz
FindOpenSSL: use extra dependencies from pkg-config as well
This is important if OpenSSL is linked against an external zlib.
Diffstat (limited to 'Modules/FindOpenSSL.cmake')
-rw-r--r--Modules/FindOpenSSL.cmake42
1 files changed, 38 insertions, 4 deletions
diff --git a/Modules/FindOpenSSL.cmake b/Modules/FindOpenSSL.cmake
index f66ffcf610..78b1919d89 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)