Skip to content

Commit

Permalink
Cmake add separate export for plugin targets (#31525)
Browse files Browse the repository at this point in the history
* cmake: add separate export for plugin targets

Add a separate CMake export for the plugin targets to separate binaries
and libraries into their own CMake target export files. Skip the cross
compiled binary plugin targets during cross compile because they are not
usable and not always available.

The Yocto build system doesn't install cross compiled binaries into the
target sysroot. This makes the CMake gRPC config useless as it checks
the existent of binaries and fails without the binaries.

This is a strip down version of #22498 and related to #26148 and #26857.

Signed-off-by: Stefan Herbrechtsmeier <stefan.herbrechtsmeier@weidmueller.com>
Signed-off-by: Clément Péron <peron.clem@gmail.com>

* regenerate cmake file

Signed-off-by: Stefan Herbrechtsmeier <stefan.herbrechtsmeier@weidmueller.com>
Signed-off-by: Clément Péron <peron.clem@gmail.com>
Co-authored-by: Stefan Herbrechtsmeier <stefan.herbrechtsmeier@weidmueller.com>
  • Loading branch information
clementperon and herbrechtsmeier committed Nov 15, 2022
1 parent 3ef817b commit 831d2a6
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 7 deletions.
18 changes: 11 additions & 7 deletions CMakeLists.txt

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions cmake/gRPCConfig.cmake.in
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,6 @@ list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_LIST_DIR}/modules)

# Targets
include(${CMAKE_CURRENT_LIST_DIR}/gRPCTargets.cmake)
if(NOT CMAKE_CROSSCOMPILING)
include(${CMAKE_CURRENT_LIST_DIR}/gRPCPluginTargets.cmake)
endif()
8 changes: 8 additions & 0 deletions templates/CMakeLists.txt.template
Original file line number Diff line number Diff line change
Expand Up @@ -801,7 +801,11 @@
% else:
if(gRPC_INSTALL)
% endif
% if tgt.build == 'protoc' and 'grpc_plugin_support' in tgt.get('deps', []):
install(TARGETS ${tgt.name} EXPORT gRPCPluginTargets
% else:
install(TARGETS ${tgt.name} EXPORT gRPCTargets
% endif
RUNTIME DESTINATION <%text>${gRPC_INSTALL_BINDIR}</%text>
BUNDLE DESTINATION <%text>${gRPC_INSTALL_BINDIR}</%text>
LIBRARY DESTINATION <%text>${gRPC_INSTALL_LIBDIR}</%text>
Expand All @@ -815,6 +819,10 @@
DESTINATION <%text>${gRPC_INSTALL_CMAKEDIR}</%text>
NAMESPACE gRPC::
)
install(EXPORT gRPCPluginTargets
DESTINATION <%text>${gRPC_INSTALL_CMAKEDIR}</%text>
NAMESPACE gRPC::
)
endif()

include(CMakePackageConfigHelpers)
Expand Down

0 comments on commit 831d2a6

Please sign in to comment.