modules: nanopb: Add custom target for generated header files
Nanopb generates header files that need to be available before being included. This isn't an issue for a target where the files were added with zephyr_nanopb_sources. But if another target wants to include these generated files we need a cmake dependency chain. The nanopb_generated_headers custom target been added for this purpose. Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
This commit is contained in:
parent
c3e2be4314
commit
4b1a8cb95b
|
@ -15,6 +15,8 @@ else()
|
|||
message(STATUS "Found protoc: ${PROTOBUF_PROTOC_EXECUTABLE}")
|
||||
endif()
|
||||
|
||||
add_custom_target(nanopb_generated_headers)
|
||||
|
||||
# Usage:
|
||||
# list(APPEND CMAKE_MODULE_PATH ${ZEPHYR_BASE}/modules/nanopb)
|
||||
# include(nanopb)
|
||||
|
@ -31,4 +33,11 @@ function(zephyr_nanopb_sources target)
|
|||
|
||||
target_include_directories(${target} PUBLIC ${CMAKE_CURRENT_BINARY_DIR})
|
||||
target_sources(${target} PRIVATE ${proto_srcs} ${proto_hdrs})
|
||||
|
||||
# Create unique target name for generated header list
|
||||
string(MD5 unique_chars "${proto_hdrs}")
|
||||
set(gen_target_name ${target}_proto_${unique_chars})
|
||||
|
||||
add_custom_target(${gen_target_name} DEPENDS ${proto_hdrs})
|
||||
add_dependencies(nanopb_generated_headers ${gen_target_name})
|
||||
endfunction()
|
||||
|
|
Loading…
Reference in a new issue