CMakeLists.txt 1.7 KB

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