FindOpenSSL: We should only use hints to find OpenSSL.

This commit is contained in:
Andreas Schneider 2011-03-28 18:38:45 +02:00 committed by Brad King
parent 0fb5142e40
commit a164649f9d
1 changed files with 93 additions and 38 deletions

View File

@ -33,27 +33,32 @@ endif (UNIX)
# http://www.slproweb.com/products/Win32OpenSSL.html # http://www.slproweb.com/products/Win32OpenSSL.html
SET(_OPENSSL_ROOT_HINTS 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 (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]"
) )
SET(_OPENSSL_ROOT_PATHS SET(_OPENSSL_ROOT_PATHS
"$ENV{PROGRAMFILES}/OpenSSL"
"$ENV{PROGRAMFILES}/OpenSSL-Win32"
"$ENV{PROGRAMFILES}/OpenSSL-Win64"
"C:/OpenSSL/" "C:/OpenSSL/"
"C:/OpenSSL-Win32/"
"C:/OpenSSL-Win64/"
) )
FIND_PATH(OPENSSL_ROOT_DIR SET(_OPENSSL_ROOT_HINTS_AND_PATHS
NAMES include/openssl/ssl.h
HINTS ${_OPENSSL_ROOT_HINTS} HINTS ${_OPENSSL_ROOT_HINTS}
PATHS ${_OPENSSL_ROOT_PATHS} PATHS ${_OPENSSL_ROOT_PATHS}
ENV OPENSSL_ROOT_DIR
) )
MARK_AS_ADVANCED(OPENSSL_ROOT_DIR)
# Re-use the previous path:
FIND_PATH(OPENSSL_INCLUDE_DIR FIND_PATH(OPENSSL_INCLUDE_DIR
NAMES NAMES
openssl/ssl.h openssl/ssl.h
PATHS HINTS
${_OPENSSL_INCLUDEDIR} ${_OPENSSL_INCLUDEDIR}
${OPENSSL_ROOT_DIR}/include ${_OPENSSL_ROOT_HINTS_AND_PATHS}
PATH_SUFFIXES
include
) )
IF(WIN32 AND NOT CYGWIN) IF(WIN32 AND NOT CYGWIN)
@ -73,22 +78,52 @@ IF(WIN32 AND NOT CYGWIN)
# We are using the libraries located in the VC subdir instead of the parent directory eventhough : # We are using the libraries located in the VC subdir instead of the parent directory eventhough :
# libeay32MD.lib is identical to ../libeay32.lib, and # libeay32MD.lib is identical to ../libeay32.lib, and
# ssleay32MD.lib is identical to ../ssleay32.lib # ssleay32MD.lib is identical to ../ssleay32.lib
FIND_LIBRARY(LIB_EAY_DEBUG NAMES libeay32MDd libeay32 FIND_LIBRARY(LIB_EAY_DEBUG
PATHS ${OPENSSL_ROOT_DIR} NAMES
PATH_SUFFIXES "lib" "VC" "lib/VC" libeay32MDd
libeay32
${_OPENSSL_ROOT_HINTS_AND_PATHS}
PATH_SUFFIXES
"lib"
"VC"
"lib/VC"
) )
FIND_LIBRARY(LIB_EAY_RELEASE NAMES libeay32MD libeay32
PATHS ${OPENSSL_ROOT_DIR} FIND_LIBRARY(LIB_EAY_RELEASE
PATH_SUFFIXES "lib" "VC" "lib/VC" NAMES
libeay32MD
libeay32
${_OPENSSL_ROOT_HINTS_AND_PATHS}
PATH_SUFFIXES
"lib"
"VC"
"lib/VC"
) )
FIND_LIBRARY(SSL_EAY_DEBUG NAMES ssleay32MDd ssleay32 ssl
PATHS ${OPENSSL_ROOT_DIR} FIND_LIBRARY(SSL_EAY_DEBUG
PATH_SUFFIXES "lib" "VC" "lib/VC" NAMES
ssleay32MDd
ssleay32
ssl
${_OPENSSL_ROOT_HINTS_AND_PATHS}
PATH_SUFFIXES
"lib"
"VC"
"lib/VC"
) )
FIND_LIBRARY(SSL_EAY_RELEASE NAMES ssleay32MD ssleay32 ssl
PATHS ${OPENSSL_ROOT_DIR} FIND_LIBRARY(SSL_EAY_RELEASE
PATH_SUFFIXES "lib" "VC" "lib/VC" NAMES
ssleay32MD
ssleay32
ssl
${_OPENSSL_ROOT_HINTS_AND_PATHS}
PATH_SUFFIXES
"lib"
"VC"
"lib/VC"
) )
if( CMAKE_CONFIGURATION_TYPES OR CMAKE_BUILD_TYPE ) if( CMAKE_CONFIGURATION_TYPES OR CMAKE_BUILD_TYPE )
set( OPENSSL_LIBRARIES set( OPENSSL_LIBRARIES
optimized ${SSL_EAY_RELEASE} debug ${SSL_EAY_DEBUG} optimized ${SSL_EAY_RELEASE} debug ${SSL_EAY_DEBUG}
@ -101,14 +136,24 @@ IF(WIN32 AND NOT CYGWIN)
MARK_AS_ADVANCED(LIB_EAY_DEBUG LIB_EAY_RELEASE) MARK_AS_ADVANCED(LIB_EAY_DEBUG LIB_EAY_RELEASE)
ELSEIF(MINGW) ELSEIF(MINGW)
# same player, for MingW # same player, for MingW
FIND_LIBRARY(LIB_EAY NAMES libeay32 FIND_LIBRARY(LIB_EAY
PATHS ${OPENSSL_ROOT_DIR} NAMES
PATH_SUFFIXES "lib" "VC" "lib/MinGW" libeay32
${_OPENSSL_ROOT_HINTS_AND_PATHS}
PATH_SUFFIXES
"lib"
"lib/MinGW"
) )
FIND_LIBRARY(SSL_EAY NAMES ssleay32
PATHS ${OPENSSL_ROOT_DIR} FIND_LIBRARY(SSL_EAY
PATH_SUFFIXES "lib" "VC" "lib/MinGW" NAMES
ssleay32
${_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} ) set( OPENSSL_LIBRARIES ${SSL_EAY} ${LIB_EAY} )
ELSE(MSVC) ELSE(MSVC)
@ -116,17 +161,21 @@ IF(WIN32 AND NOT CYGWIN)
FIND_LIBRARY(LIB_EAY FIND_LIBRARY(LIB_EAY
NAMES NAMES
libeay32 libeay32
PATHS HINTS
${_OPENSSL_LIBDIR} ${_OPENSSL_LIBDIR}
${OPENSSL_ROOT_DIR}/lib ${_OPENSSL_ROOT_HINTS_AND_PATHS}
PATH_SUFFIXES
lib
) )
FIND_LIBRARY(SSL_EAY FIND_LIBRARY(SSL_EAY
NAMES NAMES
ssleay32 ssleay32
PATHS HINTS
${_OPENSSL_LIBDIR} ${_OPENSSL_LIBDIR}
${OPENSSL_ROOT_DIR}/lib ${_OPENSSL_ROOT_HINTS_AND_PATHS}
PATH_SUFFIXES
lib
) )
MARK_AS_ADVANCED(SSL_EAY LIB_EAY) MARK_AS_ADVANCED(SSL_EAY LIB_EAY)
@ -139,15 +188,21 @@ ELSE(WIN32 AND NOT CYGWIN)
ssl ssl
ssleay32 ssleay32
ssleay32MD ssleay32MD
PATHS HINTS
${_OPENSSL_LIBDIR} ${_OPENSSL_LIBDIR}
${_OPENSSL_ROOT_HINTS_AND_PATHS}
PATH_SUFFIXES
lib
) )
FIND_LIBRARY(OPENSSL_CRYPTO_LIBRARIES FIND_LIBRARY(OPENSSL_CRYPTO_LIBRARIES
NAMES NAMES
crypto crypto
PATHS HINTS
${_OPENSSL_LIBDIR} ${_OPENSSL_LIBDIR}
${_OPENSSL_ROOT_HINTS_AND_PATHS}
PATH_SUFFIXES
lib
) )
MARK_AS_ADVANCED(OPENSSL_CRYPTO_LIBRARIES OPENSSL_SSL_LIBRARIES) MARK_AS_ADVANCED(OPENSSL_CRYPTO_LIBRARIES OPENSSL_SSL_LIBRARIES)