we are currently trying to get the code generation for some proto files working in our project.
We followed https://docs.espressif.com/projects/esp ... generation and added the following lines into out component CMakeLists.txt:
Code: Select all
idf_component_register(SRCS
"main.cpp"
"protocol.pb.cc"
)
message(WARNING "COMPONENT_LIB '${COMPONENT_LIB}'")
add_custom_command(
WORKING_DIRECTORY ${COMPONENT_DIR}
DEPENDS protocol.proto
COMMAND echo XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
COMMAND protoc --proto_path=${COMPONENT_DIR} --cpp_out=${COMPONENT_DIR} protocol.proto
OUTPUT ${COMPONENT_DIR}/protocol.pb.cc ${COMPONENT_DIR}/protocol.pb.h
)
add_custom_target(
generate_protobuf
DEPENDS ${COMPONENT_DIR}/protocol.pb.cc ${COMPONENT_DIR}/protocol.pb.h
)
add_dependencies(
${COMPONENT_LIB} generate_protobuf
)
set_property(DIRECTORY "${COMPONENT_DIR}" APPEND PROPERTY
ADDITIONAL_MAKE_CLEAN_FILES protocol.pb.h protocol.pb.cc)
Code: Select all
PACKAGES:
- framework-arduinoespressif32 @ 3.20005.220925 (2.0.5)
- framework-espidf @ 3.40402.0 (4.4.2)
- tool-cmake @ 3.16.4
- tool-esptoolpy @ 1.40201.0 (4.2.1)
- tool-ninja @ 1.7.1
- toolchain-esp32ulp @ 1.22851.191205 (2.28.51)
- toolchain-xtensa-esp32 @ 8.4.0+2021r2-patch3
Code: Select all
*** [.pio/build/esp32dev/src/protocol.pb.o] Source `src/protocol.pb.cc' not found, needed by target `.pio/build/esp32dev/src/protocol.pb.o'.
We had a look into the generated build.ninja file and could not find a dependency between __idf_src and generate_protobuf, as if the add_dependencies was ignored.
What is wrong here?
Thanks in advance
Florian