nanopb_generate_cpp - target dir configuration

369 views
Skip to first unread message

Peter Janik

unread,
Mar 16, 2022, 7:46:57 AM3/16/22
to nanopb
Hi All,

I am working on a project based on zephyr, cmake  3.22.1 and nanopb protocol buffers 0.4.6 dev. I am trying to configure cmake in order to generate proto c- sources in a specific directory. I am not sure what I configured wrongly but I am not able to get satisfactory output.

My dir structure is like this (only relevant parts shown):

- proto
- lib_proto
- src
- build
CMakeLists.txt

proto dir contains 3 proto sources. My intention is to get the *.pb.c, *.pb.h files in lib_proto dir.

The CMakeLists.txt snippet looks like this:

set(PROTO_FILES proto/piu_command.proto proto/piu_info.proto proto/piu_measurement.proto)
set(NANOPB_IMPORT_DIRS proto)
set(NANOPB_OUT ${CMAKE_CURRENT_SOURCE_DIR}/lib_proto)
set(NANOPB_OPTIONS -v)

list(APPEND CMAKE_MODULE_PATH ${nanopb_SOURCE_DIR})

nanopb_generate_cpp(proto_sources proto_headers RELPATH proto ${PROTO_FILES})

target_sources(app PRIVATE ${proto_sources} ${app_sources})


Using the above I am not getting *.pb.c, *.pb.h files generated in lib_proto dir rather in build dir that is a temporary dir of zephyr.

Please, can somebody advice me what is wrongly setup, what to change? I tried to go through different web cmake and nanopb / proto buf pages but was not able to figure out how to setup the cmake the way i need to generate files. Or are there any limitations where the sources can be generated to?

Thanx.
Best regards,
peter

Ivan Wagner

unread,
Nov 25, 2022, 5:16:08 AM11/25/22
to nanopb
Hi Peter,

did you ever solve your issue with the output directory?

best,

ivan

Peter Janik

unread,
Nov 25, 2022, 8:32:51 AM11/25/22
to nanopb
Hi Ivan,
well, I havent solved it. Fortunately, there are only seldom changes in the proto files so when I do one, I make a manual copy of generated files.
Also I tried to add some commands to cmake file to copy them but nothing worked well for me. As it is not so often needed, I left it for manual copy.
Are you trying to solve the same / similar problem?
Best regards,
peter

Reply all
Reply to author
Forward
0 new messages