1 # - Try to find the OpenSSL encryption library
2 # Once done this will define
4 # OPENSSL_FOUND - system has the OpenSSL library
5 # OPENSSL_INCLUDE_DIR - the OpenSSL include directory
6 # OPENSSL_LIBRARIES - The libraries needed to use OpenSSL
8 # Copyright (c) 2006, Alexander Neundorf, <neundorf@kde.org>
10 # Redistribution and use is allowed according to the terms of the BSD license.
11 # For details see the accompanying COPYING-CMAKE-SCRIPTS file.
15 SET(OpenSSL_FIND_QUIETLY TRUE)
16 ENDIF(OPENSSL_LIBRARIES)
18 IF(SSL_EAY_DEBUG AND SSL_EAY_RELEASE)
20 ENDIF(SSL_EAY_DEBUG AND SSL_EAY_RELEASE)
22 FIND_PATH(OPENSSL_INCLUDE_DIR openssl/ssl.h )
25 # /MD and /MDd are the standard values - if somone wants to use
26 # others, the libnames have to change here too
27 # use also ssl and ssleay32 in debug as fallback for openssl < 0.9.8b
29 FIND_LIBRARY(SSL_EAY_DEBUG NAMES ssleay32MDd ssl ssleay32)
30 FIND_LIBRARY(SSL_EAY_RELEASE NAMES ssleay32MD ssl ssleay32)
33 IF(SSL_EAY_DEBUG AND SSL_EAY_RELEASE)
34 SET(OPENSSL_LIBRARIES optimized ${SSL_EAY_RELEASE} debug ${SSL_EAY_DEBUG})
35 ELSE(SSL_EAY_DEBUG AND SSL_EAY_RELEASE)
36 SET(OPENSSL_LIBRARIES NOTFOUND)
37 MESSAGE(STATUS "Could not find the debug and release version of openssl")
38 ENDIF(SSL_EAY_DEBUG AND SSL_EAY_RELEASE)
40 STRING(TOLOWER ${CMAKE_BUILD_TYPE} CMAKE_BUILD_TYPE_TOLOWER)
41 IF(CMAKE_BUILD_TYPE_TOLOWER MATCHES debug)
42 SET(OPENSSL_LIBRARIES ${SSL_EAY_DEBUG})
43 ELSE(CMAKE_BUILD_TYPE_TOLOWER MATCHES debug)
44 SET(OPENSSL_LIBRARIES ${SSL_EAY_RELEASE})
45 ENDIF(CMAKE_BUILD_TYPE_TOLOWER MATCHES debug)
47 MARK_AS_ADVANCED(SSL_EAY_DEBUG SSL_EAY_RELEASE)
50 FIND_LIBRARY(OPENSSL_LIBRARIES NAMES ssl ssleay32 ssleay32MD )
54 IF(OPENSSL_INCLUDE_DIR AND OPENSSL_LIBRARIES)
55 SET(OPENSSL_FOUND TRUE)
56 ELSE(OPENSSL_INCLUDE_DIR AND OPENSSL_LIBRARIES)
57 SET(OPENSSL_FOUND FALSE)
58 ENDIF (OPENSSL_INCLUDE_DIR AND OPENSSL_LIBRARIES)
61 IF (NOT OpenSSL_FIND_QUIETLY)
62 MESSAGE(STATUS "Found OpenSSL: ${OPENSSL_LIBRARIES}")
63 ENDIF (NOT OpenSSL_FIND_QUIETLY)
65 IF (OpenSSL_FIND_REQUIRED)
66 MESSAGE(FATAL_ERROR "Could NOT find OpenSSL")
67 ENDIF (OpenSSL_FIND_REQUIRED)
70 MARK_AS_ADVANCED(OPENSSL_INCLUDE_DIR OPENSSL_LIBRARIES)