Merge pull request #20629 from KyleFromKitware/plugin-options

Add options for all codegen plugins
pull/21182/head
Jan Tattermusch 5 years ago committed by GitHub
commit 369e5a8de7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 56
      CMakeLists.txt
  2. 16
      templates/CMakeLists.txt.template

@ -220,15 +220,41 @@ function(protobuf_generate_grpc_cpp)
endforeach() endforeach()
endfunction() endfunction()
# These options allow users to enable or disable the building of the various
# protoc plugins. For example, running CMake with
# -DgRPC_BUILD_GRPC_CSHARP_PLUGIN=OFF will disable building the C# plugin.
set(_gRPC_PLUGIN_LIST)
option(gRPC_BUILD_GRPC_CPP_PLUGIN "Build grpc_cpp_plugin" ON)
if (gRPC_BUILD_GRPC_CPP_PLUGIN)
list(APPEND _gRPC_PLUGIN_LIST grpc_cpp_plugin)
endif ()
option(gRPC_BUILD_GRPC_CSHARP_PLUGIN "Build grpc_csharp_plugin" ON)
if (gRPC_BUILD_GRPC_CSHARP_PLUGIN)
list(APPEND _gRPC_PLUGIN_LIST grpc_csharp_plugin)
endif ()
option(gRPC_BUILD_GRPC_NODE_PLUGIN "Build grpc_node_plugin" ON)
if (gRPC_BUILD_GRPC_NODE_PLUGIN)
list(APPEND _gRPC_PLUGIN_LIST grpc_node_plugin)
endif ()
option(gRPC_BUILD_GRPC_OBJECTIVE_C_PLUGIN "Build grpc_objective_c_plugin" ON)
if (gRPC_BUILD_GRPC_OBJECTIVE_C_PLUGIN)
list(APPEND _gRPC_PLUGIN_LIST grpc_objective_c_plugin)
endif ()
option(gRPC_BUILD_GRPC_PHP_PLUGIN "Build grpc_php_plugin" ON)
if (gRPC_BUILD_GRPC_PHP_PLUGIN)
list(APPEND _gRPC_PLUGIN_LIST grpc_php_plugin)
endif ()
option(gRPC_BUILD_GRPC_PYTHON_PLUGIN "Build grpc_python_plugin" ON)
if (gRPC_BUILD_GRPC_PYTHON_PLUGIN)
list(APPEND _gRPC_PLUGIN_LIST grpc_python_plugin)
endif ()
option(gRPC_BUILD_GRPC_RUBY_PLUGIN "Build grpc_ruby_plugin" ON)
if (gRPC_BUILD_GRPC_RUBY_PLUGIN)
list(APPEND _gRPC_PLUGIN_LIST grpc_ruby_plugin)
endif ()
add_custom_target(plugins add_custom_target(plugins
DEPENDS DEPENDS ${_gRPC_PLUGIN_LIST}
grpc_cpp_plugin
grpc_csharp_plugin
grpc_node_plugin
grpc_objective_c_plugin
grpc_php_plugin
grpc_python_plugin
grpc_ruby_plugin
) )
add_custom_target(tools_c add_custom_target(tools_c
@ -12906,7 +12932,7 @@ target_link_libraries(grpc_cli
endif() endif()
if(gRPC_BUILD_CODEGEN) if(gRPC_BUILD_CODEGEN AND gRPC_BUILD_GRPC_CPP_PLUGIN)
add_executable(grpc_cpp_plugin add_executable(grpc_cpp_plugin
src/compiler/cpp_plugin.cc src/compiler/cpp_plugin.cc
@ -12943,7 +12969,7 @@ if(gRPC_INSTALL)
endif() endif()
endif() endif()
if(gRPC_BUILD_CODEGEN) if(gRPC_BUILD_CODEGEN AND gRPC_BUILD_GRPC_CSHARP_PLUGIN)
add_executable(grpc_csharp_plugin add_executable(grpc_csharp_plugin
src/compiler/csharp_plugin.cc src/compiler/csharp_plugin.cc
@ -13053,7 +13079,7 @@ target_link_libraries(grpc_linux_system_roots_test
endif() endif()
if(gRPC_BUILD_CODEGEN) if(gRPC_BUILD_CODEGEN AND gRPC_BUILD_GRPC_NODE_PLUGIN)
add_executable(grpc_node_plugin add_executable(grpc_node_plugin
src/compiler/node_plugin.cc src/compiler/node_plugin.cc
@ -13090,7 +13116,7 @@ if(gRPC_INSTALL)
endif() endif()
endif() endif()
if(gRPC_BUILD_CODEGEN) if(gRPC_BUILD_CODEGEN AND gRPC_BUILD_GRPC_OBJECTIVE_C_PLUGIN)
add_executable(grpc_objective_c_plugin add_executable(grpc_objective_c_plugin
src/compiler/objective_c_plugin.cc src/compiler/objective_c_plugin.cc
@ -13127,7 +13153,7 @@ if(gRPC_INSTALL)
endif() endif()
endif() endif()
if(gRPC_BUILD_CODEGEN) if(gRPC_BUILD_CODEGEN AND gRPC_BUILD_GRPC_PHP_PLUGIN)
add_executable(grpc_php_plugin add_executable(grpc_php_plugin
src/compiler/php_plugin.cc src/compiler/php_plugin.cc
@ -13164,7 +13190,7 @@ if(gRPC_INSTALL)
endif() endif()
endif() endif()
if(gRPC_BUILD_CODEGEN) if(gRPC_BUILD_CODEGEN AND gRPC_BUILD_GRPC_PYTHON_PLUGIN)
add_executable(grpc_python_plugin add_executable(grpc_python_plugin
src/compiler/python_plugin.cc src/compiler/python_plugin.cc
@ -13201,7 +13227,7 @@ if(gRPC_INSTALL)
endif() endif()
endif() endif()
if(gRPC_BUILD_CODEGEN) if(gRPC_BUILD_CODEGEN AND gRPC_BUILD_GRPC_RUBY_PLUGIN)
add_executable(grpc_ruby_plugin add_executable(grpc_ruby_plugin
src/compiler/ruby_plugin.cc src/compiler/ruby_plugin.cc

@ -315,13 +315,21 @@
endforeach() endforeach()
endfunction() endfunction()
add_custom_target(plugins # These options allow users to enable or disable the building of the various
DEPENDS # protoc plugins. For example, running CMake with
# -DgRPC_BUILD_GRPC_CSHARP_PLUGIN=OFF will disable building the C# plugin.
set(_gRPC_PLUGIN_LIST)
% for tgt in targets: % for tgt in targets:
% if tgt.build == 'protoc': % if tgt.build == 'protoc':
${tgt.name} option(gRPC_BUILD_${tgt.name.upper()} "Build ${tgt.name}" ON)
if (gRPC_BUILD_${tgt.name.upper()})
list(APPEND _gRPC_PLUGIN_LIST ${tgt.name})
endif ()
% endif % endif
% endfor % endfor
add_custom_target(plugins
DEPENDS <%text>${_gRPC_PLUGIN_LIST}</%text>
) )
add_custom_target(tools_c add_custom_target(tools_c
@ -419,7 +427,7 @@
</%block> </%block>
endif() endif()
% elif tgt.build in ["protoc"]: % elif tgt.build in ["protoc"]:
if(gRPC_BUILD_CODEGEN) if(gRPC_BUILD_CODEGEN AND gRPC_BUILD_${tgt.name.upper()})
<%block filter='platforms_condition_block(tgt.platforms)'> <%block filter='platforms_condition_block(tgt.platforms)'>
${cc_binary(tgt)} ${cc_binary(tgt)}
${cc_install(tgt)} ${cc_install(tgt)}

Loading…
Cancel
Save