-
Notifications
You must be signed in to change notification settings - Fork 37
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: Honor ASIO_GRPC_USE_BOOST_CONTAINER in add_subdirectory mode. Al…
…so add test for add_subdirectory
- Loading branch information
Showing
10 changed files
with
231 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
# Copyright 2022 Dennis Hezel | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
cmake_minimum_required(VERSION 3.14) | ||
|
||
project(asio-grpc-cmake-test-subdirectory) | ||
|
||
file(REMOVE_RECURSE "${CMAKE_CURRENT_BINARY_DIR}/s" "${CMAKE_CURRENT_BINARY_DIR}/t" | ||
"${CMAKE_CURRENT_BINARY_DIR}/test-install") | ||
|
||
file(COPY "@ASIO_GRPC_PROJECT_ROOT@/src" DESTINATION "${CMAKE_CURRENT_BINARY_DIR}/s/a-g/") | ||
file(COPY "@ASIO_GRPC_PROJECT_ROOT@/cmake" DESTINATION "${CMAKE_CURRENT_BINARY_DIR}/s/a-g/") | ||
file(COPY "@ASIO_GRPC_PROJECT_ROOT@/CMakeLists.txt" DESTINATION "${CMAKE_CURRENT_BINARY_DIR}/s/a-g/") | ||
file(COPY "${CMAKE_CURRENT_LIST_DIR}/src/." DESTINATION "${CMAKE_CURRENT_BINARY_DIR}/s/") | ||
|
||
include(ExternalProject) | ||
|
||
externalproject_add( | ||
t | ||
PREFIX t | ||
SOURCE_DIR "${CMAKE_CURRENT_BINARY_DIR}/s" | ||
CMAKE_ARGS "-DCMAKE_CXX_COMPILER=@CMAKE_CXX_COMPILER@" | ||
"-DCMAKE_CXX_FLAGS=@CMAKE_CXX_FLAGS@" | ||
"-DCMAKE_EXE_LINKER_FLAGS=@CMAKE_EXE_LINKER_FLAGS@" | ||
"-DCMAKE_BUILD_TYPE=Release" | ||
"-DCMAKE_RUNTIME_OUTPUT_DIRECTORY=${CMAKE_CURRENT_BINARY_DIR}/test-install" | ||
"-DCMAKE_MSVC_RUNTIME_LIBRARY=@CMAKE_MSVC_RUNTIME_LIBRARY@" | ||
"-DBoost_USE_STATIC_RUNTIME=@ASIO_GRPC_BOOST_USE_STATIC_RUNTIME@" | ||
"-DCMAKE_TOOLCHAIN_FILE=@CMAKE_TOOLCHAIN_FILE@" | ||
"-DVCPKG_TARGET_TRIPLET=@VCPKG_TARGET_TRIPLET@" | ||
"-DVCPKG_HOST_TRIPLET=@VCPKG_HOST_TRIPLET@" | ||
"-DVCPKG_OVERLAY_TRIPLETS=@VCPKG_OVERLAY_TRIPLETS@" | ||
"-DVCPKG_MANIFEST_MODE=@VCPKG_MANIFEST_MODE@" | ||
"-DVCPKG_MANIFEST_INSTALL=@VCPKG_MANIFEST_INSTALL@" | ||
"-DVCPKG_OVERLAY_PORTS=@VCPKG_OVERLAY_PORTS@" | ||
"-DVCPKG_INSTALL_OPTIONS=@VCPKG_INSTALL_OPTIONS@" | ||
"-DVCPKG_INSTALLED_DIR=@VCPKG_INSTALLED_DIR@" | ||
"-DASIO_GRPC_USE_BOOST_CONTAINER=@ASIO_GRPC_USE_BOOST_CONTAINER@" | ||
BUILD_COMMAND "${CMAKE_COMMAND}" "--build" "<BINARY_DIR>" "--config" "Release" | ||
INSTALL_COMMAND "") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
# Copyright 2022 Dennis Hezel | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
cmake_minimum_required(VERSION 3.14) | ||
|
||
project(asio-grpc-cmake-test-subdirectory LANGUAGES CXX) | ||
|
||
add_subdirectory(a-g) | ||
|
||
find_package(gRPC) | ||
find_package(asio) | ||
find_package(Boost COMPONENTS container) | ||
|
||
# main | ||
add_executable(main) | ||
|
||
target_sources(main PRIVATE main.cpp) | ||
|
||
asio_grpc_protobuf_generate( | ||
GENERATE_GRPC | ||
TARGET main | ||
OUT_DIR "${CMAKE_CURRENT_BINARY_DIR}/target" | ||
PROTOS "${CMAKE_CURRENT_SOURCE_DIR}/proto/target.proto") | ||
|
||
target_compile_definitions(main INTERFACE $<$<CXX_COMPILER_ID:MSVC>:_WIN32_WINNT=0x0A00> # Windows 10 | ||
ASIO_NO_DEPRECATED) | ||
|
||
target_link_libraries(main PRIVATE asio-grpc::asio-grpc-standalone-asio asio::asio Boost::container | ||
gRPC::grpc++_unsecure) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
// Copyright 2022 Dennis Hezel | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
#include "target.grpc.pb.h" | ||
|
||
#include <agrpc/asio_grpc.hpp> | ||
#include <grpcpp/completion_queue.h> | ||
|
||
int main() | ||
{ | ||
agrpc::GrpcContext grpc_context{std::make_unique<grpc::CompletionQueue>()}; | ||
|
||
auto rpc = &target::Test::AsyncService::RequestUnary; | ||
|
||
target::Request request; | ||
request.set_integer(42); | ||
|
||
target::Request response; | ||
|
||
grpc_context.run(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
// Copyright 2022 Dennis Hezel | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
syntax = "proto3"; | ||
|
||
package target; | ||
|
||
service Test { | ||
rpc Unary(Request) returns (Response) {} | ||
} | ||
|
||
message Request { | ||
int32 integer = 1; | ||
} | ||
|
||
message Response { | ||
int32 integer = 1; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
{ | ||
"$schema": "https://raw.githubusercontent.com/microsoft/vcpkg/cafd398be781144787573ca78390e951673c7055/scripts/vcpkg.schema.json", | ||
"name": "asio-grpc-cmake-test", | ||
"version": "1", | ||
"dependencies": [ | ||
{ | ||
"name": "abseil", | ||
"features": [ | ||
"cxx17" | ||
] | ||
}, | ||
"doctest", | ||
"grpc", | ||
"boost-coroutine", | ||
"boost-asio", | ||
"boost-interprocess", | ||
"boost-thread", | ||
"boost-container", | ||
"boost-process", | ||
{ | ||
"name": "asio", | ||
"features": [ | ||
"coroutine" | ||
] | ||
}, | ||
"libunifex", | ||
"gtest" | ||
], | ||
"builtin-baseline": "cafd398be781144787573ca78390e951673c7055" | ||
} |