zephyr/modules/nanopb/CMakeLists.txt
Pieter De Gendt 0357b4d4f5 modules: nanopb: Add helper function to generate sources
Introduce a helper function zephyr_nanopb_sources to generate
source files and add these to a target.

Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
2023-09-15 12:57:40 +02:00

52 lines
1,000 B
CMake

# Copyright (c) 2021, Basalte bv
#
# SPDX-License-Identifier: Apache-2.0
if(CONFIG_NANOPB)
set(NANOPB_DIR ${ZEPHYR_CURRENT_MODULE_DIR})
zephyr_library()
zephyr_library_sources(
${NANOPB_DIR}/pb_common.c
${NANOPB_DIR}/pb_encode.c
${NANOPB_DIR}/pb_decode.c
)
zephyr_include_directories(${NANOPB_DIR})
zephyr_compile_definitions(
PB_MAX_REQUIRED_FIELDS=${CONFIG_NANOPB_MAX_REQUIRED_FIELDS})
zephyr_compile_definitions_ifdef(
CONFIG_NANOPB_ENABLE_MALLOC
PB_ENABLE_MALLOC
)
zephyr_compile_definitions_ifdef(
CONFIG_NANOPB_NO_ERRMSG
PB_NO_ERRMSG
)
zephyr_compile_definitions_ifdef(
CONFIG_NANOPB_BUFFER_ONLY
PB_BUFFER_ONLY
)
zephyr_compile_definitions_ifdef(
CONFIG_NANOPB_WITHOUT_64BIT
PB_WITHOUT_64BIT
)
zephyr_compile_definitions_ifdef(
CONFIG_NANOPB_ENCODE_ARRAYS_UNPACKED
PB_ENCODE_ARRAYS_UNPACKED
)
zephyr_compile_definitions_ifdef(
CONFIG_NANOPB_VALIDATE_UTF8
PB_VALIDATE_UTF8
)
endif()