FindMbedTLS.cmake 1.4 KB

1234567891011121314151617181920212223242526272829303132333435
  1. if(BELL_EXTERNAL_MBEDTLS)
  2. set(MbedTLS_DIR ${BELL_EXTERNAL_MBEDTLS})
  3. message(STATUS "Using config mode, setting local mbedtls ${MbedTLS_DIR}")
  4. find_package(MbedTLS REQUIRED CONFIG)
  5. get_target_property(MBEDTLS_INCLUDE_DIRS MbedTLS::mbedtls INTERFACE_INCLUDE_DIRECTORIES)
  6. if(MSVC)
  7. set(MBEDTLS_RELEASE "RELEASE" CACHE STRING "local mbedtls version")
  8. else()
  9. set(MBEDTLS_RELEASE "NOCONFIG" CACHE STRING "local mbedtls version")
  10. endif()
  11. get_target_property(MBEDTLS_INFO MbedTLS::mbedtls IMPORTED_LOCATION_${MBEDTLS_RELEASE})
  12. set(MBEDTLS_LIBRARIES ${MBEDTLS_INFO})
  13. get_target_property(MBEDTLS_INFO MbedTLS::mbedx509 IMPORTED_LOCATION_${MBEDTLS_RELEASE})
  14. list(APPEND MBEDTLS_LIBRARIES ${MBEDTLS_INFO})
  15. get_target_property(MBEDTLS_INFO MbedTLS::mbedcrypto IMPORTED_LOCATION_${MBEDTLS_RELEASE})
  16. list(APPEND MBEDTLS_LIBRARIES ${MBEDTLS_INFO})
  17. else()
  18. find_path(MBEDTLS_INCLUDE_DIRS mbedtls/ssl.h)
  19. find_library(MBEDTLS_LIBRARY mbedtls)
  20. find_library(MBEDX509_LIBRARY mbedx509)
  21. find_library(MBEDCRYPTO_LIBRARY mbedcrypto)
  22. set(MBEDTLS_LIBRARIES "${MBEDTLS_LIBRARY}" "${MBEDX509_LIBRARY}" "${MBEDCRYPTO_LIBRARY}")
  23. include(FindPackageHandleStandardArgs)
  24. find_package_handle_standard_args(MbedTLS DEFAULT_MSG
  25. MBEDTLS_INCLUDE_DIRS MBEDTLS_LIBRARY MBEDX509_LIBRARY MBEDCRYPTO_LIBRARY)
  26. mark_as_advanced(MBEDTLS_INCLUDE_DIRS MBEDTLS_LIBRARY MBEDX509_LIBRARY MBEDCRYPTO_LIBRARY)
  27. endif()