From eace9b44ec04d0743f3e8c8cb7675b9acff703c7 Mon Sep 17 00:00:00 2001 From: Martchus Date: Tue, 6 Jul 2021 19:55:11 +0200 Subject: [PATCH] Fix linking statically against OpenSSL MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit `set(… PARENT_SCOPE)` leaves the current scope unaffected so appending the static dependencies removed the OpenSSL libs themselves again. --- cmake/modules/3rdParty.cmake | 32 +++++++++++++++----------------- 1 file changed, 15 insertions(+), 17 deletions(-) diff --git a/cmake/modules/3rdParty.cmake b/cmake/modules/3rdParty.cmake index d6aa9cf..2d71108 100644 --- a/cmake/modules/3rdParty.cmake +++ b/cmake/modules/3rdParty.cmake @@ -164,18 +164,17 @@ function (use_openssl) return() endif () message(STATUS "Found OpenSSL") - set("${ARGS_LIBRARIES_VARIABLE}" - "${${ARGS_LIBRARIES_VARIABLE}};OpenSSL::SSL;OpenSSL::Crypto" - PARENT_SCOPE) + set("${ARGS_LIBRARIES_VARIABLE}" "${${ARGS_LIBRARIES_VARIABLE}};OpenSSL::SSL;OpenSSL::Crypto") + if (WIN32 AND OPENSSL_USE_STATIC_LIBS) + # FIXME: preferably use pkg-config to cover this case without hardcoding OpenSSL's dependencies under Windows + set("${ARGS_LIBRARIES_VARIABLE}" "${${ARGS_LIBRARIES_VARIABLE}};-lws2_32;-lgdi32;-lcrypt32") + endif () set("${ARGS_PACKAGES_VARIABLE}" "${${ARGS_PACKAGES_VARIABLE}};OpenSSL" PARENT_SCOPE) - if (WIN32 AND OPENSSL_USE_STATIC_LIBS) - # FIXME: preferably use pkg-config to cover this case without hardcoding OpenSSL's dependencies under Windows - set("${ARGS_LIBRARIES_VARIABLE}" - "${${ARGS_LIBRARIES_VARIABLE}};-lws2_32;-lgdi32;-lcrypt32" - PARENT_SCOPE) - endif () + set("${ARGS_LIBRARIES_VARIABLE}" + "${${ARGS_LIBRARIES_VARIABLE}}" + PARENT_SCOPE) set("PKG_CONFIG_OpenSSL_SSL" "libssl" PARENT_SCOPE) @@ -197,17 +196,16 @@ function (use_crypto) return() endif () message(STATUS "Found OpenSSL") - set("${ARGS_LIBRARIES_VARIABLE}" - "${${ARGS_LIBRARIES_VARIABLE}};OpenSSL::Crypto" - PARENT_SCOPE) + set("${ARGS_LIBRARIES_VARIABLE}" "${${ARGS_LIBRARIES_VARIABLE}};OpenSSL::Crypto") + if (WIN32 AND OPENSSL_USE_STATIC_LIBS) + set("${ARGS_LIBRARIES_VARIABLE}" "${${ARGS_LIBRARIES_VARIABLE}};-lws2_32;-lgdi32;-lcrypt32") + endif () set("${ARGS_PACKAGES_VARIABLE}" "${${ARGS_PACKAGES_VARIABLE}};OpenSSL" PARENT_SCOPE) - if (WIN32 AND OPENSSL_USE_STATIC_LIBS) - set("${ARGS_LIBRARIES_VARIABLE}" - "${${ARGS_LIBRARIES_VARIABLE}};OpenSSL::Crypto;-lws2_32;-lgdi32;-lcrypt32" - PARENT_SCOPE) - endif () + set("${ARGS_LIBRARIES_VARIABLE}" + "${${ARGS_LIBRARIES_VARIABLE}}" + PARENT_SCOPE) set("PKG_CONFIG_OpenSSL_Crypto" "libcrypto" PARENT_SCOPE)