[c++ grpc] Add gRPC to CMake-based build
* Integrates building gRPC via its CMakeList * Includes a dummy project to test that gRPC++ builds and can be linked correctly.
This commit is contained in:
Родитель
4ae54d6e61
Коммит
c969e2167f
|
@ -1,6 +1,6 @@
|
|||
[submodule "thirdparty/grpc"]
|
||||
path = thirdparty/grpc
|
||||
url = https://github.com/grpc/grpc.git
|
||||
url = https://github.com/chwarr/grpc.git
|
||||
|
||||
[submodule "thirdparty/rapidjson"]
|
||||
path = thirdparty/rapidjson
|
||||
|
|
|
@ -1,12 +1,16 @@
|
|||
cmake_minimum_required (VERSION 3.1)
|
||||
project (bond)
|
||||
|
||||
project (bond)
|
||||
cmake_policy (SET CMP0022 NEW)
|
||||
|
||||
set (CMAKE_MODULE_PATH
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/cmake
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/thirdparty/cmake-modules)
|
||||
|
||||
# We need to include third-party CMake modules before we configure our own
|
||||
# settings so that we don't apply our settings to third-party code.
|
||||
include (ThirdParty)
|
||||
|
||||
enable_testing()
|
||||
|
||||
set (BOND_IDL ${CMAKE_CURRENT_SOURCE_DIR}/idl)
|
||||
|
@ -35,6 +39,7 @@ add_subfolder (doc "doc")
|
|||
add_python_subdirectory (python)
|
||||
add_subdirectory (examples)
|
||||
|
||||
|
||||
install (DIRECTORY
|
||||
cpp/inc/bond
|
||||
cpp/generated/bond
|
||||
|
|
|
@ -0,0 +1,7 @@
|
|||
set (BOND_ENABLE_GRPC
|
||||
"FALSE"
|
||||
CACHE BOOL "If TRUE, then Bond C++ gRPC support will be built, using the grpc submodule. The grpc pre-requesites will need to have been installed.")
|
||||
|
||||
if (BOND_ENABLE_GRPC)
|
||||
add_subdirectory(thirdparty/grpc)
|
||||
endif()
|
|
@ -5,3 +5,10 @@ endif()
|
|||
if (NOT BOND_CORE_ONLY)
|
||||
add_subfolder (comm "examples/comm")
|
||||
endif()
|
||||
|
||||
if (BOND_ENABLE_GRPC)
|
||||
# This is a dummy project to make sure that gRPC++ builds and can be
|
||||
# linked correctly. This will be removed later, when we have a
|
||||
# Bond-over-gRPC++ test.
|
||||
add_subfolder (grpc-dummy "examples/grpc-dummy")
|
||||
endif()
|
||||
|
|
|
@ -0,0 +1,14 @@
|
|||
# This is a dummy project to make sure that gRPC++ builds and can be linked
|
||||
# correctly. This will be removed later, when we have a Bond-over-gRPC++
|
||||
# test.
|
||||
|
||||
add_bond_test (grpc-dummy g.bond g.cpp)
|
||||
|
||||
cxx_target_compile_definitions (MSVC grpc-dummy PRIVATE -D_WIN32_WINNT=0x0600)
|
||||
|
||||
target_link_libraries(grpc-dummy PRIVATE grpc++)
|
||||
target_include_directories(grpc-dummy
|
||||
# TODO: It feels like the grpc++ target should have this as part of its
|
||||
# interface... Perhaps a patch for upstream?
|
||||
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/../../../thirdparty/grpc/include
|
||||
)
|
|
@ -0,0 +1,11 @@
|
|||
namespace g;
|
||||
|
||||
struct Box
|
||||
{
|
||||
0: string sf;
|
||||
}
|
||||
|
||||
service Greeter
|
||||
{
|
||||
Box SayHello(Box);
|
||||
}
|
|
@ -0,0 +1,25 @@
|
|||
#include "g_types.h"
|
||||
|
||||
#pragma warning (push)
|
||||
#pragma warning (disable: 4100)
|
||||
|
||||
#include <grpc++/grpc++.h>
|
||||
|
||||
#pragma warning (pop)
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
using namespace g;
|
||||
|
||||
int main()
|
||||
{
|
||||
Box b;
|
||||
b.sf = "world";
|
||||
|
||||
printf("Hello, %s\n", b.sf.c_str());
|
||||
|
||||
grpc::ServerBuilder sb;
|
||||
sb.AddListeningPort("127.0.0.1:12345", nullptr);
|
||||
|
||||
return 0;
|
||||
}
|
|
@ -1 +1 @@
|
|||
Subproject commit e48dd23092a58c76a1cb486846fbeea38f60af3e
|
||||
Subproject commit 2306937f5011b886457569871cfad18fc5805927
|
Загрузка…
Ссылка в новой задаче