CMakeLists.txt 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. if(CONFIG_MBEDTLS)
  2. zephyr_interface_library_named(mbedTLS)
  3. if(CONFIG_MBEDTLS_BUILTIN)
  4. target_compile_definitions(mbedTLS INTERFACE
  5. MBEDTLS_CONFIG_FILE="${CONFIG_MBEDTLS_CFG_FILE}"
  6. )
  7. target_include_directories(mbedTLS INTERFACE
  8. ${ZEPHYR_CURRENT_MODULE_DIR}/mbedtls/include
  9. configs
  10. )
  11. zephyr_library()
  12. file(GLOB
  13. mbedtls_sources # This is an output parameter
  14. ${ZEPHYR_CURRENT_MODULE_DIR}/mbedtls/library/*.c
  15. )
  16. zephyr_library_sources(
  17. zephyr_init.c
  18. ${mbedtls_sources}
  19. )
  20. zephyr_library_sources_ifdef(CONFIG_MBEDTLS_SHELL shell.c)
  21. zephyr_library_app_memory(k_mbedtls_partition)
  22. if(CONFIG_ARCH_POSIX AND CONFIG_ASAN AND NOT CONFIG_64BIT)
  23. # i386 assembly code used in MBEDTLS does not compile with size optimization
  24. # if address sanitizer is enabled, as such switch default optimization level
  25. # to speed
  26. set_property(SOURCE ${ZEPHYR_CURRENT_MODULE_DIR}/mbedtls/library/bignum.c APPEND PROPERTY COMPILE_OPTIONS
  27. "${OPTIMIZE_FOR_SPEED_FLAG}")
  28. endif ()
  29. zephyr_library_link_libraries(mbedTLS)
  30. else()
  31. assert(CONFIG_MBEDTLS_LIBRARY "MBEDTLS was enabled, but neither BUILTIN or LIBRARY was selected.")
  32. # NB: CONFIG_MBEDTLS_LIBRARY is not regression tested and is
  33. # therefore susceptible to bit rot
  34. target_include_directories(mbedTLS INTERFACE
  35. ${CONFIG_MBEDTLS_INSTALL_PATH}
  36. )
  37. zephyr_link_libraries(
  38. mbedtls_external
  39. -L${CONFIG_MBEDTLS_INSTALL_PATH}
  40. gcc
  41. )
  42. # Lib mbedtls_external depends on libgcc (I assume?) so to allow
  43. # mbedtls_external to link with gcc we need to ensure it is placed
  44. # after mbedtls_external on the linkers command line.
  45. endif()
  46. endif()