

find_path(MBEDTLS_INCLUDE_DIR mbedtls/ssl.h)
find_library(MBEDTLS_LIB mbedtls)
find_library(MBEDX509_LIB mbedx509)
find_library(MBEDCRYPTO_LIB mbedcrypto)

if(MbedTLS_FIND_REQUIRED)
  if(NOT MBEDTLS_INCLUDE_DIR AND NOT MBEDTLS_LIB AND NOT MBEDX509_LIB AND NOT MBEDCRYPTO_LIB)
    message(FATAL_ERROR "Couldn't find mbedTLS")
  endif()
endif()

if(MBEDTLS_INCLUDE_DIR AND MBEDTLS_LIB AND MBEDX509_LIB AND MBEDCRYPTO_LIB)
  set(MBEDTLS_FOUND TRUE)
endif()

if(MBEDTLS_FOUND)
  set(MBEDTLS_LIBRARIES "${MBEDTLS_LIB}" "${MBEDX509_LIB}" "${MBEDCRYPTO_LIB}")
endif()

mark_as_advanced(MBEDTLS_INCLUDE_DIR MBEDTLS_LIBRARIES)
