On 15 August 2016 at 14:25, Brad King <brad.k...@kitware.com> wrote: > On 08/14/2016 01:58 PM, Alexander Lamaison wrote: >> This patch updates FindOpenSSL.cmake to include the necessary system >> libs in the OpenSSL libraries variables and in the OpenSSL::Crypto and >> OpenSSL::SSL target properties. > > Thanks. The singluar-named OPENSSL_{SSL,CRYPTO}_LIBRARY variables > are meant just to hold the specific library files (i.e. the result > of one find_library call). Instead of placing the dependencies > directly in them we should have other (internal) variables to hold > them. That will also avoid duplicating conditions for filling in > the imported target information.
I've attached a new patch without the changes to the singular-named variables. Alex
From e6cca7701b9b04507ec9d1a054dcc6f3652b61bb Mon Sep 17 00:00:00 2001 From: Alexander Lamaison <alexander.lamai...@gmail.com> Date: Tue, 16 Aug 2016 21:23:57 +0100 Subject: [PATCH] FindOpenSSL: Link libraries needed for static OpenSSL. OpenSSL depends on system libraries. When linking statically again OpenSSL, the client target must also link those libraries. This patch updates FindOpenSSL.cmake to include the necessary system libs in the OpenSSL libraries variables and in the OpenSSL::Crypto and OpenSSL::SSL target properties. The dependencies: Windows: crypt32 Unix: CMAKE_DL_LIBS --- Modules/FindOpenSSL.cmake | 25 +++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-) diff --git a/Modules/FindOpenSSL.cmake b/Modules/FindOpenSSL.cmake index 10b62ff..ac55416 100644 --- a/Modules/FindOpenSSL.cmake +++ b/Modules/FindOpenSSL.cmake @@ -201,7 +201,7 @@ if(WIN32 AND NOT CYGWIN) SSL_EAY_LIBRARY_DEBUG SSL_EAY_LIBRARY_RELEASE) set(OPENSSL_SSL_LIBRARY ${SSL_EAY_LIBRARY} ) set(OPENSSL_CRYPTO_LIBRARY ${LIB_EAY_LIBRARY} ) - set(OPENSSL_LIBRARIES ${SSL_EAY_LIBRARY} ${LIB_EAY_LIBRARY} ) + set(OPENSSL_LIBRARIES ${SSL_EAY_LIBRARY} ${LIB_EAY_LIBRARY} crypt32) elseif(MINGW) # same player, for MinGW set(LIB_EAY_NAMES crypto libeay32) @@ -229,7 +229,7 @@ if(WIN32 AND NOT CYGWIN) mark_as_advanced(SSL_EAY LIB_EAY) set(OPENSSL_SSL_LIBRARY ${SSL_EAY} ) set(OPENSSL_CRYPTO_LIBRARY ${LIB_EAY} ) - set(OPENSSL_LIBRARIES ${SSL_EAY} ${LIB_EAY} ) + set(OPENSSL_LIBRARIES ${SSL_EAY} ${LIB_EAY} crypt32) unset(LIB_EAY_NAMES) unset(SSL_EAY_NAMES) else() @@ -259,7 +259,7 @@ if(WIN32 AND NOT CYGWIN) mark_as_advanced(SSL_EAY LIB_EAY) set(OPENSSL_SSL_LIBRARY ${SSL_EAY} ) set(OPENSSL_CRYPTO_LIBRARY ${LIB_EAY} ) - set(OPENSSL_LIBRARIES ${SSL_EAY} ${LIB_EAY} ) + set(OPENSSL_LIBRARIES ${SSL_EAY} ${LIB_EAY} crypt32) endif() else() @@ -290,10 +290,10 @@ else() mark_as_advanced(OPENSSL_CRYPTO_LIBRARY OPENSSL_SSL_LIBRARY) # compat defines - set(OPENSSL_SSL_LIBRARIES ${OPENSSL_SSL_LIBRARY}) - set(OPENSSL_CRYPTO_LIBRARIES ${OPENSSL_CRYPTO_LIBRARY}) + set(OPENSSL_SSL_LIBRARIES ${OPENSSL_SSL_LIBRARY} ${CMAKE_DL_LIBS}) + set(OPENSSL_CRYPTO_LIBRARIES ${OPENSSL_CRYPTO_LIBRARY} ${CMAKE_DL_LIBS}) - set(OPENSSL_LIBRARIES ${OPENSSL_SSL_LIBRARY} ${OPENSSL_CRYPTO_LIBRARY}) + set(OPENSSL_LIBRARIES ${OPENSSL_SSL_LIBRARY} ${OPENSSL_CRYPTO_LIBRARY} ${CMAKE_DL_LIBS}) endif() @@ -394,6 +394,13 @@ if(OPENSSL_FOUND) add_library(OpenSSL::Crypto UNKNOWN IMPORTED) set_target_properties(OpenSSL::Crypto PROPERTIES INTERFACE_INCLUDE_DIRECTORIES "${OPENSSL_INCLUDE_DIR}") + if(WIN32 AND NOT CYGWIN) + set_target_properties(OpenSSL::Crypto PROPERTIES + INTERFACE_LINK_LIBRARIES crypt32) + else() + set_target_properties(OpenSSL::Crypto PROPERTIES + INTERFACE_LINK_LIBRARIES "${CMAKE_DL_LIBS}") + endif() if(EXISTS "${OPENSSL_CRYPTO_LIBRARY}") set_target_properties(OpenSSL::Crypto PROPERTIES IMPORTED_LINK_INTERFACE_LANGUAGES "C" @@ -445,6 +452,12 @@ if(OPENSSL_FOUND) set_target_properties(OpenSSL::SSL PROPERTIES INTERFACE_LINK_LIBRARIES OpenSSL::Crypto) endif() + if(WIN32 AND NOT CYGWIN) + set_property(TARGET OpenSSL::SSL APPEND PROPERTY + INTERFACE_LINK_LIBRARIES crypt32) + else() + set_property(TARGET OpenSSL::SSL APPEND PROPERTY + INTERFACE_LINK_LIBRARIES "${CMAKE_DL_LIBS}") endif() endif() -- 2.9.2
-- Powered by www.kitware.com Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ Kitware offers various services to support the CMake community. For more information on each offering, please visit: CMake Support: http://cmake.org/cmake/help/support.html CMake Consulting: http://cmake.org/cmake/help/consulting.html CMake Training Courses: http://cmake.org/cmake/help/training.html Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html Follow this link to subscribe/unsubscribe: http://public.kitware.com/mailman/listinfo/cmake-developers