Merge topic 'FindOpenSSL-improve'

3cfb68d FindOpenSSL: remove leftover comment
fc798ed FindOpenSSL: cleanup path hints
c78a7d1 FindOpenSSL: let CMake handle environment variable HINTS
7464519 FindOpenSSL: use SelectLibraryConfigurations
4b793ad FindOpenSSL: find cross-compiled OpenSSL from MinGW (#13431)
This commit is contained in:
David Cole 2012-08-13 13:27:31 -04:00 committed by CMake Topic Stage
commit 11a9ea35de
1 changed files with 43 additions and 35 deletions

View File

@ -29,25 +29,34 @@ if (UNIX)
pkg_check_modules(_OPENSSL QUIET openssl) pkg_check_modules(_OPENSSL QUIET openssl)
endif (UNIX) endif (UNIX)
# http://www.slproweb.com/products/Win32OpenSSL.html IF (WIN32)
SET(_OPENSSL_ROOT_HINTS # http://www.slproweb.com/products/Win32OpenSSL.html
$ENV{OPENSSL_ROOT_DIR} SET(_OPENSSL_ROOT_HINTS
${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 (32-bit)_is1;Inno Setup: App Path]"
"[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\OpenSSL (64-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
SET(_OPENSSL_ROOT_PATHS )
"$ENV{PROGRAMFILES}/OpenSSL" FILE(TO_CMAKE_PATH "$ENV{PROGRAMFILES}" _programfiles)
"$ENV{PROGRAMFILES}/OpenSSL-Win32" SET(_OPENSSL_ROOT_PATHS
"$ENV{PROGRAMFILES}/OpenSSL-Win64" "${_programfiles}/OpenSSL"
"C:/OpenSSL/" "${_programfiles}/OpenSSL-Win32"
"C:/OpenSSL-Win32/" "${_programfiles}/OpenSSL-Win64"
"C:/OpenSSL-Win64/" "C:/OpenSSL/"
) "C:/OpenSSL-Win32/"
SET(_OPENSSL_ROOT_HINTS_AND_PATHS "C:/OpenSSL-Win64/"
HINTS ${_OPENSSL_ROOT_HINTS} )
PATHS ${_OPENSSL_ROOT_PATHS} 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 NAMES
@ -60,7 +69,6 @@ FIND_PATH(OPENSSL_INCLUDE_DIR
) )
IF(WIN32 AND NOT CYGWIN) IF(WIN32 AND NOT CYGWIN)
# MINGW should go here too
IF(MSVC) IF(MSVC)
# /MD and /MDd are the standard values - if someone wants to use # /MD and /MDd are the standard values - if someone wants to use
# others, the libnames have to change here too # others, the libnames have to change here too
@ -79,7 +87,6 @@ IF(WIN32 AND NOT CYGWIN)
FIND_LIBRARY(LIB_EAY_DEBUG FIND_LIBRARY(LIB_EAY_DEBUG
NAMES NAMES
libeay32MDd libeay32MDd
libeay32
${_OPENSSL_ROOT_HINTS_AND_PATHS} ${_OPENSSL_ROOT_HINTS_AND_PATHS}
PATH_SUFFIXES PATH_SUFFIXES
"lib" "lib"
@ -101,8 +108,6 @@ IF(WIN32 AND NOT CYGWIN)
FIND_LIBRARY(SSL_EAY_DEBUG FIND_LIBRARY(SSL_EAY_DEBUG
NAMES NAMES
ssleay32MDd ssleay32MDd
ssleay32
ssl
${_OPENSSL_ROOT_HINTS_AND_PATHS} ${_OPENSSL_ROOT_HINTS_AND_PATHS}
PATH_SUFFIXES PATH_SUFFIXES
"lib" "lib"
@ -122,21 +127,22 @@ IF(WIN32 AND NOT CYGWIN)
"lib/VC" "lib/VC"
) )
if( CMAKE_CONFIGURATION_TYPES OR CMAKE_BUILD_TYPE ) include(${CMAKE_CURRENT_LIST_DIR}/SelectLibraryConfigurations.cmake)
set( OPENSSL_LIBRARIES select_library_configurations(LIB_EAY)
optimized ${SSL_EAY_RELEASE} debug ${SSL_EAY_DEBUG} select_library_configurations(SSL_EAY)
optimized ${LIB_EAY_RELEASE} debug ${LIB_EAY_DEBUG}
) set( OPENSSL_LIBRARIES ${SSL_EAY_LIBRARY} ${LIB_EAY_LIBRARY} )
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) ELSEIF(MINGW)
# same player, for MingW # same player, for MingW
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 FIND_LIBRARY(LIB_EAY
NAMES NAMES
libeay32 ${LIB_EAY_NAMES}
${_OPENSSL_ROOT_HINTS_AND_PATHS} ${_OPENSSL_ROOT_HINTS_AND_PATHS}
PATH_SUFFIXES PATH_SUFFIXES
"lib" "lib"
@ -145,7 +151,7 @@ IF(WIN32 AND NOT CYGWIN)
FIND_LIBRARY(SSL_EAY FIND_LIBRARY(SSL_EAY
NAMES NAMES
ssleay32 ${SSL_EAY_NAMES}
${_OPENSSL_ROOT_HINTS_AND_PATHS} ${_OPENSSL_ROOT_HINTS_AND_PATHS}
PATH_SUFFIXES PATH_SUFFIXES
"lib" "lib"
@ -154,6 +160,8 @@ IF(WIN32 AND NOT CYGWIN)
MARK_AS_ADVANCED(SSL_EAY LIB_EAY) MARK_AS_ADVANCED(SSL_EAY LIB_EAY)
set( OPENSSL_LIBRARIES ${SSL_EAY} ${LIB_EAY} ) set( OPENSSL_LIBRARIES ${SSL_EAY} ${LIB_EAY} )
unset(LIB_EAY_NAMES)
unset(SSL_EAY_NAMES)
ELSE(MSVC) ELSE(MSVC)
# Not sure what to pick for -say- intel, let's use the toplevel ones and hope someone report issues: # 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