blob: 54e0b99a46766ee0b3d3c05b01a26e1543946c4d [file] [log] [blame]
Brad Bishop1a4b7ee2018-12-16 17:11:34 -08001From 6d606f1101c1a172fb6d738d6f1865aa61849e68 Mon Sep 17 00:00:00 2001
Brad Bishop316dfdd2018-06-25 12:45:53 -04002From: Alexey Firago <alexey_firago@mentor.com>
3Date: Fri, 20 Oct 2017 00:04:19 +0300
4Subject: [PATCH] CMakeLists.txt: Fix grpc_cpp_plugin path during
Brad Bishop1a4b7ee2018-12-16 17:11:34 -08005 cross-compiling or native build
Brad Bishop316dfdd2018-06-25 12:45:53 -04006
7Signed-off-by: Alexey Firago <alexey_firago@mentor.com>
Brad Bishop1a4b7ee2018-12-16 17:11:34 -08008Signed-off-by: Hiram Lew <lew@avast.com>
9Signed-off-by: Jan Kaisrlik <jan.kaisrlik@avast.com>
Brad Bishop316dfdd2018-06-25 12:45:53 -040010---
11 CMakeLists.txt | 9 ++++++++-
12 templates/CMakeLists.txt.template | 9 ++++++++-
13 2 files changed, 16 insertions(+), 2 deletions(-)
14
15diff --git a/CMakeLists.txt b/CMakeLists.txt
Brad Bishop1a4b7ee2018-12-16 17:11:34 -080016index a59fd81..cd90424 100644
Brad Bishop316dfdd2018-06-25 12:45:53 -040017--- a/CMakeLists.txt
18+++ b/CMakeLists.txt
Brad Bishop1a4b7ee2018-12-16 17:11:34 -080019@@ -160,6 +160,13 @@ function(protobuf_generate_grpc_cpp)
Brad Bishop316dfdd2018-06-25 12:45:53 -040020 return()
21 endif()
Brad Bishop1a4b7ee2018-12-16 17:11:34 -080022
23+ #if cross-compiling or nativesdk, find host plugin
Brad Bishop316dfdd2018-06-25 12:45:53 -040024+ if(CMAKE_CROSSCOMPILING)
25+ find_program(gRPC_CPP_PLUGIN grpc_cpp_plugin)
26+ else()
27+ set(gRPC_CPP_PLUGIN $<TARGET_FILE:grpc_cpp_plugin>)
28+ endif()
29+
Brad Bishop1a4b7ee2018-12-16 17:11:34 -080030 set(_protobuf_include_path -I . -I ${_gRPC_PROTOBUF_WELLKNOWN_INCLUDE_DIR})
Brad Bishop316dfdd2018-06-25 12:45:53 -040031 foreach(FIL ${ARGN})
32 get_filename_component(ABS_FIL ${FIL} ABSOLUTE)
Brad Bishop1a4b7ee2018-12-16 17:11:34 -080033@@ -177,7 +184,7 @@ function(protobuf_generate_grpc_cpp)
Brad Bishop316dfdd2018-06-25 12:45:53 -040034 COMMAND ${_gRPC_PROTOBUF_PROTOC_EXECUTABLE}
35 ARGS --grpc_out=generate_mock_code=true:${_gRPC_PROTO_GENS_DIR}
36 --cpp_out=${_gRPC_PROTO_GENS_DIR}
37- --plugin=protoc-gen-grpc=$<TARGET_FILE:grpc_cpp_plugin>
38+ --plugin=protoc-gen-grpc=${gRPC_CPP_PLUGIN}
39 ${_protobuf_include_path}
40 ${REL_FIL}
41 DEPENDS ${ABS_FIL} ${_gRPC_PROTOBUF_PROTOC} grpc_cpp_plugin
42diff --git a/templates/CMakeLists.txt.template b/templates/CMakeLists.txt.template
Brad Bishop1a4b7ee2018-12-16 17:11:34 -080043index de13d02..b22bd5c 100644
Brad Bishop316dfdd2018-06-25 12:45:53 -040044--- a/templates/CMakeLists.txt.template
45+++ b/templates/CMakeLists.txt.template
Brad Bishop1a4b7ee2018-12-16 17:11:34 -080046@@ -209,6 +209,13 @@
Brad Bishop316dfdd2018-06-25 12:45:53 -040047 return()
48 endif()
Brad Bishop1a4b7ee2018-12-16 17:11:34 -080049
50+ #if cross-compiling or nativesdk, find host plugin
Brad Bishop316dfdd2018-06-25 12:45:53 -040051+ if(CMAKE_CROSSCOMPILING)
52+ find_program(gRPC_CPP_PLUGIN grpc_cpp_plugin)
53+ else()
54+ set(gRPC_CPP_PLUGIN $<TARGET_FILE:grpc_cpp_plugin>)
55+ endif()
56+
Brad Bishop1a4b7ee2018-12-16 17:11:34 -080057 set(_protobuf_include_path -I . -I <%text>${_gRPC_PROTOBUF_WELLKNOWN_INCLUDE_DIR}</%text>)
Brad Bishop316dfdd2018-06-25 12:45:53 -040058 foreach(FIL <%text>${ARGN}</%text>)
59 get_filename_component(ABS_FIL <%text>${FIL}</%text> ABSOLUTE)
Brad Bishop1a4b7ee2018-12-16 17:11:34 -080060@@ -226,7 +233,7 @@
Brad Bishop316dfdd2018-06-25 12:45:53 -040061 COMMAND <%text>${_gRPC_PROTOBUF_PROTOC_EXECUTABLE}</%text>
62 ARGS --grpc_out=<%text>generate_mock_code=true:${_gRPC_PROTO_GENS_DIR}</%text>
63 --cpp_out=<%text>${_gRPC_PROTO_GENS_DIR}</%text>
64- --plugin=protoc-gen-grpc=$<TARGET_FILE:grpc_cpp_plugin>
65+ --plugin=protoc-gen-grpc=${gRPC_CPP_PLUGIN}
66 <%text>${_protobuf_include_path}</%text>
67 <%text>${REL_FIL}</%text>
68 DEPENDS <%text>${ABS_FIL}</%text> <%text>${_gRPC_PROTOBUF_PROTOC}</%text> grpc_cpp_plugin
Brad Bishop1a4b7ee2018-12-16 17:11:34 -080069--
Brad Bishop316dfdd2018-06-25 12:45:53 -0400702.7.4
Brad Bishop1a4b7ee2018-12-16 17:11:34 -080071