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