FindOpenSSL.cmake 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  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. MESSAGE(FATAL_ERROR "Could not find the debug and release version of openssl")
  29. ENDIF(SSL_EAY_DEBUG AND SSL_EAY_RELEASE)
  30. ELSE(MSVC_IDE)
  31. STRING(TOLOWER ${CMAKE_BUILD_TYPE} CMAKE_BUILD_TYPE_TOLOWER)
  32. IF(CMAKE_BUILD_TYPE_TOLOWER MATCHES debug)
  33. SET(OPENSSL_LIBRARIES ${SSL_EAY_DEBUG})
  34. ELSE(CMAKE_BUILD_TYPE_TOLOWER MATCHES debug)
  35. SET(OPENSSL_LIBRARIES ${SSL_EAY_RELEASE})
  36. ENDIF(CMAKE_BUILD_TYPE_TOLOWER MATCHES debug)
  37. ENDIF(MSVC_IDE)
  38. MARK_AS_ADVANCED(SSL_EAY_DEBUG SSL_EAY_RELEASE)
  39. ELSE(WIN32 AND MSVC)
  40. FIND_LIBRARY(OPENSSL_LIBRARIES NAMES ssl ssleay32 ssleay32MD )
  41. ENDIF(WIN32 AND MSVC)
  42. IF(OPENSSL_INCLUDE_DIR AND OPENSSL_LIBRARIES)
  43. SET(OPENSSL_FOUND TRUE)
  44. ELSE(OPENSSL_INCLUDE_DIR AND OPENSSL_LIBRARIES)
  45. SET(OPENSSL_FOUND FALSE)
  46. ENDIF (OPENSSL_INCLUDE_DIR AND OPENSSL_LIBRARIES)
  47. IF (OPENSSL_FOUND)
  48. IF (NOT OpenSSL_FIND_QUIETLY)
  49. MESSAGE(STATUS "Found OpenSSL: ${OPENSSL_LIBRARIES}")
  50. ENDIF (NOT OpenSSL_FIND_QUIETLY)
  51. ELSE (OPENSSL_FOUND)
  52. IF (OpenSSL_FIND_REQUIRED)
  53. MESSAGE(FATAL_ERROR "Could NOT find OpenSSL")
  54. ENDIF (OpenSSL_FIND_REQUIRED)
  55. ENDIF (OPENSSL_FOUND)
  56. MARK_AS_ADVANCED(OPENSSL_INCLUDE_DIR OPENSSL_LIBRARIES)