FindOpenSSL.cmake 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  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. #=============================================================================
  8. # Copyright 2006-2009 Kitware, Inc.
  9. # Copyright 2006 Alexander Neundorf <[email protected]>
  10. #
  11. # Distributed under the OSI-approved BSD License (the "License");
  12. # see accompanying file Copyright.txt for details.
  13. #
  14. # This software is distributed WITHOUT ANY WARRANTY; without even the
  15. # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  16. # See the License for more information.
  17. #=============================================================================
  18. # (To distributed this file outside of CMake, substitute the full
  19. # License text for the above reference.)
  20. IF(OPENSSL_LIBRARIES)
  21. SET(OpenSSL_FIND_QUIETLY TRUE)
  22. ENDIF(OPENSSL_LIBRARIES)
  23. IF(SSL_EAY_DEBUG AND SSL_EAY_RELEASE)
  24. SET(LIB_FOUND 1)
  25. ENDIF(SSL_EAY_DEBUG AND SSL_EAY_RELEASE)
  26. FIND_PATH(OPENSSL_INCLUDE_DIR openssl/ssl.h )
  27. IF(WIN32 AND MSVC)
  28. # /MD and /MDd are the standard values - if somone wants to use
  29. # others, the libnames have to change here too
  30. # use also ssl and ssleay32 in debug as fallback for openssl < 0.9.8b
  31. FIND_LIBRARY(SSL_EAY_DEBUG NAMES ssleay32MDd ssl ssleay32)
  32. FIND_LIBRARY(SSL_EAY_RELEASE NAMES ssleay32MD ssl ssleay32)
  33. IF(MSVC_IDE)
  34. IF(SSL_EAY_DEBUG AND SSL_EAY_RELEASE)
  35. SET(OPENSSL_LIBRARIES optimized ${SSL_EAY_RELEASE} debug ${SSL_EAY_DEBUG})
  36. ELSE(SSL_EAY_DEBUG AND SSL_EAY_RELEASE)
  37. SET(OPENSSL_LIBRARIES NOTFOUND)
  38. MESSAGE(STATUS "Could not find the debug and release version of openssl")
  39. ENDIF(SSL_EAY_DEBUG AND SSL_EAY_RELEASE)
  40. ELSE(MSVC_IDE)
  41. STRING(TOLOWER ${CMAKE_BUILD_TYPE} CMAKE_BUILD_TYPE_TOLOWER)
  42. IF(CMAKE_BUILD_TYPE_TOLOWER MATCHES debug)
  43. SET(OPENSSL_LIBRARIES ${SSL_EAY_DEBUG})
  44. ELSE(CMAKE_BUILD_TYPE_TOLOWER MATCHES debug)
  45. SET(OPENSSL_LIBRARIES ${SSL_EAY_RELEASE})
  46. ENDIF(CMAKE_BUILD_TYPE_TOLOWER MATCHES debug)
  47. ENDIF(MSVC_IDE)
  48. MARK_AS_ADVANCED(SSL_EAY_DEBUG SSL_EAY_RELEASE)
  49. ELSE(WIN32 AND MSVC)
  50. FIND_LIBRARY(OPENSSL_LIBRARIES NAMES ssl ssleay32 ssleay32MD )
  51. ENDIF(WIN32 AND MSVC)
  52. IF(OPENSSL_INCLUDE_DIR AND OPENSSL_LIBRARIES)
  53. SET(OPENSSL_FOUND TRUE)
  54. ELSE(OPENSSL_INCLUDE_DIR AND OPENSSL_LIBRARIES)
  55. SET(OPENSSL_FOUND FALSE)
  56. ENDIF (OPENSSL_INCLUDE_DIR AND OPENSSL_LIBRARIES)
  57. IF (OPENSSL_FOUND)
  58. IF (NOT OpenSSL_FIND_QUIETLY)
  59. MESSAGE(STATUS "Found OpenSSL: ${OPENSSL_LIBRARIES}")
  60. ENDIF (NOT OpenSSL_FIND_QUIETLY)
  61. ELSE (OPENSSL_FOUND)
  62. IF (OpenSSL_FIND_REQUIRED)
  63. MESSAGE(FATAL_ERROR "Could NOT find OpenSSL")
  64. ENDIF (OpenSSL_FIND_REQUIRED)
  65. ENDIF (OPENSSL_FOUND)
  66. MARK_AS_ADVANCED(OPENSSL_INCLUDE_DIR OPENSSL_LIBRARIES)