More changes to the build system; make i18n generation nicer
[quassel.git] / cmake / modules / FindOpenSSL.cmake
1 # - Try to find the OpenSSL encryption library
2 # Once done this will define
3 #
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
7 #  OPENSSL_EAY_LIBRARIES - The additional libraries needed to use OpenSSL on windows
8
9 # Copyright (c) 2006, Alexander Neundorf, <neundorf@kde.org>
10 #
11 # Redistribution and use is allowed according to the terms of the BSD license.
12 # For details see the accompanying COPYING-CMAKE-SCRIPTS file.
13
14 INCLUDE(FindLibraryWithDebug)
15
16 # on win32 we additional need to link to libeay32.lib
17 MACRO(OPENSSL_ADD_LIB_EAY_LIBS)
18    FIND_LIBRARY_WITH_DEBUG(OPENSSL_EAY_LIBRARIES
19                    WIN32_DEBUG_POSTFIX d
20                    NAMES eay libeay libeay32 libeay32MD)
21 ENDMACRO(OPENSSL_ADD_LIB_EAY_LIBS)
22
23 IF(OPENSSL_LIBRARIES)
24    SET(OpenSSL_FIND_QUIETLY TRUE)
25 ENDIF(OPENSSL_LIBRARIES)
26
27 IF(SSL_EAY_DEBUG AND SSL_EAY_RELEASE)
28    SET(LIB_FOUND 1)
29 ENDIF(SSL_EAY_DEBUG AND SSL_EAY_RELEASE)
30
31 FIND_PATH(OPENSSL_INCLUDE_DIR openssl/ssl.h )
32
33 FIND_LIBRARY_WITH_DEBUG(OPENSSL_LIBRARIES
34                 WIN32_DEBUG_POSTFIX d
35                 NAMES ssl ssleay ssleay32 ssleay32MD)
36
37 IF(WIN32)
38    OPENSSL_ADD_LIB_EAY_LIBS()
39    IF(OPENSSL_INCLUDE_DIR AND OPENSSL_LIBRARIES AND OPENSSL_EAY_LIBRARIES)
40       SET(OPENSSL_FOUND TRUE)
41    ELSE(OPENSSL_INCLUDE_DIR AND OPENSSL_LIBRARIES AND OPENSSL_EAY_LIBRARIES)
42       SET(OPENSSL_FOUND FALSE)
43    ENDIF (OPENSSL_INCLUDE_DIR AND OPENSSL_LIBRARIES AND OPENSSL_EAY_LIBRARIES)
44 ELSE(WIN32)
45    IF(OPENSSL_INCLUDE_DIR AND OPENSSL_LIBRARIES)
46       SET(OPENSSL_FOUND TRUE)
47    ELSE(OPENSSL_INCLUDE_DIR AND OPENSSL_LIBRARIES)
48       SET(OPENSSL_FOUND FALSE)
49    ENDIF (OPENSSL_INCLUDE_DIR AND OPENSSL_LIBRARIES)
50 ENDIF(WIN32)
51
52 IF (OPENSSL_FOUND)
53    IF (NOT OpenSSL_FIND_QUIETLY)
54       MESSAGE(STATUS "Found OpenSSL: ${OPENSSL_LIBRARIES}")
55    ENDIF (NOT OpenSSL_FIND_QUIETLY)
56 ELSE (OPENSSL_FOUND)
57    IF (OpenSSL_FIND_REQUIRED)
58       MESSAGE(FATAL_ERROR "Could NOT find OpenSSL")
59    ENDIF (OpenSSL_FIND_REQUIRED)
60 ENDIF (OPENSSL_FOUND)
61
62 MARK_AS_ADVANCED(OPENSSL_INCLUDE_DIR OPENSSL_LIBRARIES)
63