when cross-compiling, the host grpc_cpp_plugin should be used

pull/11795/head
Markus Heß 8 years ago committed by Jan Tattermusch
parent 04642dc7ec
commit 0d7a0ded1c
  1. 9
      CMakeLists.txt
  2. 9
      templates/CMakeLists.txt.template

@ -190,6 +190,13 @@ function(protobuf_generate_grpc_cpp)
get_filename_component(REL_DIR ${REL_FIL} DIRECTORY) get_filename_component(REL_DIR ${REL_FIL} DIRECTORY)
set(RELFIL_WE "${REL_DIR}/${FIL_WE}") set(RELFIL_WE "${REL_DIR}/${FIL_WE}")
#if cross-compiling, find host plugin
if(CMAKE_CROSSCOMPILING)
find_program(gRPC_CPP_PLUGIN grpc_cpp_plugin)
else()
set(gRPC_CPP_PLUGIN $<TARGET_FILE:grpc_cpp_plugin>)
endif()
add_custom_command( add_custom_command(
OUTPUT "${_gRPC_PROTO_GENS_DIR}/${RELFIL_WE}.grpc.pb.cc" OUTPUT "${_gRPC_PROTO_GENS_DIR}/${RELFIL_WE}.grpc.pb.cc"
"${_gRPC_PROTO_GENS_DIR}/${RELFIL_WE}.grpc.pb.h" "${_gRPC_PROTO_GENS_DIR}/${RELFIL_WE}.grpc.pb.h"
@ -199,7 +206,7 @@ function(protobuf_generate_grpc_cpp)
COMMAND ${_gRPC_PROTOBUF_PROTOC_EXECUTABLE} COMMAND ${_gRPC_PROTOBUF_PROTOC_EXECUTABLE}
ARGS --grpc_out=generate_mock_code=true:${_gRPC_PROTO_GENS_DIR} ARGS --grpc_out=generate_mock_code=true:${_gRPC_PROTO_GENS_DIR}
--cpp_out=${_gRPC_PROTO_GENS_DIR} --cpp_out=${_gRPC_PROTO_GENS_DIR}
--plugin=protoc-gen-grpc=$<TARGET_FILE:grpc_cpp_plugin> --plugin=protoc-gen-grpc=${gRPC_CPP_PLUGIN}
${_protobuf_include_path} ${_protobuf_include_path}
${REL_FIL} ${REL_FIL}
DEPENDS ${ABS_FIL} ${_gRPC_PROTOBUF_PROTOC} grpc_cpp_plugin DEPENDS ${ABS_FIL} ${_gRPC_PROTOBUF_PROTOC} grpc_cpp_plugin

@ -239,6 +239,13 @@
get_filename_component(REL_DIR <%text>${REL_FIL}</%text> DIRECTORY) get_filename_component(REL_DIR <%text>${REL_FIL}</%text> DIRECTORY)
set(RELFIL_WE "<%text>${REL_DIR}/${FIL_WE}</%text>") set(RELFIL_WE "<%text>${REL_DIR}/${FIL_WE}</%text>")
#if cross-compiling, find host plugin
if(CMAKE_CROSSCOMPILING)
find_program(gRPC_CPP_PLUGIN grpc_cpp_plugin)
else()
set(gRPC_CPP_PLUGIN $<TARGET_FILE:grpc_cpp_plugin>)
endif()
add_custom_command( add_custom_command(
OUTPUT <%text>"${_gRPC_PROTO_GENS_DIR}/${RELFIL_WE}.grpc.pb.cc"</%text> OUTPUT <%text>"${_gRPC_PROTO_GENS_DIR}/${RELFIL_WE}.grpc.pb.cc"</%text>
<%text>"${_gRPC_PROTO_GENS_DIR}/${RELFIL_WE}.grpc.pb.h"</%text> <%text>"${_gRPC_PROTO_GENS_DIR}/${RELFIL_WE}.grpc.pb.h"</%text>
@ -248,7 +255,7 @@
COMMAND <%text>${_gRPC_PROTOBUF_PROTOC_EXECUTABLE}</%text> COMMAND <%text>${_gRPC_PROTOBUF_PROTOC_EXECUTABLE}</%text>
ARGS --grpc_out=<%text>generate_mock_code=true:${_gRPC_PROTO_GENS_DIR}</%text> ARGS --grpc_out=<%text>generate_mock_code=true:${_gRPC_PROTO_GENS_DIR}</%text>
--cpp_out=<%text>${_gRPC_PROTO_GENS_DIR}</%text> --cpp_out=<%text>${_gRPC_PROTO_GENS_DIR}</%text>
--plugin=protoc-gen-grpc=$<TARGET_FILE:grpc_cpp_plugin> --plugin=protoc-gen-grpc=<%text>${gRPC_CPP_PLUGIN}</%text>
<%text>${_protobuf_include_path}</%text> <%text>${_protobuf_include_path}</%text>
<%text>${REL_FIL}</%text> <%text>${REL_FIL}</%text>
DEPENDS <%text>${ABS_FIL}</%text> <%text>${_gRPC_PROTOBUF_PROTOC}</%text> grpc_cpp_plugin DEPENDS <%text>${ABS_FIL}</%text> <%text>${_gRPC_PROTOBUF_PROTOC}</%text> grpc_cpp_plugin

Loading…
Cancel
Save