cmake: don't export grpc_cpp_plugin when crosscompiling (#26148)

* cmake: don't install plugins when crosscompiling

Plugins should not be installed for a cross-compilation environment,
because it has to run on a host/build system. If it's installed then
configure stage fails with an error, that imported target references
non-existing file. Even if the file is found, it can't be used on a host.

Signed-off-by: Vyacheslav Yurkov <uvv.mail@gmail.com>

* better way of detecting protoc targets

Co-authored-by: Jan Tattermusch <jtattermusch@google.com>
pull/26327/head
Vyacheslav Yurkov 4 years ago committed by GitHub
parent ef35b4a28b
commit db88fb0ee8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 16
      CMakeLists.txt
  2. 2
      templates/CMakeLists.txt.template

@ -3722,7 +3722,7 @@ foreach(_hdr
endforeach()
if(gRPC_INSTALL)
if(gRPC_INSTALL AND NOT CMAKE_CROSSCOMPILING)
install(TARGETS grpc_plugin_support EXPORT gRPCTargets
RUNTIME DESTINATION ${gRPC_INSTALL_BINDIR}
LIBRARY DESTINATION ${gRPC_INSTALL_LIBDIR}
@ -10843,7 +10843,7 @@ target_link_libraries(grpc_cpp_plugin
if(gRPC_INSTALL)
if(gRPC_INSTALL AND NOT CMAKE_CROSSCOMPILING)
install(TARGETS grpc_cpp_plugin EXPORT gRPCTargets
RUNTIME DESTINATION ${gRPC_INSTALL_BINDIR}
LIBRARY DESTINATION ${gRPC_INSTALL_LIBDIR}
@ -10882,7 +10882,7 @@ target_link_libraries(grpc_csharp_plugin
if(gRPC_INSTALL)
if(gRPC_INSTALL AND NOT CMAKE_CROSSCOMPILING)
install(TARGETS grpc_csharp_plugin EXPORT gRPCTargets
RUNTIME DESTINATION ${gRPC_INSTALL_BINDIR}
LIBRARY DESTINATION ${gRPC_INSTALL_LIBDIR}
@ -10921,7 +10921,7 @@ target_link_libraries(grpc_node_plugin
if(gRPC_INSTALL)
if(gRPC_INSTALL AND NOT CMAKE_CROSSCOMPILING)
install(TARGETS grpc_node_plugin EXPORT gRPCTargets
RUNTIME DESTINATION ${gRPC_INSTALL_BINDIR}
LIBRARY DESTINATION ${gRPC_INSTALL_LIBDIR}
@ -10960,7 +10960,7 @@ target_link_libraries(grpc_objective_c_plugin
if(gRPC_INSTALL)
if(gRPC_INSTALL AND NOT CMAKE_CROSSCOMPILING)
install(TARGETS grpc_objective_c_plugin EXPORT gRPCTargets
RUNTIME DESTINATION ${gRPC_INSTALL_BINDIR}
LIBRARY DESTINATION ${gRPC_INSTALL_LIBDIR}
@ -10999,7 +10999,7 @@ target_link_libraries(grpc_php_plugin
if(gRPC_INSTALL)
if(gRPC_INSTALL AND NOT CMAKE_CROSSCOMPILING)
install(TARGETS grpc_php_plugin EXPORT gRPCTargets
RUNTIME DESTINATION ${gRPC_INSTALL_BINDIR}
LIBRARY DESTINATION ${gRPC_INSTALL_LIBDIR}
@ -11038,7 +11038,7 @@ target_link_libraries(grpc_python_plugin
if(gRPC_INSTALL)
if(gRPC_INSTALL AND NOT CMAKE_CROSSCOMPILING)
install(TARGETS grpc_python_plugin EXPORT gRPCTargets
RUNTIME DESTINATION ${gRPC_INSTALL_BINDIR}
LIBRARY DESTINATION ${gRPC_INSTALL_LIBDIR}
@ -11077,7 +11077,7 @@ target_link_libraries(grpc_ruby_plugin
if(gRPC_INSTALL)
if(gRPC_INSTALL AND NOT CMAKE_CROSSCOMPILING)
install(TARGETS grpc_ruby_plugin EXPORT gRPCTargets
RUNTIME DESTINATION ${gRPC_INSTALL_BINDIR}
LIBRARY DESTINATION ${gRPC_INSTALL_LIBDIR}

@ -689,6 +689,8 @@
# grpcpp_channelz doesn't build with protobuf-lite, so no install required
# See https://github.com/grpc/grpc/issues/22826
if(gRPC_INSTALL AND NOT gRPC_USE_PROTO_LITE)
% elif tgt.build == 'protoc':
if(gRPC_INSTALL AND NOT CMAKE_CROSSCOMPILING)
% else:
if(gRPC_INSTALL)
% endif

Loading…
Cancel
Save