aboutsummaryrefslogtreecommitdiffhomepage
path: root/examples
diff options
context:
space:
mode:
authorGravatar Sree Kuchibhotla <sreek@google.com>2017-12-04 12:14:18 -0800
committerGravatar Sree Kuchibhotla <sreek@google.com>2017-12-04 12:14:18 -0800
commit9a434371e2f582675880239c1d0d5d85081761d8 (patch)
tree935e23c511274413add36f5c175a6c2bee8afe1d /examples
parent4ca35636fe3c5d1e936d4cc03d18efb4be2824b8 (diff)
parentc3b1e55a3c6af7c39ed1a6d7dea3463ba6194449 (diff)
Merge branch 'master' into rq-fix
Diffstat (limited to 'examples')
-rw-r--r--examples/cpp/helloworld/CMakeLists.txt24
1 files changed, 20 insertions, 4 deletions
diff --git a/examples/cpp/helloworld/CMakeLists.txt b/examples/cpp/helloworld/CMakeLists.txt
index 71a8db4f24..49684a13b0 100644
--- a/examples/cpp/helloworld/CMakeLists.txt
+++ b/examples/cpp/helloworld/CMakeLists.txt
@@ -6,13 +6,29 @@ project(HelloWorld C CXX)
if(NOT MSVC)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
+else()
+ add_definitions(-D_WIN32_WINNT=0x600)
endif()
# Protobuf
-set(protobuf_MODULE_COMPATIBLE TRUE)
-find_package(protobuf CONFIG REQUIRED)
+# NOTE: we cannot use "CONFIG" mode here because protobuf-config.cmake
+# is broken when used with CMAKE_INSTALL_PREFIX
+find_package(Protobuf REQUIRED)
message(STATUS "Using protobuf ${protobuf_VERSION}")
+if(Protobuf_FOUND)
+ # Protobuf_FOUND is set for package type "CONFIG"
+ set(_PROTOBUF_LIBPROTOBUF protobuf::libprotobuf)
+ set(_PROTOBUF_PROTOC protobuf::protoc)
+elseif(PROTOBUF_FOUND)
+ # PROTOBUF_FOUND is set for package type "MODULE"
+ set(_PROTOBUF_LIBPROTOBUF ${PROTOBUF_LIBRARIES})
+ set(_PROTOBUF_PROTOC ${PROTOBUF_PROTOC_EXECUTABLE})
+ include_directories(${PROTOBUF_INCLUDE_DIRS})
+else()
+ message(WARNING "Failed to locate libprotobuf and protoc!")
+endif()
+
# gRPC
find_package(gRPC CONFIG REQUIRED)
message(STATUS "Using gRPC ${gRPC_VERSION}")
@@ -31,7 +47,7 @@ set(hw_grpc_srcs "${CMAKE_CURRENT_BINARY_DIR}/helloworld.grpc.pb.cc")
set(hw_grpc_hdrs "${CMAKE_CURRENT_BINARY_DIR}/helloworld.grpc.pb.h")
add_custom_command(
OUTPUT "${hw_grpc_srcs}" "${hw_grpc_hdrs}"
- COMMAND protobuf::protoc
+ COMMAND ${_PROTOBUF_PROTOC}
ARGS --grpc_out "${CMAKE_CURRENT_BINARY_DIR}" -I "${hw_proto_path}"
--plugin=protoc-gen-grpc="${gRPC_CPP_PLUGIN_EXECUTABLE}"
"${hw_proto}"
@@ -48,6 +64,6 @@ foreach(_target
${hw_proto_srcs}
${hw_grpc_srcs})
target_link_libraries(${_target}
- protobuf::libprotobuf
+ ${_PROTOBUF_LIBPROTOBUF}
gRPC::grpc++_unsecure)
endforeach()