summaryrefslogtreecommitdiffstats
path: root/recipes-connectivity/kuksa-val/kuksa-val/0002-Fix-gRPC-configuration-for-OE-cross-compiling.patch
blob: a7eaf10041eba9c8c61699d6fb30bd6ea4d2b4b7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
From 09eba6eef270a3f75add5c54b5455399aecceaf6 Mon Sep 17 00:00:00 2001
From: Scott Murray <scott.murray@konsulko.com>
Date: Thu, 6 Oct 2022 11:56:57 -0400
Subject: [PATCH 2/3] Fix gRPC configuration for OE cross-compiling

The gRPC CMake package that kuksa.val pulls in is problematic with
respect to cross-compiling with OpenEmbedded's split native and
target sysroots, as the location of the grpc_cpp_plugin does not
match the (somewhat ill-advised) assumptions in the original
upstream gRPC configuration.  To work around this, a patch to
gRPC is separately applied to split the plugins into their own
optional package, and the logic in grpc.cmake here tweaked to
explicitly take cross-compilation into account.

Upstream-Status: Pending

Signed-off-by: Scott Murray <scott.murray@konsulko.com>
---
 kuksa-val-server/grpc.cmake | 13 ++++++++++---
 1 file changed, 10 insertions(+), 3 deletions(-)

diff --git a/kuksa-val-server/grpc.cmake b/kuksa-val-server/grpc.cmake
index 4d90f1d..d097a69 100644
--- a/kuksa-val-server/grpc.cmake
+++ b/kuksa-val-server/grpc.cmake
@@ -14,14 +14,21 @@ set(gRPC_SSL_PROVIDER "package" CACHE STRING "Provider of ssl library")
 set(GRPC_VER 1.44.0)
 
 find_package(Protobuf)
-find_package(gRPC ${GRPC_VER} EXACT CONFIG)
+find_package(gRPC ${GRPC_VER} CONFIG)
+if(NOT CMAKE_CROSSCOMPILING)
+    find_package(gRPCPlugin ${GRPC_VER} CONFIG)
+    if(gRPCPlugin_FOUND)
+        set(_GRPC_CPP_PLUGIN_EXECUTABLE $<TARGET_FILE:gRPC::grpc_cpp_plugin>)
+    endif()
+else()
+    find_program(_GRPC_CPP_PLUGIN_EXECUTABLE grpc_cpp_plugin)
+endif()
 
-if(Protobuf_FOUND AND gRPC_FOUND)
+if(Protobuf_FOUND AND gRPC_FOUND AND _GRPC_CPP_PLUGIN_EXECUTABLE)
     message(STATUS "Using protobuf ${protobuf_VERSION}")
     message(STATUS "Using gRPC ${gRPC_VERSION}")
 
     set(_GRPC_GRPCPP gRPC::grpc++)
-    set(_GRPC_CPP_PLUGIN_EXECUTABLE $<TARGET_FILE:gRPC::grpc_cpp_plugin>)
     set(_REFLECTION gRPC::grpc++_reflection)
     set(_PROTOBUF_PROTOC $<TARGET_FILE:protobuf::protoc>)
 
-- 
2.37.3