blob: 6cad53396421818c7867368b5c291f20e8ec1c04 [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
Brad Bishop26bdd442019-08-16 17:08:17 -04004Subject: [PATCH] CMakeLists.txt: Fix grpc_cpp_plugin path during cross-compiling or native build
Brad Bishop316dfdd2018-06-25 12:45:53 -04005
6Signed-off-by: Alexey Firago <alexey_firago@mentor.com>
Brad Bishop1a4b7ee2018-12-16 17:11:34 -08007Signed-off-by: Hiram Lew <lew@avast.com>
8Signed-off-by: Jan Kaisrlik <jan.kaisrlik@avast.com>
Brad Bishop316dfdd2018-06-25 12:45:53 -04009---
10 CMakeLists.txt | 9 ++++++++-
11 templates/CMakeLists.txt.template | 9 ++++++++-
12 2 files changed, 16 insertions(+), 2 deletions(-)
13
Brad Bishop316dfdd2018-06-25 12:45:53 -040014--- a/CMakeLists.txt
15+++ b/CMakeLists.txt
Brad Bishop26bdd442019-08-16 17:08:17 -040016@@ -193,6 +193,13 @@ function(protobuf_generate_grpc_cpp)
Brad Bishop316dfdd2018-06-25 12:45:53 -040017 return()
18 endif()
Brad Bishop1a4b7ee2018-12-16 17:11:34 -080019
20+ #if cross-compiling or nativesdk, find host plugin
Brad Bishop316dfdd2018-06-25 12:45:53 -040021+ if(CMAKE_CROSSCOMPILING)
22+ find_program(gRPC_CPP_PLUGIN grpc_cpp_plugin)
23+ else()
24+ set(gRPC_CPP_PLUGIN $<TARGET_FILE:grpc_cpp_plugin>)
25+ endif()
26+
Brad Bishop1a4b7ee2018-12-16 17:11:34 -080027 set(_protobuf_include_path -I . -I ${_gRPC_PROTOBUF_WELLKNOWN_INCLUDE_DIR})
Brad Bishop316dfdd2018-06-25 12:45:53 -040028 foreach(FIL ${ARGN})
29 get_filename_component(ABS_FIL ${FIL} ABSOLUTE)
Brad Bishop316dfdd2018-06-25 12:45:53 -040030--- a/templates/CMakeLists.txt.template
31+++ b/templates/CMakeLists.txt.template
Brad Bishop26bdd442019-08-16 17:08:17 -040032@@ -233,6 +233,13 @@
Brad Bishop316dfdd2018-06-25 12:45:53 -040033 return()
34 endif()
Brad Bishop1a4b7ee2018-12-16 17:11:34 -080035
36+ #if cross-compiling or nativesdk, find host plugin
Brad Bishop316dfdd2018-06-25 12:45:53 -040037+ if(CMAKE_CROSSCOMPILING)
38+ find_program(gRPC_CPP_PLUGIN grpc_cpp_plugin)
39+ else()
40+ set(gRPC_CPP_PLUGIN $<TARGET_FILE:grpc_cpp_plugin>)
41+ endif()
42+
Brad Bishop1a4b7ee2018-12-16 17:11:34 -080043 set(_protobuf_include_path -I . -I <%text>${_gRPC_PROTOBUF_WELLKNOWN_INCLUDE_DIR}</%text>)
Brad Bishop316dfdd2018-06-25 12:45:53 -040044 foreach(FIL <%text>${ARGN}</%text>)
45 get_filename_component(ABS_FIL <%text>${FIL}</%text> ABSOLUTE)