FindMbedTLS.cmake 1.5 KB

123456789101112131415161718192021222324252627282930313233343536
  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. add_library(mbedtls UNKNOWN IMPORTED)
  20. set_property(TARGET mbedtls PROPERTY IMPORTED_LOCATION "${MBEDTLS_LIBRARY}")
  21. add_library(mbedx509 UNKNOWN IMPORTED)
  22. set_property(TARGET mbedx509 PROPERTY IMPORTED_LOCATION "${MBEDX509_LIBRARY}")
  23. add_library(mbedcrypto UNKNOWN IMPORTED)
  24. set_property(TARGET mbedcrypto PROPERTY IMPORTED_LOCATION "${MBEDCRYPTO_LIBRARY}")
  25. set(MBEDTLS_LIBRARIES mbedtls mbedx509 mbedcrypto)
  26. include(FindPackageHandleStandardArgs)
  27. find_package_handle_standard_args(MBEDTLS DEFAULT_MSG
  28. MBEDTLS_INCLUDE_DIRS MBEDTLS_LIBRARY MBEDX509_LIBRARY MBEDCRYPTO_LIBRARY)
  29. mark_as_advanced(MBEDTLS_INCLUDE_DIRS MBEDTLS_LIBRARY MBEDX509_LIBRARY MBEDCRYPTO_LIBRARY)