6569f8b5dda0c0a96978028ffc9c0e062643790a
[AGL/meta-agl-demo.git] / recipes-connectivity / kuksa-val / kuksa-val / 0002-Fix-gRPC-configuration-for-OE-cross-compiling.patch
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
5
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.
16
17 Upstream-Status: Pending
18
19 Signed-off-by: Scott Murray <scott.murray@konsulko.com>
20 ---
21  grpc.cmake | 15 +++++++++++----
22  1 file changed, 11 insertions(+), 4 deletions(-)
23
24 diff --git a/grpc.cmake b/grpc.cmake
25 index c0228a0..30b3757 100644
26 --- a/grpc.cmake
27 +++ b/grpc.cmake
28 @@ -11,17 +11,24 @@
29  # *****************************************************************************
30  
31  set(gRPC_SSL_PROVIDER "package" CACHE STRING "Provider of ssl library")
32 -set(GRPC_VER 1.44.0)
33 +set(GRPC_VER 1.24.3)
34  
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>)
42 +    endif()
43 +else()
44 +    find_program(_GRPC_CPP_PLUGIN_EXECUTABLE grpc_cpp_plugin)
45 +endif()
46  
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}")
51  
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>)
56  
57 -- 
58 2.35.1
59