FindOpenSSL.cmake 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  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. # Copyright (c) 2006, Alexander Neundorf, <[email protected]>
  8. #
  9. # Redistribution and use is allowed according to the terms of the BSD license.
  10. # For details see the accompanying COPYING-CMAKE-SCRIPTS file.
  11. IF(OPENSSL_LIBRARIES)
  12. SET(OpenSSL_FIND_QUIETLY TRUE)
  13. ENDIF(OPENSSL_LIBRARIES)
  14. IF(SSL_EAY_DEBUG AND SSL_EAY_RELEASE)
  15. SET(LIB_FOUND 1)
  16. ENDIF(SSL_EAY_DEBUG AND SSL_EAY_RELEASE)
  17. FIND_PATH(OPENSSL_INCLUDE_DIR openssl/ssl.h )
  18. IF(WIN32 AND MSVC)
  19. # /MD and /MDd are the standard values - if somone wants to use
  20. # others, the libnames have to change here too
  21. # use also ssl and ssleay32 in debug as fallback for openssl < 0.9.8b
  22. FIND_LIBRARY(SSL_EAY_DEBUG NAMES ssleay32MDd ssl ssleay32)
  23. FIND_LIBRARY(SSL_EAY_RELEASE NAMES ssleay32MD ssl ssleay32)
  24. IF(MSVC_IDE)
  25. IF(SSL_EAY_DEBUG AND SSL_EAY_RELEASE)
  26. SET(OPENSSL_LIBRARIES optimized ${SSL_EAY_RELEASE} debug ${SSL_EAY_DEBUG})
  27. ELSE(SSL_EAY_DEBUG AND SSL_EAY_RELEASE)
  28. SET(OPENSSL_LIBRARIES NOTFOUND)
  29. MESSAGE(STATUS "Could not find the debug and release version of openssl")
  30. ENDIF(SSL_EAY_DEBUG AND SSL_EAY_RELEASE)
  31. ELSE(MSVC_IDE)
  32. STRING(TOLOWER ${CMAKE_BUILD_TYPE} CMAKE_BUILD_TYPE_TOLOWER)
  33. IF(CMAKE_BUILD_TYPE_TOLOWER MATCHES debug)
  34. SET(OPENSSL_LIBRARIES ${SSL_EAY_DEBUG})
  35. ELSE(CMAKE_BUILD_TYPE_TOLOWER MATCHES debug)
  36. SET(OPENSSL_LIBRARIES ${SSL_EAY_RELEASE})
  37. ENDIF(CMAKE_BUILD_TYPE_TOLOWER MATCHES debug)
  38. ENDIF(MSVC_IDE)
  39. MARK_AS_ADVANCED(SSL_EAY_DEBUG SSL_EAY_RELEASE)
  40. ELSE(WIN32 AND MSVC)
  41. FIND_LIBRARY(OPENSSL_LIBRARIES NAMES ssl ssleay32 ssleay32MD )
  42. ENDIF(WIN32 AND MSVC)
  43. IF(OPENSSL_INCLUDE_DIR AND OPENSSL_LIBRARIES)
  44. SET(OPENSSL_FOUND TRUE)
  45. ELSE(OPENSSL_INCLUDE_DIR AND OPENSSL_LIBRARIES)
  46. SET(OPENSSL_FOUND FALSE)
  47. ENDIF (OPENSSL_INCLUDE_DIR AND OPENSSL_LIBRARIES)
  48. IF (OPENSSL_FOUND)
  49. IF (NOT OpenSSL_FIND_QUIETLY)
  50. MESSAGE(STATUS "Found OpenSSL: ${OPENSSL_LIBRARIES}")
  51. ENDIF (NOT OpenSSL_FIND_QUIETLY)
  52. ELSE (OPENSSL_FOUND)
  53. IF (OpenSSL_FIND_REQUIRED)
  54. MESSAGE(FATAL_ERROR "Could NOT find OpenSSL")
  55. ENDIF (OpenSSL_FIND_REQUIRED)
  56. ENDIF (OPENSSL_FOUND)
  57. MARK_AS_ADVANCED(OPENSSL_INCLUDE_DIR OPENSSL_LIBRARIES)