[cmake-developers] Can't find correct openssl on Windows

Patrick Spendrin ps_ml at gmx.de
Fri Dec 18 19:49:13 EST 2015


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hi,

I have a small problem: when I try to search for my self-built
openssl, cmake always prefers the slproweb.com packages instead of my
own ones (even when setting OPENSSL_ROOT_DIR). This is due to the
different naming of the libraries in the slproweb installation:
There, you'll find ssleay32MD.lib vs. ssleay32.lib in my location.

I already opened a bug report for that:
https://public.kitware.com/Bug/view.php?id=15887

I attached a patch both here and at the bug report which fixes this
behaviour for the cost of having an additional and ugly option for the
FindOpenSSL.cmake file.
I don't see a different solution, as the no-MD/MT version of the
library is the backup solution (although the one I would prefer in
this case).

If you have any other idea, please let me know.

regards,
Patrick
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.21 (MingW32)

iQIcBAEBAgAGBQJWdKmJAAoJEPAKI6QtGt1xB60QAIyVhBdjiqT/yRKE2GsCTj2o
xdOKlyMJ8BozJB5KP34QndzVCpKEsC+rs8UStKjk7N0P5Qly3URuRTKG375wDXw1
3d1unxDfDUplTj/vCKjzKFD9lZxmACkJ9/9MHy7jhjWfYIxFUbxDMQvMWnzsSgSZ
daC0lxG65ggUBpYtA32TeM9GP2zB8ebAd6gSoDN+Iz3bJrl5cWvb1fom1nh0+2XV
fjGQ23yeraJGpzMF96siPXuk9XFoJvQfShIn2cBILjWHqr+NohlPayY6qQkFz4C5
Ock9aMwAYhhbVmJzFWho2A1+qFYGJq0fLnS1Qb/+uJg7GTtI8bC/PQynnbkt+q93
jP7UwlKzqFHUhlhkO7gmTZv8np3bxLUNYTblZvCED1iF4kdlzCwbeNfIqf5y4zev
ndInmEqvsODZwshcOqRFbX1nxq93/ZVUAaNy9ESlOBiL6xB2qHl+WOq4vNjZdh7w
Pav2UqiEpmyC/x8aFfafrkDDEY4pMf6J/s0U21M8QMXQXw/QErFF8pLGXszLFrqz
vJc+M3j45AZ9TLu86Uwekt6Z9WAtfXtfvQGaVH5bSicz7UBopjW5oX+U+3VO83Sa
0vwSmDNbOIo7YVmjtMc4d1xJwYWsbAQ1tXnfUgk66LGZStOHzjYWhUAFoAXZGOCV
S4jiUpisEtRhtJSOkNoG
=nozd
-----END PGP SIGNATURE-----
-------------- next part --------------
From 9fd1bfa174a8c8a5e63d875492ed01e7df34d1d7 Mon Sep 17 00:00:00 2001
From: Patrick Spendrin <ps_ml at gmx.de>
Date: Sat, 19 Dec 2015 01:16:15 +0100
Subject: [PATCH] Make it possible to ignore slproweb OpenSSL

slproweb binary installations are found by default and their file
naming convention is preferred over the ones openssl generates by
default (without MD/MT).
This change makes it possible to only find libraries without MD/MT
by setting OPENSSL_MSVC_NO_RT_MODE=TRUE
---
 Modules/FindOpenSSL.cmake | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/Modules/FindOpenSSL.cmake b/Modules/FindOpenSSL.cmake
index 8b4b988..c78896b 100644
--- a/Modules/FindOpenSSL.cmake
+++ b/Modules/FindOpenSSL.cmake
@@ -38,6 +38,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.
+# Set ``OPENSSL_MSVC_NO_RT_MODE`` set ``TRUE`` to use libraries without MD / MT in their name.
 
 #=============================================================================
 # Copyright 2006-2009 Kitware, Inc.
@@ -108,7 +109,6 @@ find_path(OPENSSL_INCLUDE_DIR
   PATH_SUFFIXES
     include
 )
-
 if(WIN32 AND NOT CYGWIN)
   if(MSVC)
     # /MD and /MDd are the standard values - if someone wants to use
@@ -127,10 +127,14 @@ 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")
+    if (NOT OPENSSL_MSVC_NO_RT_MODE)
+      if (OPENSSL_MSVC_STATIC_RT)
+        set(_OPENSSL_MSVC_RT_MODE "MT")
+      else ()
+        set(_OPENSSL_MSVC_RT_MODE "MD")
+      endif ()
     else ()
-      set(_OPENSSL_MSVC_RT_MODE "MD")
+      set(_OPENSSL_MSVC_RT_MODE "")
     endif ()
 
     if(OPENSSL_USE_STATIC_LIBS)
-- 
2.6.3.windows.1

-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-Make-it-possible-to-ignore-slproweb-OpenSSL.patch.sig
Type: application/octet-stream
Size: 543 bytes
Desc: not available
URL: <http://public.kitware.com/pipermail/cmake-developers/attachments/20151219/478a567e/attachment.obj>


More information about the cmake-developers mailing list