All of lore.kernel.org
 help / color / mirror / Atom feed
* [meta-oe][PATCH v2 1/2] grpc: add cmake support for target
@ 2022-04-08  7:30 Stefan Herbrechtsmeier
  2022-04-08  7:30 ` [meta-oe][PATCH v2 2/2] grpc: remove useless link with libatomic append Stefan Herbrechtsmeier
  2022-04-08 12:25 ` [oe] [meta-oe][PATCH v2 1/2] grpc: add cmake support for target Clément Péron
  0 siblings, 2 replies; 6+ messages in thread
From: Stefan Herbrechtsmeier @ 2022-04-08  7:30 UTC (permalink / raw)
  To: openembedded-devel; +Cc: Stefan Herbrechtsmeier

From: Stefan Herbrechtsmeier <stefan.herbrechtsmeier@weidmueller.com>

The CMake gRPC config checks for binaries and fails if a binary (plugin)
is missing. Fix the problem in the code and add the CMake gRPC config
back to the target package.

Signed-off-by: Stefan Herbrechtsmeier <stefan.herbrechtsmeier@weidmueller.com>

---

Changes in v2:
- Rebase on top of latest master

 ...d-separate-export-for-plugin-targets.patch | 93 +++++++++++++++++++
 meta-oe/recipes-devtools/grpc/grpc_1.45.1.bb  |  3 +-
 2 files changed, 94 insertions(+), 2 deletions(-)
 create mode 100644 meta-oe/recipes-devtools/grpc/grpc/0001-cmake-add-separate-export-for-plugin-targets.patch

diff --git a/meta-oe/recipes-devtools/grpc/grpc/0001-cmake-add-separate-export-for-plugin-targets.patch b/meta-oe/recipes-devtools/grpc/grpc/0001-cmake-add-separate-export-for-plugin-targets.patch
new file mode 100644
index 000000000..679bd3882
--- /dev/null
+++ b/meta-oe/recipes-devtools/grpc/grpc/0001-cmake-add-separate-export-for-plugin-targets.patch
@@ -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/meta-oe/recipes-devtools/grpc/grpc_1.45.1.bb b/meta-oe/recipes-devtools/grpc/grpc_1.45.1.bb
index 872bc6afc..292ea7f9b 100644
--- a/meta-oe/recipes-devtools/grpc/grpc_1.45.1.bb
+++ b/meta-oe/recipes-devtools/grpc/grpc_1.45.1.bb
@@ -24,6 +24,7 @@ SRCREV_grpc = "1c159689ceda2c408f7f9d97d96a264c9521b806"
 BRANCH = "v1.45.x"
 SRC_URI = "git://github.com/grpc/grpc.git;protocol=https;name=grpc;branch=${BRANCH} \
            file://0001-Revert-Changed-GRPCPP_ABSEIL_SYNC-to-GPR_ABSEIL_SYNC.patch \
+           file://0001-cmake-add-separate-export-for-plugin-targets.patch \
            "
 # Fixes build with older compilers 4.8 especially on ubuntu 14.04
 CXXFLAGS:append:class-native = " -Wl,--no-as-needed"
@@ -80,8 +81,6 @@ do_configure:prepend:toolchain-clang:x86() {
 
 BBCLASSEXTEND = "native nativesdk"
 
-SYSROOT_DIRS_IGNORE:append:class-target = " ${baselib}/cmake/grpc"
-
 FILES:${PN}-compiler += " \
     ${bindir} \
     ${libdir}/libgrpc_plugin_support${SOLIBS} \
-- 
2.30.2



^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [meta-oe][PATCH v2 2/2] grpc: remove useless link with libatomic append
  2022-04-08  7:30 [meta-oe][PATCH v2 1/2] grpc: add cmake support for target Stefan Herbrechtsmeier
@ 2022-04-08  7:30 ` Stefan Herbrechtsmeier
  2022-04-08 12:25 ` [oe] [meta-oe][PATCH v2 1/2] grpc: add cmake support for target Clément Péron
  1 sibling, 0 replies; 6+ messages in thread
From: Stefan Herbrechtsmeier @ 2022-04-08  7:30 UTC (permalink / raw)
  To: openembedded-devel; +Cc: Stefan Herbrechtsmeier

From: Stefan Herbrechtsmeier <stefan.herbrechtsmeier@weidmueller.com>

The sed commands to link with libatomic don't match and is therefore
useless. If they are really needed the problem should be fixed in the
code for example with CHECK_LIBRARY_EXISTS.

Signed-off-by: Stefan Herbrechtsmeier <stefan.herbrechtsmeier@weidmueller.com>

---

(no changes since v1)

 meta-oe/recipes-devtools/grpc/grpc_1.45.1.bb | 20 --------------------
 1 file changed, 20 deletions(-)

diff --git a/meta-oe/recipes-devtools/grpc/grpc_1.45.1.bb b/meta-oe/recipes-devtools/grpc/grpc_1.45.1.bb
index 292ea7f9b..7275f451a 100644
--- a/meta-oe/recipes-devtools/grpc/grpc_1.45.1.bb
+++ b/meta-oe/recipes-devtools/grpc/grpc_1.45.1.bb
@@ -59,26 +59,6 @@ do_configure:prepend() {
     sed -i -e "s#lib/pkgconfig/#${baselib}/pkgconfig/#g" ${S}/CMakeLists.txt
 }
 
-do_configure:prepend:mipsarch() {
-    sed -i -e "s/set(_gRPC_ALLTARGETS_LIBRARIES \${CMAKE_DL_LIBS} rt m pthread)/set(_gRPC_ALLTARGETS_LIBRARIES \${CMAKE_DL_LIBS} atomic rt m pthread)/g" ${S}/CMakeLists.txt
-}
-
-do_configure:prepend:powerpc() {
-    sed -i -e "s/set(_gRPC_ALLTARGETS_LIBRARIES \${CMAKE_DL_LIBS} rt m pthread)/set(_gRPC_ALLTARGETS_LIBRARIES \${CMAKE_DL_LIBS} atomic rt m pthread)/g" ${S}/CMakeLists.txt
-}
-
-do_configure:prepend:riscv64() {
-    sed -i -e "s/set(_gRPC_ALLTARGETS_LIBRARIES \${CMAKE_DL_LIBS} rt m pthread)/set(_gRPC_ALLTARGETS_LIBRARIES \${CMAKE_DL_LIBS} atomic rt m pthread)/g" ${S}/CMakeLists.txt
-}
-
-do_configure:prepend:riscv32() {
-    sed -i -e "s/set(_gRPC_ALLTARGETS_LIBRARIES \${CMAKE_DL_LIBS} rt m pthread)/set(_gRPC_ALLTARGETS_LIBRARIES \${CMAKE_DL_LIBS} atomic rt m pthread)/g" ${S}/CMakeLists.txt
-}
-
-do_configure:prepend:toolchain-clang:x86() {
-    sed -i -e "s/set(_gRPC_ALLTARGETS_LIBRARIES \${CMAKE_DL_LIBS} rt m pthread)/set(_gRPC_ALLTARGETS_LIBRARIES \${CMAKE_DL_LIBS} atomic rt m pthread)/g" ${S}/CMakeLists.txt
-}
-
 BBCLASSEXTEND = "native nativesdk"
 
 FILES:${PN}-compiler += " \
-- 
2.30.2



^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [oe] [meta-oe][PATCH v2 1/2] grpc: add cmake support for target
  2022-04-08  7:30 [meta-oe][PATCH v2 1/2] grpc: add cmake support for target Stefan Herbrechtsmeier
  2022-04-08  7:30 ` [meta-oe][PATCH v2 2/2] grpc: remove useless link with libatomic append Stefan Herbrechtsmeier
@ 2022-04-08 12:25 ` Clément Péron
  2022-04-08 12:47   ` Stefan Herbrechtsmeier
  1 sibling, 1 reply; 6+ messages in thread
From: Clément Péron @ 2022-04-08 12:25 UTC (permalink / raw)
  To: Stefan Herbrechtsmeier; +Cc: openembeded-devel, Stefan Herbrechtsmeier

Hi Stefan,

On Fri, 8 Apr 2022 at 09:30, Stefan Herbrechtsmeier
<stefan.herbrechtsmeier-oss@weidmueller.com> wrote:
>
> From: Stefan Herbrechtsmeier <stefan.herbrechtsmeier@weidmueller.com>
>
> The CMake gRPC config checks for binaries and fails if a binary (plugin)
> is missing. Fix the problem in the code and add the CMake gRPC config
> back to the target package.

Thanks for your patch, I'm still using gRPC 1.35 + your previous similar patch.
I'm trying to bump to gRPC 1.45.1 + these patches.

My recipe use CMake and depends on grpc and grpc-native:
PACKAGECONFIG[grpc] = "-DCONFIG_GRPC=ON,-DCONFIG_GRPC=OFF,grpc grpc-native"

But unfortunately CMake doesn't find the grpc_cpp_plugin.

| -- Using gRPC 1.45.1
....
| CMake Error at modules/grpc/CMakeLists.txt:37 (add_custom_command):
|   Error evaluating generator expression:
|
|     $<TARGET_FILE:gRPC::grpc_cpp_plugin>
|
|   No target "gRPC::grpc_cpp_plugin"
|
|
| CMake Error at modules/grpc/CMakeLists.txt:37 (add_custom_command):
|   Error evaluating generator expression:
|
|     $<TARGET_FILE:gRPC::grpc_cpp_plugin>
|
|   No target "gRPC::grpc_cpp_plugin"
|
|
| CMake Error at modules/grpc/CMakeLists.txt:37 (add_custom_command):
|   Error evaluating generator expression:
|
|     $<TARGET_FILE:gRPC::grpc_cpp_plugin>
|
|   No target "gRPC::grpc_cpp_plugin"

Here is my CMake source file:

# Find Protobuf installation Yocto SDK doensn't support protobuf-config.cmake
# for the moment
set(protobuf_MODULE_COMPATIBLE TRUE)
find_package(Protobuf REQUIRED)
message(STATUS "Using protobuf ${Protobuf_VERSION}")
set(_PROTOBUF_LIBPROTOBUF protobuf::libprotobuf)

# Find gRPC installation Looks for gRPCConfig.cmake file installed by gRPC's
# cmake installation.
find_package(gRPC CONFIG REQUIRED)
message(STATUS "Using gRPC ${gRPC_VERSION}")
set(_REFLECTION gRPC::grpc++_reflection)
set(_GRPC_GRPCPP gRPC::grpc++)

# Get full path of protobuf/gRPC compiler
set(_PROTOBUF_PROTOC $<TARGET_FILE:protobuf::protoc>)
set(_GRPC_CPP_PLUGIN_EXECUTABLE $<TARGET_FILE:gRPC::grpc_cpp_plugin>)

Do you have an example of how you look for gRPC in your recipe?

Thanks for your help
Regards,
Clement

>
> Signed-off-by: Stefan Herbrechtsmeier <stefan.herbrechtsmeier@weidmueller.com>
>
> ---
>
> Changes in v2:
> - Rebase on top of latest master
>
>  ...d-separate-export-for-plugin-targets.patch | 93 +++++++++++++++++++
>  meta-oe/recipes-devtools/grpc/grpc_1.45.1.bb  |  3 +-
>  2 files changed, 94 insertions(+), 2 deletions(-)
>  create mode 100644 meta-oe/recipes-devtools/grpc/grpc/0001-cmake-add-separate-export-for-plugin-targets.patch
>
> diff --git a/meta-oe/recipes-devtools/grpc/grpc/0001-cmake-add-separate-export-for-plugin-targets.patch b/meta-oe/recipes-devtools/grpc/grpc/0001-cmake-add-separate-export-for-plugin-targets.patch
> new file mode 100644
> index 000000000..679bd3882
> --- /dev/null
> +++ b/meta-oe/recipes-devtools/grpc/grpc/0001-cmake-add-separate-export-for-plugin-targets.patch
> @@ -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/meta-oe/recipes-devtools/grpc/grpc_1.45.1.bb b/meta-oe/recipes-devtools/grpc/grpc_1.45.1.bb
> index 872bc6afc..292ea7f9b 100644
> --- a/meta-oe/recipes-devtools/grpc/grpc_1.45.1.bb
> +++ b/meta-oe/recipes-devtools/grpc/grpc_1.45.1.bb
> @@ -24,6 +24,7 @@ SRCREV_grpc = "1c159689ceda2c408f7f9d97d96a264c9521b806"
>  BRANCH = "v1.45.x"
>  SRC_URI = "git://github.com/grpc/grpc.git;protocol=https;name=grpc;branch=${BRANCH} \
>             file://0001-Revert-Changed-GRPCPP_ABSEIL_SYNC-to-GPR_ABSEIL_SYNC.patch \
> +           file://0001-cmake-add-separate-export-for-plugin-targets.patch \
>             "
>  # Fixes build with older compilers 4.8 especially on ubuntu 14.04
>  CXXFLAGS:append:class-native = " -Wl,--no-as-needed"
> @@ -80,8 +81,6 @@ do_configure:prepend:toolchain-clang:x86() {
>
>  BBCLASSEXTEND = "native nativesdk"
>
> -SYSROOT_DIRS_IGNORE:append:class-target = " ${baselib}/cmake/grpc"
> -
>  FILES:${PN}-compiler += " \
>      ${bindir} \
>      ${libdir}/libgrpc_plugin_support${SOLIBS} \
> --
> 2.30.2
>
>
> -=-=-=-=-=-=-=-=-=-=-=-
> Links: You receive all messages sent to this group.
> View/Reply Online (#96473): https://lists.openembedded.org/g/openembedded-devel/message/96473
> Mute This Topic: https://lists.openembedded.org/mt/90331029/4240582
> Group Owner: openembedded-devel+owner@lists.openembedded.org
> Unsubscribe: https://lists.openembedded.org/g/openembedded-devel/unsub [peron.clem@gmail.com]
> -=-=-=-=-=-=-=-=-=-=-=-
>


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [oe] [meta-oe][PATCH v2 1/2] grpc: add cmake support for target
  2022-04-08 12:25 ` [oe] [meta-oe][PATCH v2 1/2] grpc: add cmake support for target Clément Péron
@ 2022-04-08 12:47   ` Stefan Herbrechtsmeier
  2022-04-08 19:12     ` Clément Péron
  0 siblings, 1 reply; 6+ messages in thread
From: Stefan Herbrechtsmeier @ 2022-04-08 12:47 UTC (permalink / raw)
  To: Clément Péron; +Cc: openembeded-devel, Stefan Herbrechtsmeier

Hi Clement,

Am 08.04.2022 um 14:25 schrieb Clément Péron:
> Hi Stefan,
> 
> On Fri, 8 Apr 2022 at 09:30, Stefan Herbrechtsmeier
> <stefan.herbrechtsmeier-oss@weidmueller.com> wrote:
>>
>> From: Stefan Herbrechtsmeier <stefan.herbrechtsmeier@weidmueller.com>
>>
>> The CMake gRPC config checks for binaries and fails if a binary (plugin)
>> is missing. Fix the problem in the code and add the CMake gRPC config
>> back to the target package.
> 
> Thanks for your patch, I'm still using gRPC 1.35 + your previous similar patch.
> I'm trying to bump to gRPC 1.45.1 + these patches.
> 
> My recipe use CMake and depends on grpc and grpc-native:
> PACKAGECONFIG[grpc] = "-DCONFIG_GRPC=ON,-DCONFIG_GRPC=OFF,grpc grpc-native"
> 
> But unfortunately CMake doesn't find the grpc_cpp_plugin.

This is the correct behavior of my patch because the grpc_cpp_plugin 
from the cross build isn't usable during cross build. You need the 
grpc_cpp_plugin from the host and therefore have to search the 
grpc_cpp_plugin by yourself during cross compile [1].

My first patch was rejected and therefore I create a minimal patch which 
only make the CMake gRPC config usable.

> 
> | -- Using gRPC 1.45.1
> ....
> | CMake Error at modules/grpc/CMakeLists.txt:37 (add_custom_command):
> |   Error evaluating generator expression:
> |
> |     $<TARGET_FILE:gRPC::grpc_cpp_plugin>
> |
> |   No target "gRPC::grpc_cpp_plugin"
> |
> |
> | CMake Error at modules/grpc/CMakeLists.txt:37 (add_custom_command):
> |   Error evaluating generator expression:
> |
> |     $<TARGET_FILE:gRPC::grpc_cpp_plugin>
> |
> |   No target "gRPC::grpc_cpp_plugin"
> |
> |
> | CMake Error at modules/grpc/CMakeLists.txt:37 (add_custom_command):
> |   Error evaluating generator expression:
> |
> |     $<TARGET_FILE:gRPC::grpc_cpp_plugin>
> |
> |   No target "gRPC::grpc_cpp_plugin"
> 
> Here is my CMake source file:
> 
> # Find Protobuf installation Yocto SDK doensn't support protobuf-config.cmake
> # for the moment
> set(protobuf_MODULE_COMPATIBLE TRUE)
> find_package(Protobuf REQUIRED)
> message(STATUS "Using protobuf ${Protobuf_VERSION}")
> set(_PROTOBUF_LIBPROTOBUF protobuf::libprotobuf)
> 
> # Find gRPC installation Looks for gRPCConfig.cmake file installed by gRPC's
> # cmake installation.
> find_package(gRPC CONFIG REQUIRED)
> message(STATUS "Using gRPC ${gRPC_VERSION}")
> set(_REFLECTION gRPC::grpc++_reflection)
> set(_GRPC_GRPCPP gRPC::grpc++)
> 
> # Get full path of protobuf/gRPC compiler
> set(_PROTOBUF_PROTOC $<TARGET_FILE:protobuf::protoc>)
> set(_GRPC_CPP_PLUGIN_EXECUTABLE $<TARGET_FILE:gRPC::grpc_cpp_plugin>)

You have to search the binaries if you cross compile [1]:

if(CMAKE_CROSSCOMPILING)
   find_program(_GRPC_CPP_PLUGIN_EXECUTABLE grpc_cpp_plugin)
else()
   set(_GRPC_CPP_PLUGIN_EXECUTABLE $<TARGET_FILE:gRPC::grpc_cpp_plugin>)
endif()

> 
> Do you have an example of how you look for gRPC in your recipe?

This isn't possible because you use a target and not a variable.

[1] https://github.com/grpc/grpc/blob/master/examples/cpp/cmake/common.cmake

Regards
   Stefan


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [oe] [meta-oe][PATCH v2 1/2] grpc: add cmake support for target
  2022-04-08 12:47   ` Stefan Herbrechtsmeier
@ 2022-04-08 19:12     ` Clément Péron
  2022-04-11  7:09       ` Stefan Herbrechtsmeier
  0 siblings, 1 reply; 6+ messages in thread
From: Clément Péron @ 2022-04-08 19:12 UTC (permalink / raw)
  To: Stefan Herbrechtsmeier; +Cc: openembeded-devel, Stefan Herbrechtsmeier

Hi Stefan,

On Fri, 8 Apr 2022 at 14:47, Stefan Herbrechtsmeier
<stefan.herbrechtsmeier-oss@weidmueller.com> wrote:
>
> Hi Clement,
>
> Am 08.04.2022 um 14:25 schrieb Clément Péron:
> > Hi Stefan,
> >
> > On Fri, 8 Apr 2022 at 09:30, Stefan Herbrechtsmeier
> > <stefan.herbrechtsmeier-oss@weidmueller.com> wrote:
> >>
> >> From: Stefan Herbrechtsmeier <stefan.herbrechtsmeier@weidmueller.com>
> >>
> >> The CMake gRPC config checks for binaries and fails if a binary (plugin)
> >> is missing. Fix the problem in the code and add the CMake gRPC config
> >> back to the target package.
> >
> > Thanks for your patch, I'm still using gRPC 1.35 + your previous similar patch.
> > I'm trying to bump to gRPC 1.45.1 + these patches.
> >
> > My recipe use CMake and depends on grpc and grpc-native:
> > PACKAGECONFIG[grpc] = "-DCONFIG_GRPC=ON,-DCONFIG_GRPC=OFF,grpc grpc-native"
> >
> > But unfortunately CMake doesn't find the grpc_cpp_plugin.
>
> This is the correct behavior of my patch because the grpc_cpp_plugin
> from the cross build isn't usable during cross build. You need the
> grpc_cpp_plugin from the host and therefore have to search the
> grpc_cpp_plugin by yourself during cross compile [1].
>
> My first patch was rejected and therefore I create a minimal patch which
> only make the CMake gRPC config usable.
>
> >
> > | -- Using gRPC 1.45.1
> > ....
> > | CMake Error at modules/grpc/CMakeLists.txt:37 (add_custom_command):
> > |   Error evaluating generator expression:
> > |
> > |     $<TARGET_FILE:gRPC::grpc_cpp_plugin>
> > |
> > |   No target "gRPC::grpc_cpp_plugin"
> > |
> > |
> > | CMake Error at modules/grpc/CMakeLists.txt:37 (add_custom_command):
> > |   Error evaluating generator expression:
> > |
> > |     $<TARGET_FILE:gRPC::grpc_cpp_plugin>
> > |
> > |   No target "gRPC::grpc_cpp_plugin"
> > |
> > |
> > | CMake Error at modules/grpc/CMakeLists.txt:37 (add_custom_command):
> > |   Error evaluating generator expression:
> > |
> > |     $<TARGET_FILE:gRPC::grpc_cpp_plugin>
> > |
> > |   No target "gRPC::grpc_cpp_plugin"
> >
> > Here is my CMake source file:
> >
> > # Find Protobuf installation Yocto SDK doensn't support protobuf-config.cmake
> > # for the moment
> > set(protobuf_MODULE_COMPATIBLE TRUE)
> > find_package(Protobuf REQUIRED)
> > message(STATUS "Using protobuf ${Protobuf_VERSION}")
> > set(_PROTOBUF_LIBPROTOBUF protobuf::libprotobuf)
> >
> > # Find gRPC installation Looks for gRPCConfig.cmake file installed by gRPC's
> > # cmake installation.
> > find_package(gRPC CONFIG REQUIRED)
> > message(STATUS "Using gRPC ${gRPC_VERSION}")
> > set(_REFLECTION gRPC::grpc++_reflection)
> > set(_GRPC_GRPCPP gRPC::grpc++)
> >
> > # Get full path of protobuf/gRPC compiler
> > set(_PROTOBUF_PROTOC $<TARGET_FILE:protobuf::protoc>)
> > set(_GRPC_CPP_PLUGIN_EXECUTABLE $<TARGET_FILE:gRPC::grpc_cpp_plugin>)
>
> You have to search the binaries if you cross compile [1]:
>
> if(CMAKE_CROSSCOMPILING)
>    find_program(_GRPC_CPP_PLUGIN_EXECUTABLE grpc_cpp_plugin)
> else()
>    set(_GRPC_CPP_PLUGIN_EXECUTABLE $<TARGET_FILE:gRPC::grpc_cpp_plugin>)
> endif()

Thanks this fix my issue

Tested-by: Clément Péron <peron.clem@gmail.com>

>
> >
> > Do you have an example of how you look for gRPC in your recipe?
>
> This isn't possible because you use a target and not a variable.

Maybe a dumb question but how protobuf-compiler handle this?

Thanks,
Clement



>
> [1] https://github.com/grpc/grpc/blob/master/examples/cpp/cmake/common.cmake
>
> Regards
>    Stefan


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [oe] [meta-oe][PATCH v2 1/2] grpc: add cmake support for target
  2022-04-08 19:12     ` Clément Péron
@ 2022-04-11  7:09       ` Stefan Herbrechtsmeier
  0 siblings, 0 replies; 6+ messages in thread
From: Stefan Herbrechtsmeier @ 2022-04-11  7:09 UTC (permalink / raw)
  To: Clément Péron; +Cc: openembeded-devel, Stefan Herbrechtsmeier

Hi Clement,

Am 08.04.2022 um 21:12 schrieb Clément Péron:
> Hi Stefan,
> 
> On Fri, 8 Apr 2022 at 14:47, Stefan Herbrechtsmeier
> <stefan.herbrechtsmeier-oss@weidmueller.com> wrote:
>>
>> Hi Clement,
>>
>> Am 08.04.2022 um 14:25 schrieb Clément Péron:
>>> Hi Stefan,
>>>
>>> On Fri, 8 Apr 2022 at 09:30, Stefan Herbrechtsmeier
>>> <stefan.herbrechtsmeier-oss@weidmueller.com> wrote:
>>>>
>>>> From: Stefan Herbrechtsmeier <stefan.herbrechtsmeier@weidmueller.com>
>>>>
>>>> The CMake gRPC config checks for binaries and fails if a binary (plugin)
>>>> is missing. Fix the problem in the code and add the CMake gRPC config
>>>> back to the target package.
>>>
>>> Thanks for your patch, I'm still using gRPC 1.35 + your previous similar patch.
>>> I'm trying to bump to gRPC 1.45.1 + these patches.
>>>
>>> My recipe use CMake and depends on grpc and grpc-native:
>>> PACKAGECONFIG[grpc] = "-DCONFIG_GRPC=ON,-DCONFIG_GRPC=OFF,grpc grpc-native"
>>>
>>> But unfortunately CMake doesn't find the grpc_cpp_plugin.
>>
>> This is the correct behavior of my patch because the grpc_cpp_plugin
>> from the cross build isn't usable during cross build. You need the
>> grpc_cpp_plugin from the host and therefore have to search the
>> grpc_cpp_plugin by yourself during cross compile [1].
>>
>> My first patch was rejected and therefore I create a minimal patch which
>> only make the CMake gRPC config usable.
>>
>>>
>>> | -- Using gRPC 1.45.1
>>> ....
>>> | CMake Error at modules/grpc/CMakeLists.txt:37 (add_custom_command):
>>> |   Error evaluating generator expression:
>>> |
>>> |     $<TARGET_FILE:gRPC::grpc_cpp_plugin>
>>> |
>>> |   No target "gRPC::grpc_cpp_plugin"
>>> |
>>> |
>>> | CMake Error at modules/grpc/CMakeLists.txt:37 (add_custom_command):
>>> |   Error evaluating generator expression:
>>> |
>>> |     $<TARGET_FILE:gRPC::grpc_cpp_plugin>
>>> |
>>> |   No target "gRPC::grpc_cpp_plugin"
>>> |
>>> |
>>> | CMake Error at modules/grpc/CMakeLists.txt:37 (add_custom_command):
>>> |   Error evaluating generator expression:
>>> |
>>> |     $<TARGET_FILE:gRPC::grpc_cpp_plugin>
>>> |
>>> |   No target "gRPC::grpc_cpp_plugin"
>>>
>>> Here is my CMake source file:
>>>
>>> # Find Protobuf installation Yocto SDK doensn't support protobuf-config.cmake
>>> # for the moment
>>> set(protobuf_MODULE_COMPATIBLE TRUE)
>>> find_package(Protobuf REQUIRED)
>>> message(STATUS "Using protobuf ${Protobuf_VERSION}")
>>> set(_PROTOBUF_LIBPROTOBUF protobuf::libprotobuf)
>>>
>>> # Find gRPC installation Looks for gRPCConfig.cmake file installed by gRPC's
>>> # cmake installation.
>>> find_package(gRPC CONFIG REQUIRED)
>>> message(STATUS "Using gRPC ${gRPC_VERSION}")
>>> set(_REFLECTION gRPC::grpc++_reflection)
>>> set(_GRPC_GRPCPP gRPC::grpc++)
>>>
>>> # Get full path of protobuf/gRPC compiler
>>> set(_PROTOBUF_PROTOC $<TARGET_FILE:protobuf::protoc>)
>>> set(_GRPC_CPP_PLUGIN_EXECUTABLE $<TARGET_FILE:gRPC::grpc_cpp_plugin>)
>>
>> You have to search the binaries if you cross compile [1]:
>>
>> if(CMAKE_CROSSCOMPILING)
>>     find_program(_GRPC_CPP_PLUGIN_EXECUTABLE grpc_cpp_plugin)
>> else()
>>     set(_GRPC_CPP_PLUGIN_EXECUTABLE $<TARGET_FILE:gRPC::grpc_cpp_plugin>)
>> endif()
> 
> Thanks this fix my issue
> 
> Tested-by: Clément Péron <peron.clem@gmail.com>

Thanks for the test. Maybe you could comment to the grpc pull request to 
get attention.

>>> Do you have an example of how you look for gRPC in your recipe?
>>
>> This isn't possible because you use a target and not a variable.
> 
> Maybe a dumb question but how protobuf-compiler handle this?

I don't know. The recipe use autotools and not cmake at the moment. The 
CMake project have a module for protobuf [2] to create the targets. The 
grpc example use the same code as above to find the program if you cross 
compile.

>> [1] https://github.com/grpc/grpc/blob/master/examples/cpp/cmake/common.cmake

[2] https://cmake.org/cmake/help/latest/module/FindProtobuf.html

Regards
   Stefan


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2022-04-11 17:17 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-04-08  7:30 [meta-oe][PATCH v2 1/2] grpc: add cmake support for target Stefan Herbrechtsmeier
2022-04-08  7:30 ` [meta-oe][PATCH v2 2/2] grpc: remove useless link with libatomic append Stefan Herbrechtsmeier
2022-04-08 12:25 ` [oe] [meta-oe][PATCH v2 1/2] grpc: add cmake support for target Clément Péron
2022-04-08 12:47   ` Stefan Herbrechtsmeier
2022-04-08 19:12     ` Clément Péron
2022-04-11  7:09       ` Stefan Herbrechtsmeier

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.