From 821e17785ecd4a329842dc6c5b093eb30cc4f160 Mon Sep 17 00:00:00 2001 From: Thijs Wenker Date: Thu, 1 Oct 2015 16:41:58 +0200 Subject: [PATCH] FindOpenSSL: Add support for static MSVC runtime Add an OPENSSL_MSVC_STATIC_RT option to switch from the default search for `/MD` libraries to look for `/MT` libraries instead. --- Help/release/dev/FindOpenSSL-msvc-static-rt.rst | 6 ++++++ Modules/FindOpenSSL.cmake | 17 ++++++++++++----- 2 files changed, 18 insertions(+), 5 deletions(-) create mode 100644 Help/release/dev/FindOpenSSL-msvc-static-rt.rst diff --git a/Help/release/dev/FindOpenSSL-msvc-static-rt.rst b/Help/release/dev/FindOpenSSL-msvc-static-rt.rst new file mode 100644 index 000000000..6e0ee276c --- /dev/null +++ b/Help/release/dev/FindOpenSSL-msvc-static-rt.rst @@ -0,0 +1,6 @@ +FindOpenSSL-msvc-static-rt +-------------------------- + +* The :module:`FindOpenSSL` module gained a new + ``OPENSSL_MSVC_STATIC_RT`` option to search for libraries using + the MSVC static runtime. diff --git a/Modules/FindOpenSSL.cmake b/Modules/FindOpenSSL.cmake index d75e8ab25..a0f4c524b 100644 --- a/Modules/FindOpenSSL.cmake +++ b/Modules/FindOpenSSL.cmake @@ -37,6 +37,7 @@ # # Set ``OPENSSL_ROOT_DIR`` to the root directory of an OpenSSL installation. # Set ``OPENSSL_USE_STATIC_LIBS`` to ``TRUE`` to look for static libraries. +# Set ``OPENSSL_MSVC_STATIC_RT`` set ``TRUE`` to choose the MT version of the lib. #============================================================================= # Copyright 2006-2009 Kitware, Inc. @@ -113,7 +114,7 @@ if(WIN32 AND NOT CYGWIN) # /MD and /MDd are the standard values - if someone wants to use # others, the libnames have to change here too # use also ssl and ssleay32 in debug as fallback for openssl < 0.9.8b - # TODO: handle /MT and static lib + # enable OPENSSL_MSVC_STATIC_RT to get the libs build /MT (Multithreaded no-DLL) # In Visual C++ naming convention each of these four kinds of Windows libraries has it's standard suffix: # * MD for dynamic-release # * MDd for dynamic-debug @@ -126,6 +127,12 @@ if(WIN32 AND NOT CYGWIN) # ssleay32MD.lib is identical to ../ssleay32.lib # enable OPENSSL_USE_STATIC_LIBS to use the static libs located in lib/VC/static + if (OPENSSL_MSVC_STATIC_RT) + set(_OPENSSL_MSVC_RT_MODE "MT") + else () + set(_OPENSSL_MSVC_RT_MODE "MD") + endif () + if(OPENSSL_USE_STATIC_LIBS) set(_OPENSSL_PATH_SUFFIXES "lib" @@ -142,7 +149,7 @@ if(WIN32 AND NOT CYGWIN) find_library(LIB_EAY_DEBUG NAMES - libeay32MDd + libeay32${_OPENSSL_MSVC_RT_MODE}d libeay32d ${_OPENSSL_ROOT_HINTS_AND_PATHS} PATH_SUFFIXES @@ -151,7 +158,7 @@ if(WIN32 AND NOT CYGWIN) find_library(LIB_EAY_RELEASE NAMES - libeay32MD + libeay32${_OPENSSL_MSVC_RT_MODE} libeay32 ${_OPENSSL_ROOT_HINTS_AND_PATHS} PATH_SUFFIXES @@ -160,7 +167,7 @@ if(WIN32 AND NOT CYGWIN) find_library(SSL_EAY_DEBUG NAMES - ssleay32MDd + ssleay32${_OPENSSL_MSVC_RT_MODE}d ssleay32d ${_OPENSSL_ROOT_HINTS_AND_PATHS} PATH_SUFFIXES @@ -169,7 +176,7 @@ if(WIN32 AND NOT CYGWIN) find_library(SSL_EAY_RELEASE NAMES - ssleay32MD + ssleay32${_OPENSSL_MSVC_RT_MODE} ssleay32 ssl ${_OPENSSL_ROOT_HINTS_AND_PATHS}