summaryrefslogtreecommitdiffstats
path: root/Modules/FindProtobuf.cmake
diff options
context:
space:
mode:
authorFrank Lange <langefrq@gmx.de>2021-04-30 20:56:39 (GMT)
committerBrad King <brad.king@kitware.com>2021-05-06 17:42:21 (GMT)
commitf2a4b879b1cddce84c56de63809e831aea53d1ba (patch)
tree6ecff61d0f3059b2a27be53dc619d3bfe727f5b3 /Modules/FindProtobuf.cmake
parent5cbbe3d301838b361f7ff9ae7e09dc10ce089957 (diff)
downloadCMake-f2a4b879b1cddce84c56de63809e831aea53d1ba.zip
CMake-f2a4b879b1cddce84c56de63809e831aea53d1ba.tar.gz
CMake-f2a4b879b1cddce84c56de63809e831aea53d1ba.tar.bz2
FindProtobuf: Add PLUGIN parameter to protobuf_generate
This allows for example reusing the function for generating gRPC code by specifying which grpc plugin to use.
Diffstat (limited to 'Modules/FindProtobuf.cmake')
-rw-r--r--Modules/FindProtobuf.cmake8
1 files changed, 6 insertions, 2 deletions
diff --git a/Modules/FindProtobuf.cmake b/Modules/FindProtobuf.cmake
index 4b1e336..c73a2d8 100644
--- a/Modules/FindProtobuf.cmake
+++ b/Modules/FindProtobuf.cmake
@@ -140,7 +140,7 @@ Example:
function(protobuf_generate)
set(_options APPEND_PATH DESCRIPTORS)
- set(_singleargs LANGUAGE OUT_VAR EXPORT_MACRO PROTOC_OUT_DIR)
+ set(_singleargs LANGUAGE OUT_VAR EXPORT_MACRO PROTOC_OUT_DIR PLUGIN)
if(COMMAND target_sources)
list(APPEND _singleargs TARGET)
endif()
@@ -171,6 +171,10 @@ function(protobuf_generate)
set(_dll_export_decl "dllexport_decl=${protobuf_generate_EXPORT_MACRO}:")
endif()
+ if(protobuf_generate_PLUGIN)
+ set(_plugin "--plugin=${protobuf_generate_PLUGIN}")
+ endif()
+
if(NOT protobuf_generate_GENERATE_EXTENSIONS)
if(protobuf_generate_LANGUAGE STREQUAL cpp)
set(protobuf_generate_GENERATE_EXTENSIONS .pb.h .pb.cc)
@@ -245,7 +249,7 @@ function(protobuf_generate)
add_custom_command(
OUTPUT ${_generated_srcs}
COMMAND protobuf::protoc
- ARGS --${protobuf_generate_LANGUAGE}_out ${_dll_export_decl}${protobuf_generate_PROTOC_OUT_DIR} ${_dll_desc_out} ${_protobuf_include_path} ${_abs_file}
+ ARGS --${protobuf_generate_LANGUAGE}_out ${_dll_export_decl}${protobuf_generate_PROTOC_OUT_DIR} ${_plugin} ${_dll_desc_out} ${_protobuf_include_path} ${_abs_file}
DEPENDS ${_abs_file} protobuf::protoc
COMMENT "Running ${protobuf_generate_LANGUAGE} protocol buffer compiler on ${_proto}"
VERBATIM )