1# Copyright (c) 2021, Basalte bv
2#
3# SPDX-License-Identifier: Apache-2.0
4
5if(CONFIG_NANOPB)
6
7  set(NANOPB_DIR ${ZEPHYR_CURRENT_MODULE_DIR})
8
9  zephyr_library()
10  zephyr_library_sources(
11    ${NANOPB_DIR}/pb_common.c
12    ${NANOPB_DIR}/pb_encode.c
13    ${NANOPB_DIR}/pb_decode.c
14  )
15
16  zephyr_include_directories(${NANOPB_DIR})
17
18  zephyr_compile_definitions(
19    PB_MAX_REQUIRED_FIELDS=${CONFIG_NANOPB_MAX_REQUIRED_FIELDS})
20
21  zephyr_compile_definitions_ifdef(
22    CONFIG_NANOPB_ENABLE_MALLOC
23    PB_ENABLE_MALLOC
24  )
25
26  zephyr_compile_definitions_ifdef(
27    CONFIG_NANOPB_NO_ERRMSG
28    PB_NO_ERRMSG
29  )
30
31  zephyr_compile_definitions_ifdef(
32    CONFIG_NANOPB_BUFFER_ONLY
33    PB_BUFFER_ONLY
34  )
35
36  zephyr_compile_definitions_ifdef(
37    CONFIG_NANOPB_WITHOUT_64BIT
38    PB_WITHOUT_64BIT
39  )
40
41  zephyr_compile_definitions_ifdef(
42    CONFIG_NANOPB_ENCODE_ARRAYS_UNPACKED
43    PB_ENCODE_ARRAYS_UNPACKED
44  )
45
46  zephyr_compile_definitions_ifdef(
47    CONFIG_NANOPB_VALIDATE_UTF8
48    PB_VALIDATE_UTF8
49  )
50
51endif()
52