summaryrefslogtreecommitdiffstats
path: root/cmake
diff options
context:
space:
mode:
authorLi Xinwei <1326710505@qq.com>2021-01-22 19:13:19 +0800
committerLi Xinwei <1326710505@qq.com>2021-01-28 18:21:06 +0000
commit29a58af4caea921e641c27477e6a255274de27ea (patch)
tree6a8126ede33ebcde151ddc7321412c788060c0d4 /cmake
parent40bfbe7dd9fb783b07550db8944931d1637da721 (diff)
CMake: Fix HAVE_openssl config test when using static OpenSSL
When using static OpenSSL, HAVE_openssl test will fail, because of unresolved external symbols. These symbols are from Ws2_32.lib and Crypt32.lib, which CMake does not link by default. In qmake build system, we can use OPENSSL_LIBS variable to specify these system libraries. But there is no similar variable in CMake build system. Accordingly, we should let OpenSSL::Crypto target link these libraries. Upstream issue: https://gitlab.kitware.com/cmake/cmake/-/issues/19263 Pick-to: 6.0 Change-Id: I5f27790b251d0a0f71aaf2aed2b933aeb3326f1f Reviewed-by: Craig Scott <craig.scott@qt.io> Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
Diffstat (limited to 'cmake')
-rw-r--r--cmake/FindWrapOpenSSL.cmake12
1 files changed, 12 insertions, 0 deletions
diff --git a/cmake/FindWrapOpenSSL.cmake b/cmake/FindWrapOpenSSL.cmake
index 6e80862258..ef9d49842c 100644
--- a/cmake/FindWrapOpenSSL.cmake
+++ b/cmake/FindWrapOpenSSL.cmake
@@ -11,6 +11,18 @@ set(WrapOpenSSL_FOUND OFF)
find_package(WrapOpenSSLHeaders ${WrapOpenSSL_FIND_VERSION})
if(OpenSSL_FOUND)
+ if(WIN32)
+ get_target_property(libType OpenSSL::Crypto TYPE)
+ if(libType STREQUAL "ALIAS")
+ get_target_property(writableLib OpenSSL::Crypto ALIASED_TARGET)
+ else()
+ set(writableLib OpenSSL::Crypto)
+ endif()
+ target_link_libraries(${writableLib} INTERFACE Ws2_32 Crypt32)
+ unset(libType)
+ unset(writableLib)
+ endif()
+
set(WrapOpenSSL_FOUND ON)
add_library(WrapOpenSSL::WrapOpenSSL INTERFACE IMPORTED)