From d837a9f40d95abe90fd09184dc86e3fbaca92328 Mon Sep 17 00:00:00 2001 From: Alex Mikhalev Date: Thu, 3 Jan 2019 14:25:54 -0700 Subject: [PATCH] fix nanopb_generate --- components/nanopb/functions.cmake | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/components/nanopb/functions.cmake b/components/nanopb/functions.cmake index 02f95a8..174cb59 100644 --- a/components/nanopb/functions.cmake +++ b/components/nanopb/functions.cmake @@ -1,19 +1,23 @@ +set(NANOPB_PLUGIN "${CMAKE_CURRENT_LIST_DIR}/nanopb/generator/protoc-gen-nanopb") + 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}) + set(${HDR_VAR} ${${HDR_VAR}} ${PROTO_HDR} PARENT_SCOPE) + set(${SRC_VAR} ${${SRC_VAR}} ${PROTO_SRC} PARENT_SCOPE) 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 + --plugin=protoc-gen-nanopb=${NANOPB_PLUGIN} --nanopb_out=${PB_OUT} --proto_path ${PROTO_FILE_DIR} ${PROTO_FILE_PATH} - DEPENDS ${PROTO_FILE_PATH}) + DEPENDS ${PROTO_FILE_PATH} + COMMENT "Generating nanopb sources for ${PROTO_FILE}") + set_property(SOURCE ${PROTO_HDR} ${PROTO_SRC} PROPERTY GENERATED TRUE) endif() list(APPEND ADDITIONAL_MAKE_CLEAN_FILES ${PROTO_HDR} ${PROTO_SRC}) endfunction()