summaryrefslogtreecommitdiff
path: root/Modules/FindOpenSSL.cmake
diff options
context:
space:
mode:
Diffstat (limited to 'Modules/FindOpenSSL.cmake')
-rw-r--r--Modules/FindOpenSSL.cmake151
1 files changed, 83 insertions, 68 deletions
diff --git a/Modules/FindOpenSSL.cmake b/Modules/FindOpenSSL.cmake
index d1fc2d2..224c88e 100644
--- a/Modules/FindOpenSSL.cmake
+++ b/Modules/FindOpenSSL.cmake
@@ -27,29 +27,38 @@
if (UNIX)
find_package(PkgConfig QUIET)
pkg_check_modules(_OPENSSL QUIET openssl)
-endif (UNIX)
-
-# http://www.slproweb.com/products/Win32OpenSSL.html
-SET(_OPENSSL_ROOT_HINTS
- $ENV{OPENSSL_ROOT_DIR}
- ${OPENSSL_ROOT_DIR}
- "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\OpenSSL (32-bit)_is1;Inno Setup: App Path]"
- "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\OpenSSL (64-bit)_is1;Inno Setup: App Path]"
- )
-SET(_OPENSSL_ROOT_PATHS
- "$ENV{PROGRAMFILES}/OpenSSL"
- "$ENV{PROGRAMFILES}/OpenSSL-Win32"
- "$ENV{PROGRAMFILES}/OpenSSL-Win64"
- "C:/OpenSSL/"
- "C:/OpenSSL-Win32/"
- "C:/OpenSSL-Win64/"
- )
-SET(_OPENSSL_ROOT_HINTS_AND_PATHS
- HINTS ${_OPENSSL_ROOT_HINTS}
- PATHS ${_OPENSSL_ROOT_PATHS}
- )
+endif ()
+
+if (WIN32)
+ # http://www.slproweb.com/products/Win32OpenSSL.html
+ set(_OPENSSL_ROOT_HINTS
+ ${OPENSSL_ROOT_DIR}
+ "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\OpenSSL (32-bit)_is1;Inno Setup: App Path]"
+ "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\OpenSSL (64-bit)_is1;Inno Setup: App Path]"
+ ENV OPENSSL_ROOT_DIR
+ )
+ file(TO_CMAKE_PATH "$ENV{PROGRAMFILES}" _programfiles)
+ set(_OPENSSL_ROOT_PATHS
+ "${_programfiles}/OpenSSL"
+ "${_programfiles}/OpenSSL-Win32"
+ "${_programfiles}/OpenSSL-Win64"
+ "C:/OpenSSL/"
+ "C:/OpenSSL-Win32/"
+ "C:/OpenSSL-Win64/"
+ )
+ unset(_programfiles)
+ set(_OPENSSL_ROOT_HINTS_AND_PATHS
+ HINTS ${_OPENSSL_ROOT_HINTS}
+ PATHS ${_OPENSSL_ROOT_PATHS}
+ )
+else ()
+ set(_OPENSSL_ROOT_HINTS
+ ${OPENSSL_ROOT_DIR}
+ ENV OPENSSL_ROOT_DIR
+ )
+endif ()
-FIND_PATH(OPENSSL_INCLUDE_DIR
+find_path(OPENSSL_INCLUDE_DIR
NAMES
openssl/ssl.h
HINTS
@@ -59,9 +68,8 @@ FIND_PATH(OPENSSL_INCLUDE_DIR
include
)
-IF(WIN32 AND NOT CYGWIN)
- # MINGW should go here too
- IF(MSVC)
+if(WIN32 AND NOT CYGWIN)
+ if(MSVC)
# /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
@@ -76,10 +84,10 @@ IF(WIN32 AND NOT CYGWIN)
# We are using the libraries located in the VC subdir instead of the parent directory eventhough :
# libeay32MD.lib is identical to ../libeay32.lib, and
# ssleay32MD.lib is identical to ../ssleay32.lib
- FIND_LIBRARY(LIB_EAY_DEBUG
+ find_library(LIB_EAY_DEBUG
NAMES
libeay32MDd
- libeay32
+ libeay32d
${_OPENSSL_ROOT_HINTS_AND_PATHS}
PATH_SUFFIXES
"lib"
@@ -87,7 +95,7 @@ IF(WIN32 AND NOT CYGWIN)
"lib/VC"
)
- FIND_LIBRARY(LIB_EAY_RELEASE
+ find_library(LIB_EAY_RELEASE
NAMES
libeay32MD
libeay32
@@ -98,11 +106,10 @@ IF(WIN32 AND NOT CYGWIN)
"lib/VC"
)
- FIND_LIBRARY(SSL_EAY_DEBUG
+ find_library(SSL_EAY_DEBUG
NAMES
ssleay32MDd
- ssleay32
- ssl
+ ssleay32d
${_OPENSSL_ROOT_HINTS_AND_PATHS}
PATH_SUFFIXES
"lib"
@@ -110,7 +117,7 @@ IF(WIN32 AND NOT CYGWIN)
"lib/VC"
)
- FIND_LIBRARY(SSL_EAY_RELEASE
+ find_library(SSL_EAY_RELEASE
NAMES
ssleay32MD
ssleay32
@@ -122,41 +129,49 @@ IF(WIN32 AND NOT CYGWIN)
"lib/VC"
)
- if( CMAKE_CONFIGURATION_TYPES OR CMAKE_BUILD_TYPE )
- set( OPENSSL_LIBRARIES
- optimized ${SSL_EAY_RELEASE} debug ${SSL_EAY_DEBUG}
- optimized ${LIB_EAY_RELEASE} debug ${LIB_EAY_DEBUG}
- )
- else()
- set( OPENSSL_LIBRARIES ${SSL_EAY_RELEASE} ${LIB_EAY_RELEASE} )
- endif()
- MARK_AS_ADVANCED(SSL_EAY_DEBUG SSL_EAY_RELEASE)
- MARK_AS_ADVANCED(LIB_EAY_DEBUG LIB_EAY_RELEASE)
- ELSEIF(MINGW)
+ set(LIB_EAY_LIBRARY_DEBUG "${LIB_EAY_DEBUG}")
+ set(LIB_EAY_LIBRARY_RELEASE "${LIB_EAY_RELEASE}")
+ set(SSL_EAY_LIBRARY_DEBUG "${SSL_EAY_DEBUG}")
+ set(SSL_EAY_LIBRARY_RELEASE "${SSL_EAY_RELEASE}")
+
+ include(${CMAKE_CURRENT_LIST_DIR}/SelectLibraryConfigurations.cmake)
+ select_library_configurations(LIB_EAY)
+ select_library_configurations(SSL_EAY)
+
+ set( OPENSSL_LIBRARIES ${SSL_EAY_LIBRARY} ${LIB_EAY_LIBRARY} )
+ elseif(MINGW)
# same player, for MingW
- FIND_LIBRARY(LIB_EAY
+ set(LIB_EAY_NAMES libeay32)
+ set(SSL_EAY_NAMES ssleay32)
+ if(CMAKE_CROSS_COMPILING)
+ list(APPEND LIB_EAY_NAMES crypto)
+ list(APPEND SSL_EAY_NAMES ssl)
+ endif()
+ find_library(LIB_EAY
NAMES
- libeay32
+ ${LIB_EAY_NAMES}
${_OPENSSL_ROOT_HINTS_AND_PATHS}
PATH_SUFFIXES
"lib"
"lib/MinGW"
)
- FIND_LIBRARY(SSL_EAY
+ find_library(SSL_EAY
NAMES
- ssleay32
+ ${SSL_EAY_NAMES}
${_OPENSSL_ROOT_HINTS_AND_PATHS}
PATH_SUFFIXES
"lib"
"lib/MinGW"
)
- MARK_AS_ADVANCED(SSL_EAY LIB_EAY)
+ mark_as_advanced(SSL_EAY LIB_EAY)
set( OPENSSL_LIBRARIES ${SSL_EAY} ${LIB_EAY} )
- ELSE(MSVC)
+ unset(LIB_EAY_NAMES)
+ unset(SSL_EAY_NAMES)
+ else()
# Not sure what to pick for -say- intel, let's use the toplevel ones and hope someone report issues:
- FIND_LIBRARY(LIB_EAY
+ find_library(LIB_EAY
NAMES
libeay32
HINTS
@@ -166,7 +181,7 @@ IF(WIN32 AND NOT CYGWIN)
lib
)
- FIND_LIBRARY(SSL_EAY
+ find_library(SSL_EAY
NAMES
ssleay32
HINTS
@@ -176,12 +191,12 @@ IF(WIN32 AND NOT CYGWIN)
lib
)
- MARK_AS_ADVANCED(SSL_EAY LIB_EAY)
+ mark_as_advanced(SSL_EAY LIB_EAY)
set( OPENSSL_LIBRARIES ${SSL_EAY} ${LIB_EAY} )
- ENDIF(MSVC)
-ELSE(WIN32 AND NOT CYGWIN)
+ endif()
+else()
- FIND_LIBRARY(OPENSSL_SSL_LIBRARY
+ find_library(OPENSSL_SSL_LIBRARY
NAMES
ssl
ssleay32
@@ -193,7 +208,7 @@ ELSE(WIN32 AND NOT CYGWIN)
lib
)
- FIND_LIBRARY(OPENSSL_CRYPTO_LIBRARY
+ find_library(OPENSSL_CRYPTO_LIBRARY
NAMES
crypto
HINTS
@@ -203,15 +218,15 @@ ELSE(WIN32 AND NOT CYGWIN)
lib
)
- MARK_AS_ADVANCED(OPENSSL_CRYPTO_LIBRARY OPENSSL_SSL_LIBRARY)
+ 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})
+ set(OPENSSL_CRYPTO_LIBRARIES ${OPENSSL_CRYPTO_LIBRARY})
- SET(OPENSSL_LIBRARIES ${OPENSSL_SSL_LIBRARY} ${OPENSSL_CRYPTO_LIBRARY})
+ set(OPENSSL_LIBRARIES ${OPENSSL_SSL_LIBRARY} ${OPENSSL_CRYPTO_LIBRARY})
-ENDIF(WIN32 AND NOT CYGWIN)
+endif()
function(from_hex HEX DEC)
string(TOUPPER "${HEX}" HEX)
@@ -242,7 +257,7 @@ function(from_hex HEX DEC)
endwhile()
set(${DEC} ${_res} PARENT_SCOPE)
-endfunction(from_hex)
+endfunction()
if (OPENSSL_INCLUDE_DIR)
if (_OPENSSL_VERSION)
@@ -276,11 +291,11 @@ if (OPENSSL_INCLUDE_DIR)
# this should be updated to handle that, too. This has not happened yet
# so it is simply ignored here for now.
string(ASCII "${OPENSSL_VERSION_PATCH_ASCII}" OPENSSL_VERSION_PATCH_STRING)
- endif (NOT OPENSSL_VERSION_PATCH STREQUAL "00")
+ endif ()
set(OPENSSL_VERSION "${OPENSSL_VERSION_MAJOR}.${OPENSSL_VERSION_MINOR}.${OPENSSL_VERSION_FIX}${OPENSSL_VERSION_PATCH_STRING}")
- endif (_OPENSSL_VERSION)
-endif (OPENSSL_INCLUDE_DIR)
+ endif ()
+endif ()
include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake)
@@ -294,11 +309,11 @@ if (OPENSSL_VERSION)
FAIL_MESSAGE
"Could NOT find OpenSSL, try to set the path to OpenSSL root folder in the system variable OPENSSL_ROOT_DIR"
)
-else (OPENSSL_VERSION)
+else ()
find_package_handle_standard_args(OpenSSL "Could NOT find OpenSSL, try to set the path to OpenSSL root folder in the system variable OPENSSL_ROOT_DIR"
OPENSSL_LIBRARIES
OPENSSL_INCLUDE_DIR
)
-endif (OPENSSL_VERSION)
+endif ()
-MARK_AS_ADVANCED(OPENSSL_INCLUDE_DIR OPENSSL_LIBRARIES)
+mark_as_advanced(OPENSSL_INCLUDE_DIR OPENSSL_LIBRARIES)