Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 1 | From 6d606f1101c1a172fb6d738d6f1865aa61849e68 Mon Sep 17 00:00:00 2001 |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 2 | From: Alexey Firago <alexey_firago@mentor.com> |
| 3 | Date: Fri, 20 Oct 2017 00:04:19 +0300 |
Brad Bishop | 26bdd44 | 2019-08-16 17:08:17 -0400 | [diff] [blame^] | 4 | Subject: [PATCH] CMakeLists.txt: Fix grpc_cpp_plugin path during cross-compiling or native build |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 5 | |
| 6 | Signed-off-by: Alexey Firago <alexey_firago@mentor.com> |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 7 | Signed-off-by: Hiram Lew <lew@avast.com> |
| 8 | Signed-off-by: Jan Kaisrlik <jan.kaisrlik@avast.com> |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 9 | --- |
| 10 | CMakeLists.txt | 9 ++++++++- |
| 11 | templates/CMakeLists.txt.template | 9 ++++++++- |
| 12 | 2 files changed, 16 insertions(+), 2 deletions(-) |
| 13 | |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 14 | --- a/CMakeLists.txt |
| 15 | +++ b/CMakeLists.txt |
Brad Bishop | 26bdd44 | 2019-08-16 17:08:17 -0400 | [diff] [blame^] | 16 | @@ -193,6 +193,13 @@ function(protobuf_generate_grpc_cpp) |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 17 | return() |
| 18 | endif() |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 19 | |
| 20 | + #if cross-compiling or nativesdk, find host plugin |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 21 | + 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 Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 27 | set(_protobuf_include_path -I . -I ${_gRPC_PROTOBUF_WELLKNOWN_INCLUDE_DIR}) |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 28 | foreach(FIL ${ARGN}) |
| 29 | get_filename_component(ABS_FIL ${FIL} ABSOLUTE) |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 30 | --- a/templates/CMakeLists.txt.template |
| 31 | +++ b/templates/CMakeLists.txt.template |
Brad Bishop | 26bdd44 | 2019-08-16 17:08:17 -0400 | [diff] [blame^] | 32 | @@ -233,6 +233,13 @@ |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 33 | return() |
| 34 | endif() |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 35 | |
| 36 | + #if cross-compiling or nativesdk, find host plugin |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 37 | + 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 Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 43 | set(_protobuf_include_path -I . -I <%text>${_gRPC_PROTOBUF_WELLKNOWN_INCLUDE_DIR}</%text>) |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 44 | foreach(FIL <%text>${ARGN}</%text>) |
| 45 | get_filename_component(ABS_FIL <%text>${FIL}</%text> ABSOLUTE) |