feat(zephyr): support v4.4

- fix(cmake): only create alias if it doesn't exist:
Zephyr v4.4 has moved to MbedTLS 4.x in following PR:
https://github.com/zephyrproject-rtos/zephyr/pull/104031
Zephyr now uses MbedTLS' CMakeLists, which exports targets
with NAMESPACE MbedTLS::, therefore MbedTLS::mbedtls,
MbedTLS::mbedx509, MbedTLS::tfpsacrypto aliases already exist

- fix(zephyr): v4.4: include correct mbedtls config based on zephyr version
CONFIG_MBEDTLS_CFG_FILE was deprecated. Instead, CONFIG_MBEDTLS_CONFIG_FILE
shall be used. This change supports both based on Kconfig symbols.

Signed-off-by: Krisztian Szilvasi <34309983+kr-t@users.noreply.github.com>
This commit is contained in:
Krisztian Szilvasi authored and Jon Shallow committed 2026-04-23 16:48:56 +01:00
1 parent 8402c3bb8c
commit d62f137bcd
2 files changed
+15 -4

No files matched your search

+11 -3
View File
@@ -801,9 +801,17 @@ target_compile_options(
PUBLIC -DLIBCOAP_PACKAGE_BUILD="${LIBCOAP_PACKAGE_BUILD}")
if(ZEPHYR_BASE)
target_compile_options(
${COAP_LIBRARY_NAME}
PUBLIC -DMBEDTLS_CONFIG_FILE="${CONFIG_MBEDTLS_CFG_FILE}" -I${ZEPHYR_MBEDTLS_CMAKE_DIR}/configs)
# Zephyr >= v4.4:
if(DEFINED CONFIG_MBEDTLS_CONFIG_FILE)
target_compile_options(${COAP_LIBRARY_NAME}
PUBLIC -DMBEDTLS_CONFIG_FILE="${CONFIG_MBEDTLS_CONFIG_FILE}" -I${ZEPHYR_MBEDTLS_CMAKE_DIR}/configs)
# Zephyr < v4.4:
elseif(DEFINED CONFIG_MBEDTLS_CFG_FILE)
target_compile_options(${COAP_LIBRARY_NAME}
PUBLIC -DMBEDTLS_CONFIG_FILE="${CONFIG_MBEDTLS_CFG_FILE}" -I${ZEPHYR_MBEDTLS_CMAKE_DIR}/configs)
else()
message(WARNING "No usable MBEDTLS config Kconfig symbol found")
endif()
endif() # ! ZEPHYR_BASE
add_library(
+4 -1
View File
@@ -159,7 +159,10 @@ if(CONFIG_LIBCOAP)
if(CONFIG_MBEDTLS)
if(TARGET mbedTLS)
target_include_directories(mbedTLS INTERFACE ${ZEPHYR_LIBCOAP_MODULE_DIR}/include)
add_library(MbedTLS::mbedtls ALIAS mbedTLS)
# Only create alias if it doesn't already exist (Zephyr v4.4+ has it)
if(NOT TARGET MbedTLS::mbedtls)
add_library(MbedTLS::mbedtls ALIAS mbedTLS)
endif()
else()
message(WARNING "mbedTLS target not found.")
endif()