grpc: fix installed CMake package 58/27558/1
authorScott Murray <scott.murray@konsulko.com>
Wed, 25 May 2022 19:45:40 +0000 (15:45 -0400)
committerScott Murray <scott.murray@konsulko.com>
Thu, 26 May 2022 15:27:50 +0000 (11:27 -0400)
The CMake package configuration installed by grpc ends up not being
usable in practice.  Add a bbappend that adds the fixes:
- a do_install:append to correct the version number to the actual
  version, as it gets mangled somehow during the grpc build.  This
  is required to avoid triggering version mismatch checks when using
  the package in CMake.
- backport a fix from the kirkstone branch of meta-openembedded that
  splits the host tools (i.e. protoc plugins) out into a separate
  CMake package.  This avoids failures due to CMake not playing well
  with the split native versus target sysroots that OpenEmbedded
  uses.  This may be revisited if grpc upstream comes up with a
  different approach.

Bug-AGL: SPEC-4405

Signed-off-by: Scott Murray <scott.murray@konsulko.com>
Change-Id: Ia284901c148c1fcdf1b8ab77947d8be9445be631

recipes-devtools/grpc/files/0001-cmake-add-separate-export-for-plugin-targets.patch [new file with mode: 0644]
recipes-devtools/grpc/files/0001-cmake-add-separate-export-for-plugin-targets.patch.old [new file with mode: 0644]
recipes-devtools/grpc/grpc_1.24.3.bbappend [new file with mode: 0644]
recipes-devtools/grpc/grpc_agldemo.inc [new file with mode: 0644]

diff --git a/recipes-devtools/grpc/files/0001-cmake-add-separate-export-for-plugin-targets.patch b/recipes-devtools/grpc/files/0001-cmake-add-separate-export-for-plugin-targets.patch
new file mode 100644 (file)
index 0000000..545bb8f
--- /dev/null
@@ -0,0 +1,95 @@
+From 3150cb043363e05588062dd392b940be25594713 Mon Sep 17 00:00:00 2001
+From: Stefan Herbrechtsmeier <stefan.herbrechtsmeier@weidmueller.com>
+Date: Tue, 18 Feb 2020 14:17:07 +0100
+Subject: [PATCH] cmake: add separate export for plugin targets
+
+Upstream-Status: Submitted [https://github.com/grpc/grpc/pull/29328]
+
+[backported to grpc 1.24.3]
+Signed-off-by: Scott Murray <scott.murray@konsulko.com>
+
+---
+ CMakeLists.txt | 18 +++++++++++-------
+ 1 file changed, 11 insertions(+), 7 deletions(-)
+
+diff --git a/CMakeLists.txt b/CMakeLists.txt
+index 139eb12315..c2ac14cc17 100644
+--- a/CMakeLists.txt
++++ b/CMakeLists.txt
+@@ -13570,7 +13570,7 @@ target_link_libraries(grpc_cpp_plugin
+ if (gRPC_INSTALL)
+-  install(TARGETS grpc_cpp_plugin EXPORT gRPCTargets
++  install(TARGETS grpc_cpp_plugin EXPORT gRPCPluginTargets
+     RUNTIME DESTINATION ${gRPC_INSTALL_BINDIR}
+     LIBRARY DESTINATION ${gRPC_INSTALL_LIBDIR}
+     ARCHIVE DESTINATION ${gRPC_INSTALL_LIBDIR}
+@@ -13611,7 +13611,7 @@ target_link_libraries(grpc_csharp_plugin
+ if (gRPC_INSTALL)
+-  install(TARGETS grpc_csharp_plugin EXPORT gRPCTargets
++  install(TARGETS grpc_csharp_plugin EXPORT gRPCPluginTargets
+     RUNTIME DESTINATION ${gRPC_INSTALL_BINDIR}
+     LIBRARY DESTINATION ${gRPC_INSTALL_LIBDIR}
+     ARCHIVE DESTINATION ${gRPC_INSTALL_LIBDIR}
+@@ -13733,7 +13733,7 @@ target_link_libraries(grpc_node_plugin
+ if (gRPC_INSTALL)
+-  install(TARGETS grpc_node_plugin EXPORT gRPCTargets
++  install(TARGETS grpc_node_plugin EXPORT gRPCPluginTargets
+     RUNTIME DESTINATION ${gRPC_INSTALL_BINDIR}
+     LIBRARY DESTINATION ${gRPC_INSTALL_LIBDIR}
+     ARCHIVE DESTINATION ${gRPC_INSTALL_LIBDIR}
+@@ -13774,7 +13774,7 @@ target_link_libraries(grpc_objective_c_plugin
+ if (gRPC_INSTALL)
+-  install(TARGETS grpc_objective_c_plugin EXPORT gRPCTargets
++  install(TARGETS grpc_objective_c_plugin EXPORT gRPCPluginTargets
+     RUNTIME DESTINATION ${gRPC_INSTALL_BINDIR}
+     LIBRARY DESTINATION ${gRPC_INSTALL_LIBDIR}
+     ARCHIVE DESTINATION ${gRPC_INSTALL_LIBDIR}
+@@ -13815,7 +13815,7 @@ target_link_libraries(grpc_php_plugin
+ if (gRPC_INSTALL)
+-  install(TARGETS grpc_php_plugin EXPORT gRPCTargets
++  install(TARGETS grpc_php_plugin EXPORT gRPCPluginTargets
+     RUNTIME DESTINATION ${gRPC_INSTALL_BINDIR}
+     LIBRARY DESTINATION ${gRPC_INSTALL_LIBDIR}
+     ARCHIVE DESTINATION ${gRPC_INSTALL_LIBDIR}
+@@ -13856,7 +13856,7 @@ target_link_libraries(grpc_python_plugin
+ if (gRPC_INSTALL)
+-  install(TARGETS grpc_python_plugin EXPORT gRPCTargets
++  install(TARGETS grpc_python_plugin EXPORT gRPCPluginTargets
+     RUNTIME DESTINATION ${gRPC_INSTALL_BINDIR}
+     LIBRARY DESTINATION ${gRPC_INSTALL_LIBDIR}
+     ARCHIVE DESTINATION ${gRPC_INSTALL_LIBDIR}
+@@ -13897,7 +13897,7 @@ target_link_libraries(grpc_ruby_plugin
+ if (gRPC_INSTALL)
+-  install(TARGETS grpc_ruby_plugin EXPORT gRPCTargets
++  install(TARGETS grpc_ruby_plugin EXPORT gRPCPluginTargets
+     RUNTIME DESTINATION ${gRPC_INSTALL_BINDIR}
+     LIBRARY DESTINATION ${gRPC_INSTALL_LIBDIR}
+     ARCHIVE DESTINATION ${gRPC_INSTALL_LIBDIR}
+@@ -19499,6 +19499,10 @@ if (gRPC_INSTALL)
+     DESTINATION ${gRPC_INSTALL_CMAKEDIR}
+     NAMESPACE gRPC::
+   )
++  install(EXPORT gRPCPluginTargets
++    DESTINATION ${gRPC_INSTALL_CMAKEDIR}
++    NAMESPACE gRPC::
++  )
+ endif()
+ foreach(_config gRPCConfig gRPCConfigVersion)
+-- 
+2.35.1
+
diff --git a/recipes-devtools/grpc/files/0001-cmake-add-separate-export-for-plugin-targets.patch.old b/recipes-devtools/grpc/files/0001-cmake-add-separate-export-for-plugin-targets.patch.old
new file mode 100644 (file)
index 0000000..679bd38
--- /dev/null
@@ -0,0 +1,93 @@
+From 3150cb043363e05588062dd392b940be25594713 Mon Sep 17 00:00:00 2001
+From: Stefan Herbrechtsmeier <stefan.herbrechtsmeier@weidmueller.com>
+Date: Tue, 18 Feb 2020 14:17:07 +0100
+Subject: [PATCH] cmake: add separate export for plugin targets
+
+Upstream-Status: Submitted [https://github.com/grpc/grpc/pull/29328]
+
+
+---
+ CMakeLists.txt | 18 +++++++++++-------
+ 1 file changed, 11 insertions(+), 7 deletions(-)
+
+diff --git a/CMakeLists.txt b/CMakeLists.txt
+index efdaf8936d..6608b1b00c 100644
+--- a/CMakeLists.txt
++++ b/CMakeLists.txt
+@@ -10935,7 +10935,7 @@ target_link_libraries(grpc_cpp_plugin
+ if(gRPC_INSTALL)
+-  install(TARGETS grpc_cpp_plugin EXPORT gRPCTargets
++  install(TARGETS grpc_cpp_plugin EXPORT gRPCPluginTargets
+     RUNTIME DESTINATION ${gRPC_INSTALL_BINDIR}
+     BUNDLE DESTINATION  ${gRPC_INSTALL_BINDIR}
+     LIBRARY DESTINATION ${gRPC_INSTALL_LIBDIR}
+@@ -10975,7 +10975,7 @@ target_link_libraries(grpc_csharp_plugin
+ if(gRPC_INSTALL)
+-  install(TARGETS grpc_csharp_plugin EXPORT gRPCTargets
++  install(TARGETS grpc_csharp_plugin EXPORT gRPCPluginTargets
+     RUNTIME DESTINATION ${gRPC_INSTALL_BINDIR}
+     BUNDLE DESTINATION  ${gRPC_INSTALL_BINDIR}
+     LIBRARY DESTINATION ${gRPC_INSTALL_LIBDIR}
+@@ -11015,7 +11015,7 @@ target_link_libraries(grpc_node_plugin
+ if(gRPC_INSTALL)
+-  install(TARGETS grpc_node_plugin EXPORT gRPCTargets
++  install(TARGETS grpc_node_plugin EXPORT gRPCPluginTargets
+     RUNTIME DESTINATION ${gRPC_INSTALL_BINDIR}
+     BUNDLE DESTINATION  ${gRPC_INSTALL_BINDIR}
+     LIBRARY DESTINATION ${gRPC_INSTALL_LIBDIR}
+@@ -11055,7 +11055,7 @@ target_link_libraries(grpc_objective_c_plugin
+ if(gRPC_INSTALL)
+-  install(TARGETS grpc_objective_c_plugin EXPORT gRPCTargets
++  install(TARGETS grpc_objective_c_plugin EXPORT gRPCPluginTargets
+     RUNTIME DESTINATION ${gRPC_INSTALL_BINDIR}
+     BUNDLE DESTINATION  ${gRPC_INSTALL_BINDIR}
+     LIBRARY DESTINATION ${gRPC_INSTALL_LIBDIR}
+@@ -11095,7 +11095,7 @@ target_link_libraries(grpc_php_plugin
+ if(gRPC_INSTALL)
+-  install(TARGETS grpc_php_plugin EXPORT gRPCTargets
++  install(TARGETS grpc_php_plugin EXPORT gRPCPluginTargets
+     RUNTIME DESTINATION ${gRPC_INSTALL_BINDIR}
+     BUNDLE DESTINATION  ${gRPC_INSTALL_BINDIR}
+     LIBRARY DESTINATION ${gRPC_INSTALL_LIBDIR}
+@@ -11135,7 +11135,7 @@ target_link_libraries(grpc_python_plugin
+ if(gRPC_INSTALL)
+-  install(TARGETS grpc_python_plugin EXPORT gRPCTargets
++  install(TARGETS grpc_python_plugin EXPORT gRPCPluginTargets
+     RUNTIME DESTINATION ${gRPC_INSTALL_BINDIR}
+     BUNDLE DESTINATION  ${gRPC_INSTALL_BINDIR}
+     LIBRARY DESTINATION ${gRPC_INSTALL_LIBDIR}
+@@ -11175,7 +11175,7 @@ target_link_libraries(grpc_ruby_plugin
+ if(gRPC_INSTALL)
+-  install(TARGETS grpc_ruby_plugin EXPORT gRPCTargets
++  install(TARGETS grpc_ruby_plugin EXPORT gRPCPluginTargets
+     RUNTIME DESTINATION ${gRPC_INSTALL_BINDIR}
+     BUNDLE DESTINATION  ${gRPC_INSTALL_BINDIR}
+     LIBRARY DESTINATION ${gRPC_INSTALL_LIBDIR}
+@@ -17349,6 +17349,10 @@ if(gRPC_INSTALL)
+     DESTINATION ${gRPC_INSTALL_CMAKEDIR}
+     NAMESPACE gRPC::
+   )
++  install(EXPORT gRPCPluginTargets
++    DESTINATION ${gRPC_INSTALL_CMAKEDIR}
++    NAMESPACE gRPC::
++  )
+ endif()
+ include(CMakePackageConfigHelpers)
+-- 
+2.30.2
+
diff --git a/recipes-devtools/grpc/grpc_1.24.3.bbappend b/recipes-devtools/grpc/grpc_1.24.3.bbappend
new file mode 100644 (file)
index 0000000..d3fe698
--- /dev/null
@@ -0,0 +1 @@
+require ${@bb.utils.contains('AGL_FEATURES', 'agldemo', 'grpc_agldemo.inc', '', d)}
diff --git a/recipes-devtools/grpc/grpc_agldemo.inc b/recipes-devtools/grpc/grpc_agldemo.inc
new file mode 100644 (file)
index 0000000..73ab083
--- /dev/null
@@ -0,0 +1,12 @@
+FILESEXTRAPATHS:prepend := "${THISDIR}/files:"
+
+SRC_URI += "file://0001-cmake-add-separate-export-for-plugin-targets.patch"
+
+do_install:append() {
+    # The gRPC package version seems to get clobbered in its CMake
+    # package (seemingly with the c-ares version), but the root cause
+    # is not obvious and the issue is not present with newer versions
+    # of things in kirkstone.  So for now just fix the version to
+    # avoid mismatch errors.
+    sed -i "s/^set(PACKAGE_VERSION \"1\.16\.1\")$/set(PACKAGE_VERSION \"${PV}\")/" ${D}/${libdir}/cmake/${BPN}/gRPCConfigVersion.cmake
+}