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 |
| 4 | Subject: [PATCH] CMakeLists.txt: Fix grpc_cpp_plugin path during |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame^] | 5 | cross-compiling or native build |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 6 | |
| 7 | Signed-off-by: Alexey Firago <alexey_firago@mentor.com> |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame^] | 8 | Signed-off-by: Hiram Lew <lew@avast.com> |
| 9 | Signed-off-by: Jan Kaisrlik <jan.kaisrlik@avast.com> |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 10 | --- |
| 11 | CMakeLists.txt | 9 ++++++++- |
| 12 | templates/CMakeLists.txt.template | 9 ++++++++- |
| 13 | 2 files changed, 16 insertions(+), 2 deletions(-) |
| 14 | |
| 15 | diff --git a/CMakeLists.txt b/CMakeLists.txt |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame^] | 16 | index a59fd81..cd90424 100644 |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 17 | --- a/CMakeLists.txt |
| 18 | +++ b/CMakeLists.txt |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame^] | 19 | @@ -160,6 +160,13 @@ function(protobuf_generate_grpc_cpp) |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 20 | return() |
| 21 | endif() |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame^] | 22 | |
| 23 | + #if cross-compiling or nativesdk, find host plugin |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 24 | + 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 Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame^] | 30 | set(_protobuf_include_path -I . -I ${_gRPC_PROTOBUF_WELLKNOWN_INCLUDE_DIR}) |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 31 | foreach(FIL ${ARGN}) |
| 32 | get_filename_component(ABS_FIL ${FIL} ABSOLUTE) |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame^] | 33 | @@ -177,7 +184,7 @@ function(protobuf_generate_grpc_cpp) |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 34 | 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 |
| 42 | diff --git a/templates/CMakeLists.txt.template b/templates/CMakeLists.txt.template |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame^] | 43 | index de13d02..b22bd5c 100644 |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 44 | --- a/templates/CMakeLists.txt.template |
| 45 | +++ b/templates/CMakeLists.txt.template |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame^] | 46 | @@ -209,6 +209,13 @@ |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 47 | return() |
| 48 | endif() |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame^] | 49 | |
| 50 | + #if cross-compiling or nativesdk, find host plugin |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 51 | + 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 Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame^] | 57 | 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] | 58 | foreach(FIL <%text>${ARGN}</%text>) |
| 59 | get_filename_component(ABS_FIL <%text>${FIL}</%text> ABSOLUTE) |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame^] | 60 | @@ -226,7 +233,7 @@ |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 61 | 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 Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame^] | 69 | -- |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 70 | 2.7.4 |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame^] | 71 | |