1 From f6c8584e181d3591b08e1f05a4f685912d7a94ce Mon Sep 17 00:00:00 2001
2 From: Scott Murray <scott.murray@konsulko.com>
3 Date: Mon, 23 May 2022 15:00:37 -0400
4 Subject: [PATCH 2/4] Fix gRPC configuration for OE cross-compiling
6 The gRPC CMake package that kuksa.val pulls in is problematic with
7 respect to cross-compiling with OpenEmbedded's split native and
8 target sysroots, as the location of the grpc_cpp_plugin does not
9 match the (somewhat ill-advised) assumptions in the original
10 upstream gRPC configuration. To work around this, a patch to
11 gRPC is separately applied to split the plugins into their own
12 optional package, and the logic in grpc.cmake here tweaked to
13 explicitly take cross-compilation into account. Additionally, the
14 explicit version requirement for gRPC is tweaked to 1.24.3 to allow
15 building with Yocto Project 3.1 aka dunfell or newer.
17 Upstream-Status: Pending
19 Signed-off-by: Scott Murray <scott.murray@konsulko.com>
21 grpc.cmake | 15 +++++++++++----
22 1 file changed, 11 insertions(+), 4 deletions(-)
24 diff --git a/grpc.cmake b/grpc.cmake
25 index c0228a0..30b3757 100644
29 # *****************************************************************************
31 set(gRPC_SSL_PROVIDER "package" CACHE STRING "Provider of ssl library")
35 find_package(Protobuf)
36 -find_package(gRPC ${GRPC_VER} EXACT CONFIG)
37 +find_package(gRPC ${GRPC_VER} CONFIG)
38 +if(NOT CMAKE_CROSSCOMPILING)
39 + find_package(gRPCPlugin ${GRPC_VER} CONFIG)
40 + if(gRPCPlugin_FOUND)
41 + set(_GRPC_CPP_PLUGIN_EXECUTABLE $<TARGET_FILE:gRPC::grpc_cpp_plugin>)
44 + find_program(_GRPC_CPP_PLUGIN_EXECUTABLE grpc_cpp_plugin)
47 -if(Protobuf_FOUND AND gRPC_FOUND)
48 +if(Protobuf_FOUND AND gRPC_FOUND AND _GRPC_CPP_PLUGIN_EXECUTABLE)
49 message(STATUS "Using protobuf ${protobuf_VERSION}")
50 message(STATUS "Using gRPC ${gRPC_VERSION}")
52 set(_GRPC_GRPCPP gRPC::grpc++)
53 - set(_GRPC_CPP_PLUGIN_EXECUTABLE $<TARGET_FILE:gRPC::grpc_cpp_plugin>)
54 set(_REFLECTION gRPC::grpc++_reflection)
55 set(_PROTOBUF_PROTOC $<TARGET_FILE:protobuf::protoc>)