IF(SSL_EAY_DEBUG AND SSL_EAY_RELEASE)
   SET(LIB_FOUND 1)
 ENDIF(SSL_EAY_DEBUG AND SSL_EAY_RELEASE)

 IF(APPLE)
  FIND_PATH(CRYPTO_INCLUDE_DIR
    NAMES openssl/crypto.h
    PATHS /usr/local/opt/openssl/include
    NO_DEFAULT_PATH)
  FIND_LIBRARY(CRYPTO_LIBRARIES
    NAMES crypto
    PATHS /usr/local/opt/openssl/lib
    NO_DEFAULT_PATH
    NO_CMAKE_ENVIRONMENT_PATH
    NO_CMAKE_PATH
    NO_SYSTEM_ENVIRONMENT_PATH
    NO_CMAKE_SYSTEM_PATH
    CMAKE_FIND_FRAMEWORK NEVER)
ELSE()
  FIND_PATH(CRYPTO_INCLUDE_DIR NAMES openssl/crypto.h)
  FIND_LIBRARY(CRYPTO_LIBRARIES NAMES crypto libcrypto)
ENDIF(APPLE)

IF(CRYPTO_INCLUDE_DIR AND CRYPTO_LIBRARIES)
   SET(CRYPTO_FOUND TRUE)
ELSE(CRYPTO_INCLUDE_DIR AND CRYPTO_LIBRARIES)
   SET(CRYPTO_FOUND FALSE)
ENDIF (CRYPTO_INCLUDE_DIR AND CRYPTO_LIBRARIES)

IF (CRYPTO_FOUND)
   IF (NOT Crypto_FIND_QUIETLY)
      MESSAGE(STATUS "Found libcrypto: ${CRYPTO_LIBRARIES}, ${CRYPTO_INCLUDE_DIR}")
   ENDIF (NOT Crypto_FIND_QUIETLY)
ELSE (CRYPTO_FOUND)
   IF (Crypto_FIND_REQUIRED)
      MESSAGE(FATAL_ERROR "Could NOT find libcrypto")
   ENDIF (Crypto_FIND_REQUIRED)
ENDIF (CRYPTO_FOUND)
