zephyr/modules/zcbor/CMakeLists.txt
Alberto Escolar Piedras 1b90d29c89 modules/zcbor: Fix implicit function declaration warning
Both zcbor_encode.c & zcbor_decode.c use strnlen()
In general these 2 functions are only exposed by the C library
if _POSIX_C_SOURCE is set 200809L.
But neither of these files (or their build scripts), are setting
this macro, causing build warnings
 Implicit declaration of function ‘strnlen’
which turn into failures in CI with some libCs.
Let's set this macro to avoid this issue.

Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
2024-01-26 07:48:55 -05:00

21 lines
738 B
CMake

if(CONFIG_ZCBOR)
zephyr_include_directories(
${ZEPHYR_ZCBOR_MODULE_DIR}/include
)
zephyr_library()
zephyr_library_sources(
${ZEPHYR_ZCBOR_MODULE_DIR}/src/zcbor_common.c
${ZEPHYR_ZCBOR_MODULE_DIR}/src/zcbor_decode.c
${ZEPHYR_ZCBOR_MODULE_DIR}/src/zcbor_encode.c
)
zephyr_library_compile_definitions(_POSIX_C_SOURCE=200809L)
zephyr_compile_definitions_ifdef(CONFIG_ZCBOR_CANONICAL ZCBOR_CANONICAL)
zephyr_compile_definitions_ifdef(CONFIG_ZCBOR_STOP_ON_ERROR ZCBOR_STOP_ON_ERROR)
zephyr_compile_definitions_ifdef(CONFIG_ZCBOR_VERBOSE ZCBOR_VERBOSE)
zephyr_compile_definitions_ifdef(CONFIG_ZCBOR_ASSERT ZCBOR_ASSERTS)
zephyr_compile_definitions_ifdef(CONFIG_ZCBOR_BIG_ENDIAN ZCBOR_BIG_ENDIAN)
endif()