1 From 09eba6eef270a3f75add5c54b5455399aecceaf6 Mon Sep 17 00:00:00 2001
2 From: Scott Murray <scott.murray@konsulko.com>
3 Date: Thu, 6 Oct 2022 11:56:57 -0400
4 Subject: [PATCH 2/3] 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.
15 Upstream-Status: Pending
17 Signed-off-by: Scott Murray <scott.murray@konsulko.com>
19 kuksa-val-server/grpc.cmake | 13 ++++++++++---
20 1 file changed, 10 insertions(+), 3 deletions(-)
22 diff --git a/kuksa-val-server/grpc.cmake b/kuksa-val-server/grpc.cmake
23 index 4d90f1d..d097a69 100644
24 --- a/kuksa-val-server/grpc.cmake
25 +++ b/kuksa-val-server/grpc.cmake
26 @@ -14,14 +14,21 @@ set(gRPC_SSL_PROVIDER "package" CACHE STRING "Provider of ssl library")
29 find_package(Protobuf)
30 -find_package(gRPC ${GRPC_VER} EXACT CONFIG)
31 +find_package(gRPC ${GRPC_VER} CONFIG)
32 +if(NOT CMAKE_CROSSCOMPILING)
33 + find_package(gRPCPlugin ${GRPC_VER} CONFIG)
34 + if(gRPCPlugin_FOUND)
35 + set(_GRPC_CPP_PLUGIN_EXECUTABLE $<TARGET_FILE:gRPC::grpc_cpp_plugin>)
38 + find_program(_GRPC_CPP_PLUGIN_EXECUTABLE grpc_cpp_plugin)
41 -if(Protobuf_FOUND AND gRPC_FOUND)
42 +if(Protobuf_FOUND AND gRPC_FOUND AND _GRPC_CPP_PLUGIN_EXECUTABLE)
43 message(STATUS "Using protobuf ${protobuf_VERSION}")
44 message(STATUS "Using gRPC ${gRPC_VERSION}")
46 set(_GRPC_GRPCPP gRPC::grpc++)
47 - set(_GRPC_CPP_PLUGIN_EXECUTABLE $<TARGET_FILE:gRPC::grpc_cpp_plugin>)
48 set(_REFLECTION gRPC::grpc++_reflection)
49 set(_PROTOBUF_PROTOC $<TARGET_FILE:protobuf::protoc>)