FindMbedTLS.cmake 1.2 KB

1234567891011121314151617181920212223242526272829
  1. #check environment variable
  2. if("$ENV{MBEDTLS_FOLDER_INCLUDE}")
  3. set(MBEDTLS_FOLDER_INCLUDE "$ENV{MBEDTLS_FOLDER_INCLUDE}")
  4. endif()
  5. if("$ENV{MBEDTLS_FOLDER_LIBRARY}")
  6. set(MBEDTLS_FOLDER_LIBRARY "$ENV{MBEDTLS_FOLDER_LIBRARY}")
  7. endif()
  8. find_path(MBEDTLS_INCLUDE_DIRS mbedtls/ssl.h HINTS ${MBEDTLS_FOLDER_INCLUDE})
  9. if(UA_BUILD_OSS_FUZZ)
  10. # oss-fuzz requires static linking of libraries
  11. set(MBEDTLS_LIBRARY /usr/lib/x86_64-linux-gnu/libmbedtls.a)
  12. set(MBEDX509_LIBRARY /usr/lib/x86_64-linux-gnu/libmbedx509.a)
  13. set(MBEDCRYPTO_LIBRARY /usr/lib/x86_64-linux-gnu/libmbedcrypto.a)
  14. else()
  15. find_library(MBEDTLS_LIBRARY mbedtls HINTS ${MBEDTLS_FOLDER_LIBRARY})
  16. find_library(MBEDX509_LIBRARY mbedx509 HINTS ${MBEDTLS_FOLDER_LIBRARY})
  17. find_library(MBEDCRYPTO_LIBRARY mbedcrypto HINTS ${MBEDTLS_FOLDER_LIBRARY})
  18. endif()
  19. set(MBEDTLS_LIBRARIES "${MBEDTLS_LIBRARY}" "${MBEDX509_LIBRARY}" "${MBEDCRYPTO_LIBRARY}")
  20. include(FindPackageHandleStandardArgs)
  21. find_package_handle_standard_args(MBEDTLS DEFAULT_MSG
  22. MBEDTLS_INCLUDE_DIRS MBEDTLS_LIBRARY MBEDX509_LIBRARY MBEDCRYPTO_LIBRARY)
  23. mark_as_advanced(MBEDTLS_INCLUDE_DIRS MBEDTLS_LIBRARY MBEDX509_LIBRARY MBEDCRYPTO_LIBRARY)