geom_gate userland utility improvements
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

65 lines
2.6 KiB

  1. # - Try to find mbedTLS
  2. # Once done this will define
  3. #
  4. # Read-Only variables
  5. # MBEDTLS_FOUND - system has mbedTLS
  6. # MBEDTLS_INCLUDE_DIR - the mbedTLS include directory
  7. # MBEDTLS_LIBRARY_DIR - the mbedTLS library directory
  8. # MBEDTLS_LIBRARIES - Link these to use mbedTLS
  9. # MBEDTLS_LIBRARY - path to mbedTLS library
  10. # MBEDX509_LIBRARY - path to mbedTLS X.509 library
  11. # MBEDCRYPTO_LIBRARY - path to mbedTLS Crypto library
  12. FIND_PATH(MBEDTLS_INCLUDE_DIR mbedtls/version.h)
  13. IF(MBEDTLS_INCLUDE_DIR AND MBEDTLS_LIBRARIES)
  14. # Already in cache, be silent
  15. SET(MBEDTLS_FIND_QUIETLY TRUE)
  16. ENDIF()
  17. FIND_LIBRARY(MBEDTLS_LIBRARY NAMES mbedtls libmbedtls libmbedx509)
  18. FIND_LIBRARY(MBEDX509_LIBRARY NAMES mbedx509 libmbedx509)
  19. FIND_LIBRARY(MBEDCRYPTO_LIBRARY NAMES mbedcrypto libmbedcrypto)
  20. IF(MBEDTLS_INCLUDE_DIR AND MBEDTLS_LIBRARY AND MBEDX509_LIBRARY AND MBEDCRYPTO_LIBRARY)
  21. SET(MBEDTLS_FOUND TRUE)
  22. ENDIF()
  23. IF(MBEDTLS_FOUND)
  24. # split mbedTLS into -L and -l linker options, so we can set them for pkg-config
  25. GET_FILENAME_COMPONENT(MBEDTLS_LIBRARY_DIR ${MBEDTLS_LIBRARY} PATH)
  26. GET_FILENAME_COMPONENT(MBEDTLS_LIBRARY_FILE ${MBEDTLS_LIBRARY} NAME_WE)
  27. GET_FILENAME_COMPONENT(MBEDX509_LIBRARY_FILE ${MBEDX509_LIBRARY} NAME_WE)
  28. GET_FILENAME_COMPONENT(MBEDCRYPTO_LIBRARY_FILE ${MBEDCRYPTO_LIBRARY} NAME_WE)
  29. STRING(REGEX REPLACE "^lib" "" MBEDTLS_LIBRARY_FILE ${MBEDTLS_LIBRARY_FILE})
  30. STRING(REGEX REPLACE "^lib" "" MBEDX509_LIBRARY_FILE ${MBEDX509_LIBRARY_FILE})
  31. STRING(REGEX REPLACE "^lib" "" MBEDCRYPTO_LIBRARY_FILE ${MBEDCRYPTO_LIBRARY_FILE})
  32. SET(MBEDTLS_LIBRARIES "-L${MBEDTLS_LIBRARY_DIR} -l${MBEDTLS_LIBRARY_FILE} -l${MBEDX509_LIBRARY_FILE} -l${MBEDCRYPTO_LIBRARY_FILE}")
  33. IF(NOT MBEDTLS_FIND_QUIETLY)
  34. MESSAGE(STATUS "Found mbedTLS:")
  35. FILE(READ ${MBEDTLS_INCLUDE_DIR}/mbedtls/version.h MBEDTLSCONTENT)
  36. STRING(REGEX MATCH "MBEDTLS_VERSION_STRING +\"[0-9|.]+\"" MBEDTLSMATCH ${MBEDTLSCONTENT})
  37. IF (MBEDTLSMATCH)
  38. STRING(REGEX REPLACE "MBEDTLS_VERSION_STRING +\"([0-9|.]+)\"" "\\1" MBEDTLS_VERSION ${MBEDTLSMATCH})
  39. MESSAGE(STATUS " version ${MBEDTLS_VERSION}")
  40. ENDIF(MBEDTLSMATCH)
  41. MESSAGE(STATUS " TLS: ${MBEDTLS_LIBRARY}")
  42. MESSAGE(STATUS " X509: ${MBEDX509_LIBRARY}")
  43. MESSAGE(STATUS " Crypto: ${MBEDCRYPTO_LIBRARY}")
  44. ENDIF(NOT MBEDTLS_FIND_QUIETLY)
  45. ELSE(MBEDTLS_FOUND)
  46. IF(MBEDTLS_FIND_REQUIRED)
  47. MESSAGE(FATAL_ERROR "Could not find mbedTLS")
  48. ENDIF(MBEDTLS_FIND_REQUIRED)
  49. ENDIF(MBEDTLS_FOUND)
  50. MARK_AS_ADVANCED(
  51. MBEDTLS_INCLUDE_DIR
  52. MBEDTLS_LIBRARY_DIR
  53. MBEDTLS_LIBRARIES
  54. MBEDTLS_LIBRARY
  55. MBEDX509_LIBRARY
  56. MBEDCRYPTO_LIBRARY
  57. )