You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
21 lines
986 B
21 lines
986 B
6 years ago
|
function(nanopb_generate PROTO_FILE PB_OUT HDR_VAR SRC_VAR)
|
||
|
get_filename_component(PROTO_FILE_NAME ${PROTO_FILE} NAME_WE)
|
||
|
get_filename_component(PROTO_FILE_PATH ${PROTO_FILE} ABSOLUTE BASE_DIR ${CMAKE_CURRENT_SOURCE_DIR})
|
||
|
get_filename_component(PROTO_FILE_DIR ${PROTO_FILE_PATH} DIRECTORY)
|
||
|
set(PROTO_HDR "${PB_OUT}/${PROTO_FILE_NAME}.pb.h")
|
||
|
set(PROTO_SRC "${PB_OUT}/${PROTO_FILE_NAME}.pb.c")
|
||
|
list(APPEND "${HDR_VAR}" ${PROTO_HDR})
|
||
|
list(APPEND "${SRC_VAR}" ${PROTO_SRC})
|
||
|
if(NOT CMAKE_SCRIPT_MODE_FILE)
|
||
|
add_custom_command(OUTPUT ${PROTO_HDR} ${PROTO_SRC}
|
||
|
COMMAND protoc
|
||
|
--plugin=protoc-gen-nanopb=${CMAKE_CURRENT_LIST_DIR}/nanopb/generator/protoc-gen-nanopb
|
||
|
--nanopb_out=${PB_OUT}
|
||
|
--proto_path ${PROTO_FILE_DIR}
|
||
|
${PROTO_FILE_PATH}
|
||
|
DEPENDS ${PROTO_FILE_PATH})
|
||
|
endif()
|
||
|
list(APPEND ADDITIONAL_MAKE_CLEAN_FILES ${PROTO_HDR} ${PROTO_SRC})
|
||
|
endfunction()
|
||
|
|