feat: update protos to 2020-02-25 version (#37)

Update the dependencies based on the new protos.
This commit is contained in:
Carlos O'Ryan 2020-02-25 13:20:33 -05:00 committed by GitHub
parent 3e4f8c025e
commit c1713cb00d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 306 additions and 365 deletions

View file

@ -24,7 +24,8 @@ set(GOOGLEAPIS_CPP_PROTOS_VERSION_MAJOR 0)
set(GOOGLEAPIS_CPP_PROTOS_VERSION_MINOR 5) set(GOOGLEAPIS_CPP_PROTOS_VERSION_MINOR 5)
set(GOOGLEAPIS_CPP_PROTOS_VERSION_PATCH 0) set(GOOGLEAPIS_CPP_PROTOS_VERSION_PATCH 0)
string(CONCAT GOOGLE_APIS_CPP_PROTOS_VERSION string(
CONCAT GOOGLE_APIS_CPP_PROTOS_VERSION
"${GOOGLEAPIS_CPP_PROTOS_VERSION_MAJOR}" "${GOOGLEAPIS_CPP_PROTOS_VERSION_MAJOR}"
"." "."
"${GOOGLEAPIS_CPP_PROTOS_VERSION_MINOR}" "${GOOGLEAPIS_CPP_PROTOS_VERSION_MINOR}"
@ -37,12 +38,11 @@ set(CMAKE_CXX_STANDARD_REQUIRED ON)
# Give application developers a hook to configure the version and hash # Give application developers a hook to configure the version and hash
# downloaded from GitHub. # downloaded from GitHub.
set( set(GOOGLE_CLOUD_CPP_GOOGLEAPIS_URL
GOOGLE_CLOUD_CPP_GOOGLEAPIS_URL "https://github.com/googleapis/googleapis/archive/0b1876b35e98f560f9c9ca9797955f020238a092.tar.gz"
"https://github.com/googleapis/googleapis/archive/19c4589a3cb44b3679f7b3fba88365b3d055d5f8.tar.gz" )
)
set(GOOGLE_CLOUD_CPP_GOOGLEAPIS_SHA256 set(GOOGLE_CLOUD_CPP_GOOGLEAPIS_SHA256
"ef455e46cfb967962aef30248f1a2a69bc78b041e89b04644e24e7844f0215c4") "4b0db7279ddf0b9ec6a39fd741ef4694b20025fe38f7d98f1ab1ba224c417c2d")
set(GOOGLEAPIS_CPP_SOURCE set(GOOGLEAPIS_CPP_SOURCE
"${CMAKE_BINARY_DIR}/external/googleapis/src/googleapis_download") "${CMAKE_BINARY_DIR}/external/googleapis/src/googleapis_download")
@ -104,7 +104,8 @@ foreach (proto ${GOOGLEAPIS_CPP_PROTO_FILES})
endforeach () endforeach ()
include(ExternalProject) include(ExternalProject)
ExternalProject_Add(googleapis_download ExternalProject_Add(
googleapis_download
EXCLUDE_FROM_ALL ON EXCLUDE_FROM_ALL ON
PREFIX "${CMAKE_BINARY_DIR}/external/googleapis" PREFIX "${CMAKE_BINARY_DIR}/external/googleapis"
URL ${GOOGLE_CLOUD_CPP_GOOGLEAPIS_URL} URL ${GOOGLE_CLOUD_CPP_GOOGLEAPIS_URL}
@ -137,19 +138,12 @@ include(CompileProtos)
google_cloud_cpp_add_protos_property() google_cloud_cpp_add_protos_property()
function (googleapis_cpp_short_name var proto) function (googleapis_cpp_short_name var proto)
string(REPLACE "google/" string(REPLACE "google/" "" short_name "${proto}")
"" string(REPLACE "/" "_" short_name "${short_name}")
short_name string(REPLACE ".proto" "_protos" short_name "${short_name}")
"${proto}") set("${var}"
string(REPLACE "/" "${short_name}"
"_" PARENT_SCOPE)
short_name
"${short_name}")
string(REPLACE ".proto"
"_protos"
short_name
"${short_name}")
set("${var}" "${short_name}" PARENT_SCOPE)
endfunction () endfunction ()
# Create a single source proto library. # Create a single source proto library.
@ -158,10 +152,9 @@ endfunction ()
# * (optional) ARGN: proto libraries the new library depends on. # * (optional) ARGN: proto libraries the new library depends on.
function (googleapis_cpp_add_library proto) function (googleapis_cpp_add_library proto)
googleapis_cpp_short_name(short_name "${proto}") googleapis_cpp_short_name(short_name "${proto}")
google_cloud_cpp_grpcpp_library(googleapis_cpp_${short_name} google_cloud_cpp_grpcpp_library(
"${GOOGLEAPIS_CPP_SOURCE}/${proto}" googleapis_cpp_${short_name} "${GOOGLEAPIS_CPP_SOURCE}/${proto}"
PROTO_PATH_DIRECTORIES PROTO_PATH_DIRECTORIES "${GOOGLEAPIS_CPP_SOURCE}"
"${GOOGLEAPIS_CPP_SOURCE}"
"${PROTO_INCLUDE_DIR}") "${PROTO_INCLUDE_DIR}")
googleapis_cpp_set_version_and_alias("${short_name}") googleapis_cpp_set_version_and_alias("${short_name}")
@ -175,7 +168,8 @@ function (googleapis_cpp_add_library proto)
target_link_libraries("googleapis_cpp_${short_name}" target_link_libraries("googleapis_cpp_${short_name}"
PRIVATE googleapis_cpp_common_flags) PRIVATE googleapis_cpp_common_flags)
else () else ()
target_link_libraries("googleapis_cpp_${short_name}" target_link_libraries(
"googleapis_cpp_${short_name}"
PUBLIC ${public_deps} PUBLIC ${public_deps}
PRIVATE googleapis_cpp_common_flags) PRIVATE googleapis_cpp_common_flags)
endif () endif ()
@ -183,26 +177,25 @@ endfunction ()
function (googleapis_cpp_set_version_and_alias short_name) function (googleapis_cpp_set_version_and_alias short_name)
add_dependencies("googleapis_cpp_${short_name}" googleapis_download) add_dependencies("googleapis_cpp_${short_name}" googleapis_download)
set_target_properties("googleapis_cpp_${short_name}" set_target_properties(
PROPERTIES VERSION "googleapis_cpp_${short_name}"
"${GOOGLE_APIS_CPP_PROTOS_VERSION}" PROPERTIES VERSION "${GOOGLE_APIS_CPP_PROTOS_VERSION}"
SOVERSION SOVERSION ${GOOGLEAPIS_CPP_PROTOS_VERSION_MAJOR})
${GOOGLEAPIS_CPP_PROTOS_VERSION_MAJOR})
add_library("googleapis-c++::${short_name}" ALIAS add_library("googleapis-c++::${short_name}" ALIAS
"googleapis_cpp_${short_name}") "googleapis_cpp_${short_name}")
endfunction () endfunction ()
googleapis_cpp_add_library("google/api/http.proto") googleapis_cpp_add_library("google/api/http.proto")
googleapis_cpp_add_library("google/api/metric.proto" api_launch_stage_protos
api_label_protos)
googleapis_cpp_add_library("google/api/monitored_resource.proto"
api_launch_stage_protos api_label_protos)
googleapis_cpp_add_library("google/api/annotations.proto" api_http_protos) googleapis_cpp_add_library("google/api/annotations.proto" api_http_protos)
googleapis_cpp_add_library("google/api/auth.proto" api_annotations_protos) googleapis_cpp_add_library("google/api/auth.proto" api_annotations_protos)
googleapis_cpp_add_library("google/api/client.proto") googleapis_cpp_add_library("google/api/client.proto")
googleapis_cpp_add_library("google/api/field_behavior.proto") googleapis_cpp_add_library("google/api/field_behavior.proto")
googleapis_cpp_add_library("google/api/label.proto") googleapis_cpp_add_library("google/api/label.proto")
googleapis_cpp_add_library("google/api/launch_stage.proto") googleapis_cpp_add_library("google/api/launch_stage.proto")
googleapis_cpp_add_library("google/api/metric.proto" api_launch_stage_protos
api_label_protos)
googleapis_cpp_add_library("google/api/monitored_resource.proto"
api_launch_stage_protos api_label_protos)
googleapis_cpp_add_library("google/api/resource.proto") googleapis_cpp_add_library("google/api/resource.proto")
googleapis_cpp_add_library("google/type/expr.proto") googleapis_cpp_add_library("google/type/expr.proto")
@ -211,31 +204,29 @@ googleapis_cpp_add_library("google/rpc/error_details.proto")
googleapis_cpp_add_library("google/rpc/status.proto" rpc_error_details_protos) googleapis_cpp_add_library("google/rpc/status.proto" rpc_error_details_protos)
googleapis_cpp_add_library("google/iam/v1/options.proto" api_annotations_protos) googleapis_cpp_add_library("google/iam/v1/options.proto" api_annotations_protos)
googleapis_cpp_add_library("google/iam/v1/policy.proto" googleapis_cpp_add_library("google/iam/v1/policy.proto" api_annotations_protos
api_annotations_protos
api_resource_protos
type_expr_protos) type_expr_protos)
googleapis_cpp_add_library("google/iam/v1/iam_policy.proto" googleapis_cpp_add_library(
"google/iam/v1/iam_policy.proto"
api_annotations_protos api_annotations_protos
api_client_protos api_client_protos
api_field_behavior_protos api_field_behavior_protos
api_resource_protos
iam_v1_options_protos iam_v1_options_protos
iam_v1_policy_protos) iam_v1_policy_protos)
googleapis_cpp_add_library("google/longrunning/operations.proto" googleapis_cpp_add_library(
api_annotations_protos rpc_status_protos) "google/longrunning/operations.proto" api_annotations_protos
api_client_protos rpc_status_protos)
googleapis_cpp_add_library("google/devtools/cloudtrace/v2/trace.proto" googleapis_cpp_add_library(
api_annotations_protos "google/devtools/cloudtrace/v2/trace.proto" api_annotations_protos
api_client_protos api_field_behavior_protos api_resource_protos rpc_status_protos)
api_field_behavior_protos googleapis_cpp_add_library(
api_resource_protos "google/devtools/cloudtrace/v2/tracing.proto"
rpc_status_protos) devtools_cloudtrace_v2_trace_protos api_annotations_protos
googleapis_cpp_add_library("google/devtools/cloudtrace/v2/tracing.proto" api_client_protos api_field_behavior_protos rpc_status_protos)
devtools_cloudtrace_v2_trace_protos
api_annotations_protos
rpc_status_protos)
google_cloud_cpp_grpcpp_library( google_cloud_cpp_grpcpp_library(
googleapis_cpp_cloud_bigquery_protos googleapis_cpp_cloud_bigquery_protos
@ -256,13 +247,16 @@ google_cloud_cpp_grpcpp_library(
"${GOOGLEAPIS_CPP_SOURCE}" "${GOOGLEAPIS_CPP_SOURCE}"
"${PROTO_INCLUDE_DIR}") "${PROTO_INCLUDE_DIR}")
googleapis_cpp_set_version_and_alias(cloud_bigquery_protos) googleapis_cpp_set_version_and_alias(cloud_bigquery_protos)
target_link_libraries(googleapis_cpp_cloud_bigquery_protos target_link_libraries(
googleapis_cpp_cloud_bigquery_protos
PUBLIC googleapis-c++::api_annotations_protos PUBLIC googleapis-c++::api_annotations_protos
googleapis-c++::api_http_protos
googleapis-c++::api_field_behavior_protos
googleapis-c++::api_client_protos googleapis-c++::api_client_protos
googleapis-c++::api_field_behavior_protos
googleapis-c++::api_resource_protos
googleapis-c++::iam_v1_iam_policy_protos googleapis-c++::iam_v1_iam_policy_protos
googleapis-c++::iam_v1_policy_protos
googleapis-c++::rpc_status_protos googleapis-c++::rpc_status_protos
googleapis-c++::api_http_protos
PRIVATE googleapis_cpp_common_flags) PRIVATE googleapis_cpp_common_flags)
google_cloud_cpp_grpcpp_library( google_cloud_cpp_grpcpp_library(
@ -278,24 +272,30 @@ google_cloud_cpp_grpcpp_library(
"${GOOGLEAPIS_CPP_SOURCE}" "${GOOGLEAPIS_CPP_SOURCE}"
"${PROTO_INCLUDE_DIR}") "${PROTO_INCLUDE_DIR}")
googleapis_cpp_set_version_and_alias(bigtable_protos) googleapis_cpp_set_version_and_alias(bigtable_protos)
target_link_libraries(googleapis_cpp_bigtable_protos target_link_libraries(
googleapis_cpp_bigtable_protos
PUBLIC googleapis-c++::api_annotations_protos PUBLIC googleapis-c++::api_annotations_protos
googleapis-c++::api_auth_protos googleapis-c++::api_client_protos
googleapis-c++::api_field_behavior_protos
googleapis-c++::api_resource_protos
googleapis-c++::iam_v1_iam_policy_protos
googleapis-c++::iam_v1_policy_protos
googleapis-c++::longrunning_operations_protos googleapis-c++::longrunning_operations_protos
googleapis-c++::rpc_status_protos googleapis-c++::rpc_status_protos
googleapis-c++::iam_v1_iam_policy_protos googleapis-c++::api_auth_protos
PRIVATE googleapis_cpp_common_flags) PRIVATE googleapis_cpp_common_flags)
google_cloud_cpp_grpcpp_library( google_cloud_cpp_grpcpp_library(
googleapis_cpp_pubsub_protos googleapis_cpp_pubsub_protos
"${GOOGLEAPIS_CPP_SOURCE}/google/pubsub/v1/pubsub.proto" "${GOOGLEAPIS_CPP_SOURCE}/google/pubsub/v1/pubsub.proto"
PROTO_PATH_DIRECTORIES PROTO_PATH_DIRECTORIES "${GOOGLEAPIS_CPP_SOURCE}" "${PROTO_INCLUDE_DIR}")
"${GOOGLEAPIS_CPP_SOURCE}"
"${PROTO_INCLUDE_DIR}")
googleapis_cpp_set_version_and_alias(pubsub_protos) googleapis_cpp_set_version_and_alias(pubsub_protos)
target_link_libraries(googleapis_cpp_pubsub_protos target_link_libraries(
googleapis_cpp_pubsub_protos
PUBLIC googleapis-c++::api_annotations_protos PUBLIC googleapis-c++::api_annotations_protos
googleapis-c++::api_client_protos googleapis-c++::api_client_protos
googleapis-c++::api_field_behavior_protos
googleapis-c++::api_resource_protos
PRIVATE googleapis_cpp_common_flags) PRIVATE googleapis_cpp_common_flags)
google_cloud_cpp_grpcpp_library( google_cloud_cpp_grpcpp_library(
@ -313,11 +313,16 @@ google_cloud_cpp_grpcpp_library(
"${GOOGLEAPIS_CPP_SOURCE}" "${GOOGLEAPIS_CPP_SOURCE}"
"${PROTO_INCLUDE_DIR}") "${PROTO_INCLUDE_DIR}")
googleapis_cpp_set_version_and_alias(spanner_protos) googleapis_cpp_set_version_and_alias(spanner_protos)
target_link_libraries(googleapis_cpp_spanner_protos target_link_libraries(
googleapis_cpp_spanner_protos
PUBLIC googleapis-c++::api_annotations_protos PUBLIC googleapis-c++::api_annotations_protos
googleapis-c++::api_client_protos
googleapis-c++::api_field_behavior_protos
googleapis-c++::api_resource_protos
googleapis-c++::iam_v1_iam_policy_protos
googleapis-c++::iam_v1_policy_protos
googleapis-c++::longrunning_operations_protos googleapis-c++::longrunning_operations_protos
googleapis-c++::rpc_status_protos googleapis-c++::rpc_status_protos
googleapis-c++::iam_v1_iam_policy_protos
PRIVATE googleapis_cpp_common_flags) PRIVATE googleapis_cpp_common_flags)
# Install the libraries and headers in the locations determined by # Install the libraries and headers in the locations determined by
@ -345,7 +350,8 @@ set(googleapis_cpp_installed_libraries_list
googleapis_cpp_rpc_status_protos googleapis_cpp_rpc_status_protos
googleapis_cpp_type_expr_protos) googleapis_cpp_type_expr_protos)
install(TARGETS ${googleapis_cpp_installed_libraries_list} install(
TARGETS ${googleapis_cpp_installed_libraries_list}
googleapis_cpp_common_flags googleapis_cpp_common_flags
EXPORT googleapis-targets EXPORT googleapis-targets
RUNTIME DESTINATION bin RUNTIME DESTINATION bin
@ -372,14 +378,8 @@ set(GOOGLE_CLOUD_CPP_CONFIG_VERSION_PATCH
# Use a function to create a scope for the variables. # Use a function to create a scope for the variables.
function (googleapis_cpp_install_pc target) function (googleapis_cpp_install_pc target)
string(REPLACE "googleapis_cpp_" string(REPLACE "googleapis_cpp_" "" _short_name ${target})
"" string(REPLACE "_protos" "" _short_name ${_short_name})
_short_name
${target})
string(REPLACE "_protos"
""
_short_name
${_short_name})
set(GOOGLE_CLOUD_CPP_PC_NAME set(GOOGLE_CLOUD_CPP_PC_NAME
"The Google APIS C++ ${_short_name} Proto Library") "The Google APIS C++ ${_short_name} Proto Library")
set(GOOGLE_CLOUD_CPP_PC_DESCRIPTION "Compiled proto for C++.") set(GOOGLE_CLOUD_CPP_PC_DESCRIPTION "Compiled proto for C++.")
@ -389,15 +389,14 @@ function (googleapis_cpp_install_pc target)
get_target_property(_target_deps ${target} LINK_LIBRARIES) get_target_property(_target_deps ${target} LINK_LIBRARIES)
foreach (dep ${_target_deps}) foreach (dep ${_target_deps})
if ("${dep}" MATCHES "^googleapis-c\\+\\+::") if ("${dep}" MATCHES "^googleapis-c\\+\\+::")
string(REPLACE "googleapis-c++::" string(REPLACE "googleapis-c++::" "googleapis_cpp_" dep "${dep}")
"googleapis_cpp_"
dep
"${dep}")
list(APPEND _target_pc_requires " " "${dep}") list(APPEND _target_pc_requires " " "${dep}")
endif () endif ()
endforeach () endforeach ()
# These dependencies are required for all the googleapis-c++::* libraries. # These dependencies are required for all the googleapis-c++::* libraries.
list(APPEND _target_pc_requires list(
APPEND
_target_pc_requires
" grpc++" " grpc++"
" grpc" " grpc"
" openssl" " openssl"
@ -422,7 +421,8 @@ set(GOOGLE_CLOUD_CPP_PC_DESCRIPTION
"Provides C++ APIs to access Google Cloud Platforms.") "Provides C++ APIs to access Google Cloud Platforms.")
# Note the use of spaces, `string(JOIN)` is not available in cmake-3.5, so we # Note the use of spaces, `string(JOIN)` is not available in cmake-3.5, so we
# need to add the separator ourselves. # need to add the separator ourselves.
string(CONCAT GOOGLE_CLOUD_CPP_PC_REQUIRES string(
CONCAT GOOGLE_CLOUD_CPP_PC_REQUIRES
"googleapis_cpp_bigtable_protos" "googleapis_cpp_bigtable_protos"
" googleapis_cpp_cloud_bigquery_protos" " googleapis_cpp_cloud_bigquery_protos"
" googleapis_cpp_iam_v1_iam_policy_protos" " googleapis_cpp_iam_v1_iam_policy_protos"
@ -449,9 +449,10 @@ install(FILES "${CMAKE_CURRENT_BINARY_DIR}/googleapis.pc"
# Create and install the CMake configuration files. # Create and install the CMake configuration files.
configure_file("cmake/config.cmake.in" "googleapis-config.cmake" @ONLY) configure_file("cmake/config.cmake.in" "googleapis-config.cmake" @ONLY)
configure_file("cmake/config-version.cmake.in" "googleapis-config-version.cmake" configure_file("cmake/config-version.cmake.in"
@ONLY) "googleapis-config-version.cmake" @ONLY)
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/googleapis-config.cmake" install(
FILES "${CMAKE_CURRENT_BINARY_DIR}/googleapis-config.cmake"
"${CMAKE_CURRENT_BINARY_DIR}/googleapis-config-version.cmake" "${CMAKE_CURRENT_BINARY_DIR}/googleapis-config-version.cmake"
"${PROJECT_SOURCE_DIR}/cmake/FindgRPC.cmake" "${PROJECT_SOURCE_DIR}/cmake/FindgRPC.cmake"
"${PROJECT_SOURCE_DIR}/cmake/FindProtobufTargets.cmake" "${PROJECT_SOURCE_DIR}/cmake/FindProtobufTargets.cmake"

View file

@ -35,4 +35,4 @@ RUN chmod 755 /usr/bin/buildifier
# "latest" version is updated, and we do not want the builds to break just # "latest" version is updated, and we do not want the builds to break just
# because some third party changed something. # because some third party changed something.
RUN pip install --upgrade pip RUN pip install --upgrade pip
RUN pip install numpy cmake_format==0.5.2 RUN pip install numpy cmake_format==0.6.9

View file

@ -19,11 +19,10 @@
# We use a function to define the property so it can be called multiple times # We use a function to define the property so it can be called multiple times
# without introducing the property over and over. # without introducing the property over and over.
function (google_cloud_cpp_add_protos_property) function (google_cloud_cpp_add_protos_property)
set_property(TARGET set_property(
PROPERTY PROTO_SOURCES TARGET
BRIEF_DOCS PROPERTY PROTO_SOURCES BRIEF_DOCS
"The list of .proto files for a target." "The list of .proto files for a target." FULL_DOCS
FULL_DOCS
"List of .proto files specified for a target.") "List of .proto files specified for a target.")
endfunction () endfunction ()
@ -54,11 +53,7 @@ endfunction ()
# `foo/bar/baz.proto` then the directory containing `foo` must be in the search # `foo/bar/baz.proto` then the directory containing `foo` must be in the search
# path. # path.
function (google_cloud_cpp_generate_proto SRCS) function (google_cloud_cpp_generate_proto SRCS)
cmake_parse_arguments(_opt cmake_parse_arguments(_opt "" "" "PROTO_PATH_DIRECTORIES" ${ARGN})
""
""
"PROTO_PATH_DIRECTORIES"
${ARGN})
if (NOT _opt_UNPARSED_ARGUMENTS) if (NOT _opt_UNPARSED_ARGUMENTS)
message(SEND_ERROR "Error: google_cloud_cpp_generate_proto() called" message(SEND_ERROR "Error: google_cloud_cpp_generate_proto() called"
" without any proto files") " without any proto files")
@ -89,11 +84,7 @@ function (google_cloud_cpp_generate_proto SRCS)
set(D "${file_directory}") set(D "${file_directory}")
if (DEFINED _opt_PROTO_PATH_DIRECTORIES) if (DEFINED _opt_PROTO_PATH_DIRECTORIES)
foreach (P ${_opt_PROTO_PATH_DIRECTORIES}) foreach (P ${_opt_PROTO_PATH_DIRECTORIES})
string(REGEX string(REGEX REPLACE "^${P}" "" T "${D}")
REPLACE "^${P}"
""
T
"${D}")
set(D ${T}) set(D ${T})
endforeach () endforeach ()
endif () endif ()
@ -102,22 +93,19 @@ function (google_cloud_cpp_generate_proto SRCS)
list(APPEND ${SRCS} "${pb_cc}" "${pb_h}") list(APPEND ${SRCS} "${pb_cc}" "${pb_h}")
add_custom_command( add_custom_command(
OUTPUT "${pb_cc}" "${pb_h}" OUTPUT "${pb_cc}" "${pb_h}"
COMMAND $<TARGET_FILE:protobuf::protoc> COMMAND
ARGS $<TARGET_FILE:protobuf::protoc> ARGS --cpp_out
--cpp_out "${CMAKE_CURRENT_BINARY_DIR}" ${protobuf_include_path}
"${CMAKE_CURRENT_BINARY_DIR}"
${protobuf_include_path}
"${filename}" "${filename}"
DEPENDS "${filename}" protobuf::protoc DEPENDS "${filename}" protobuf::protoc
COMMENT "Running C++ protocol buffer compiler on ${filename}" COMMENT "Running C++ protocol buffer compiler on ${filename}"
VERBATIM) VERBATIM)
endforeach () endforeach ()
set_source_files_properties(${${SRCS}} set_source_files_properties(${${SRCS}} PROPERTIES GENERATED TRUE)
PROPERTIES set(${SRCS}
GENERATED ${${SRCS}}
TRUE) PARENT_SCOPE)
set(${SRCS} ${${SRCS}} PARENT_SCOPE)
endfunction () endfunction ()
# Generate gRPC C++ files from .proto files preserving the directory hierarchy. # Generate gRPC C++ files from .proto files preserving the directory hierarchy.
@ -147,11 +135,7 @@ endfunction ()
# `foo/bar/baz.proto` then the directory containing `foo` must be in the search # `foo/bar/baz.proto` then the directory containing `foo` must be in the search
# path. # path.
function (google_cloud_cpp_generate_grpcpp SRCS) function (google_cloud_cpp_generate_grpcpp SRCS)
cmake_parse_arguments(_opt cmake_parse_arguments(_opt "" "" "PROTO_PATH_DIRECTORIES" ${ARGN})
""
""
"PROTO_PATH_DIRECTORIES"
${ARGN})
if (NOT _opt_UNPARSED_ARGUMENTS) if (NOT _opt_UNPARSED_ARGUMENTS)
message( message(
SEND_ERROR "Error: google_cloud_cpp_generate_grpc() called without" SEND_ERROR "Error: google_cloud_cpp_generate_grpc() called without"
@ -183,11 +167,7 @@ function (google_cloud_cpp_generate_grpcpp SRCS)
set(D "${file_directory}") set(D "${file_directory}")
if (DEFINED _opt_PROTO_PATH_DIRECTORIES) if (DEFINED _opt_PROTO_PATH_DIRECTORIES)
foreach (P ${_opt_PROTO_PATH_DIRECTORIES}) foreach (P ${_opt_PROTO_PATH_DIRECTORIES})
string(REGEX string(REGEX REPLACE "^${P}" "" T "${D}")
REPLACE "^${P}"
""
T
"${D}")
set(D ${T}) set(D ${T})
endforeach () endforeach ()
endif () endif ()
@ -198,23 +178,20 @@ function (google_cloud_cpp_generate_grpcpp SRCS)
add_custom_command( add_custom_command(
OUTPUT "${grpc_pb_cc}" "${grpc_pb_h}" OUTPUT "${grpc_pb_cc}" "${grpc_pb_h}"
COMMAND COMMAND
$<TARGET_FILE:protobuf::protoc> $<TARGET_FILE:protobuf::protoc> ARGS
ARGS
--plugin=protoc-gen-grpc=$<TARGET_FILE:gRPC::grpc_cpp_plugin> --plugin=protoc-gen-grpc=$<TARGET_FILE:gRPC::grpc_cpp_plugin>
"--grpc_out=${CMAKE_CURRENT_BINARY_DIR}" "--grpc_out=${CMAKE_CURRENT_BINARY_DIR}"
"--cpp_out=${CMAKE_CURRENT_BINARY_DIR}" "--cpp_out=${CMAKE_CURRENT_BINARY_DIR}" ${protobuf_include_path}
${protobuf_include_path}
"${filename}" "${filename}"
DEPENDS "${filename}" protobuf::protoc gRPC::grpc_cpp_plugin DEPENDS "${filename}" protobuf::protoc gRPC::grpc_cpp_plugin
COMMENT "Running gRPC C++ protocol buffer compiler on ${filename}" COMMENT "Running gRPC C++ protocol buffer compiler on ${filename}"
VERBATIM) VERBATIM)
endforeach () endforeach ()
set_source_files_properties(${${SRCS}} set_source_files_properties(${${SRCS}} PROPERTIES GENERATED TRUE)
PROPERTIES set(${SRCS}
GENERATED ${${SRCS}}
TRUE) PARENT_SCOPE)
set(${SRCS} ${${SRCS}} PARENT_SCOPE)
endfunction () endfunction ()
include(GNUInstallDirs) include(GNUInstallDirs)
@ -227,10 +204,7 @@ function (google_cloud_cpp_install_proto_library_headers target)
if (NOT "${header}" MATCHES "\\.h$") if (NOT "${header}" MATCHES "\\.h$")
continue() continue()
endif () endif ()
string(REPLACE "${CMAKE_CURRENT_BINARY_DIR}/" string(REPLACE "${CMAKE_CURRENT_BINARY_DIR}/" "" relative "${header}")
""
relative
"${header}")
get_filename_component(dir "${relative}" DIRECTORY) get_filename_component(dir "${relative}" DIRECTORY)
install(FILES "${header}" install(FILES "${header}"
DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/${dir}") DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/${dir}")
@ -245,10 +219,7 @@ function (google_cloud_cpp_install_proto_library_protos target strip_prefix)
if (NOT "${proto}" MATCHES "\\.proto$") if (NOT "${proto}" MATCHES "\\.proto$")
continue() continue()
endif () endif ()
string(REPLACE "${strip_prefix}/" string(REPLACE "${strip_prefix}/" "" relative "${proto}")
""
relative
"${proto}")
get_filename_component(dir "${relative}" DIRECTORY) get_filename_component(dir "${relative}" DIRECTORY)
# This is modeled after the Protobuf library, it installs the basic # This is modeled after the Protobuf library, it installs the basic
# protos (think google/protobuf/any.proto) in the include directory for # protos (think google/protobuf/any.proto) in the include directory for
@ -259,27 +230,22 @@ function (google_cloud_cpp_install_proto_library_protos target strip_prefix)
endfunction () endfunction ()
function (google_cloud_cpp_proto_library libname) function (google_cloud_cpp_proto_library libname)
cmake_parse_arguments(_opt cmake_parse_arguments(_opt "" "" "PROTO_PATH_DIRECTORIES" ${ARGN})
""
""
"PROTO_PATH_DIRECTORIES"
${ARGN})
if (NOT _opt_UNPARSED_ARGUMENTS) if (NOT _opt_UNPARSED_ARGUMENTS)
message(SEND_ERROR "Error: google_cloud_cpp_proto_library() called" message(SEND_ERROR "Error: google_cloud_cpp_proto_library() called"
" without any proto files") " without any proto files")
return() return()
endif () endif ()
google_cloud_cpp_generate_proto(proto_sources google_cloud_cpp_generate_proto(
${_opt_UNPARSED_ARGUMENTS} proto_sources ${_opt_UNPARSED_ARGUMENTS} PROTO_PATH_DIRECTORIES
PROTO_PATH_DIRECTORIES
${_opt_PROTO_PATH_DIRECTORIES}) ${_opt_PROTO_PATH_DIRECTORIES})
add_library(${libname} ${proto_sources}) add_library(${libname} ${proto_sources})
set_property(TARGET ${libname} set_property(TARGET ${libname} PROPERTY PROTO_SOURCES
PROPERTY PROTO_SOURCES ${_opt_UNPARSED_ARGUMENTS}) ${_opt_UNPARSED_ARGUMENTS})
target_link_libraries(${libname} target_link_libraries(${libname} PUBLIC gRPC::grpc++ gRPC::grpc
PUBLIC gRPC::grpc++ gRPC::grpc protobuf::libprotobuf) protobuf::libprotobuf)
target_include_directories( target_include_directories(
${libname} ${libname}
PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}> PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}>
@ -288,24 +254,18 @@ function (google_cloud_cpp_proto_library libname)
endfunction () endfunction ()
function (google_cloud_cpp_grpcpp_library libname) function (google_cloud_cpp_grpcpp_library libname)
cmake_parse_arguments(_opt cmake_parse_arguments(_opt "" "" "PROTO_PATH_DIRECTORIES" ${ARGN})
""
""
"PROTO_PATH_DIRECTORIES"
${ARGN})
if (NOT _opt_UNPARSED_ARGUMENTS) if (NOT _opt_UNPARSED_ARGUMENTS)
message(SEND_ERROR "Error: google_cloud_cpp_proto_library() called" message(SEND_ERROR "Error: google_cloud_cpp_proto_library() called"
" without any proto files") " without any proto files")
return() return()
endif () endif ()
google_cloud_cpp_generate_grpcpp(grpcpp_sources google_cloud_cpp_generate_grpcpp(
${_opt_UNPARSED_ARGUMENTS} grpcpp_sources ${_opt_UNPARSED_ARGUMENTS} PROTO_PATH_DIRECTORIES
PROTO_PATH_DIRECTORIES
${_opt_PROTO_PATH_DIRECTORIES}) ${_opt_PROTO_PATH_DIRECTORIES})
google_cloud_cpp_proto_library(${libname} google_cloud_cpp_proto_library(
${_opt_UNPARSED_ARGUMENTS} ${libname} ${_opt_UNPARSED_ARGUMENTS} PROTO_PATH_DIRECTORIES
PROTO_PATH_DIRECTORIES
${_opt_PROTO_PATH_DIRECTORIES}) ${_opt_PROTO_PATH_DIRECTORIES})
target_sources(${libname} PRIVATE ${grpcpp_sources}) target_sources(${libname} PRIVATE ${grpcpp_sources})
endfunction () endfunction ()

View file

@ -107,35 +107,35 @@ else ()
if (NOT TARGET protobuf::libprotobuf) if (NOT TARGET protobuf::libprotobuf)
add_library(protobuf::libprotobuf IMPORTED INTERFACE) add_library(protobuf::libprotobuf IMPORTED INTERFACE)
set_property(TARGET protobuf::libprotobuf set_property(
PROPERTY INTERFACE_INCLUDE_DIRECTORIES TARGET protobuf::libprotobuf
${Protobuf_INCLUDE_DIR}) PROPERTY INTERFACE_INCLUDE_DIRECTORIES ${Protobuf_INCLUDE_DIR})
set_property(TARGET protobuf::libprotobuf set_property(
APPEND TARGET protobuf::libprotobuf APPEND
PROPERTY INTERFACE_LINK_LIBRARIES ${Protobuf_LIBRARY} PROPERTY INTERFACE_LINK_LIBRARIES ${Protobuf_LIBRARY}
Threads::Threads) Threads::Threads)
endif () endif ()
if (NOT TARGET protobuf::libprotobuf-lite) if (NOT TARGET protobuf::libprotobuf-lite)
add_library(protobuf::libprotobuf-lite IMPORTED INTERFACE) add_library(protobuf::libprotobuf-lite IMPORTED INTERFACE)
set_property(TARGET protobuf::libprotobuf-lite set_property(
PROPERTY INTERFACE_INCLUDE_DIRECTORIES TARGET protobuf::libprotobuf-lite
${Protobuf_INCLUDE_DIR}) PROPERTY INTERFACE_INCLUDE_DIRECTORIES ${Protobuf_INCLUDE_DIR})
set_property(TARGET protobuf::libprotobuf-lite set_property(
APPEND TARGET protobuf::libprotobuf-lite APPEND
PROPERTY INTERFACE_LINK_LIBRARIES PROPERTY INTERFACE_LINK_LIBRARIES ${Protobuf_LITE_LIBRARY}
${Protobuf_LITE_LIBRARY} Threads::Threads) Threads::Threads)
endif () endif ()
if (NOT TARGET protobuf::libprotoc) if (NOT TARGET protobuf::libprotoc)
add_library(protobuf::libprotoc IMPORTED INTERFACE) add_library(protobuf::libprotoc IMPORTED INTERFACE)
set_property(TARGET protobuf::libprotoc set_property(
PROPERTY INTERFACE_INCLUDE_DIRECTORIES TARGET protobuf::libprotoc
${Protobuf_INCLUDE_DIR}) PROPERTY INTERFACE_INCLUDE_DIRECTORIES ${Protobuf_INCLUDE_DIR})
set_property(TARGET protobuf::libprotoc set_property(
APPEND TARGET protobuf::libprotoc APPEND
PROPERTY INTERFACE_LINK_LIBRARIES PROPERTY INTERFACE_LINK_LIBRARIES ${Protobuf_PROTOC_LIBRARY}
${Protobuf_PROTOC_LIBRARY} Threads::Threads) Threads::Threads)
endif () endif ()
endif () endif ()
endif () endif ()
@ -152,7 +152,8 @@ if (ProtobufTargets_FOUND AND NOT TARGET protobuf::protoc)
add_executable(protobuf::protoc IMPORTED) add_executable(protobuf::protoc IMPORTED)
# Discover the protoc compiler location. # Discover the protoc compiler location.
find_program(_protobuf_PROTOC_EXECUTABLE find_program(
_protobuf_PROTOC_EXECUTABLE
NAMES protoc NAMES protoc
DOC "The Google Protocol Buffers Compiler") DOC "The Google Protocol Buffers Compiler")
if (protobuf_DEBUG) if (protobuf_DEBUG)
@ -165,10 +166,10 @@ if (ProtobufTargets_FOUND AND NOT TARGET protobuf::protoc)
set_property(TARGET protobuf::protoc set_property(TARGET protobuf::protoc
PROPERTY IMPORTED_LOCATION ${_protobuf_PROTOC_EXECUTABLE}) PROPERTY IMPORTED_LOCATION ${_protobuf_PROTOC_EXECUTABLE})
set_property( set_property(
TARGET protobuf::protoc TARGET protobuf::protoc PROPERTY IMPORTED_LOCATION_DEBUG
PROPERTY IMPORTED_LOCATION_DEBUG ${_protobuf_PROTOC_EXECUTABLE}) ${_protobuf_PROTOC_EXECUTABLE})
set_property(TARGET protobuf::protoc set_property(
PROPERTY IMPORTED_LOCATION_RELEASE TARGET protobuf::protoc PROPERTY IMPORTED_LOCATION_RELEASE
${_protobuf_PROTOC_EXECUTABLE}) ${_protobuf_PROTOC_EXECUTABLE})
unset(_protobuf_PROTOC_EXECUTABLE) unset(_protobuf_PROTOC_EXECUTABLE)
@ -186,9 +187,7 @@ if (protobuf_DEBUG)
"ProtobufTargets_FOUND = ${ProtobufTargets_FOUND}" "ProtobufTargets_FOUND = ${ProtobufTargets_FOUND}"
" ProtobufTargets_VERSION = ${ProtobufTargets_VERSION}") " ProtobufTargets_VERSION = ${ProtobufTargets_VERSION}")
if (ProtobufTargets_FOUND) if (ProtobufTargets_FOUND)
foreach (_target foreach (_target protobuf::libprotobuf protobuf::libprotobuf-lite
protobuf::libprotobuf
protobuf::libprotobuf-lite
protobuf::libprotoc) protobuf::libprotoc)
if (NOT TARGET ${_target}) if (NOT TARGET ${_target})
message( message(
@ -201,7 +200,5 @@ if (protobuf_DEBUG)
endif () endif ()
endif () endif ()
find_package_handle_standard_args(ProtobufTargets find_package_handle_standard_args(ProtobufTargets REQUIRED_VARS
REQUIRED_VARS ProtobufTargets_FOUND ProtobufTargets_VERSION)
ProtobufTargets_FOUND
ProtobufTargets_VERSION)

View file

@ -92,9 +92,9 @@ function (_grpc_fix_grpc_cpp_plugin_target)
DOC "The gRPC C++ plugin for protoc") DOC "The gRPC C++ plugin for protoc")
mark_as_advanced(_gRPC_CPP_PLUGIN_EXECUTABLE) mark_as_advanced(_gRPC_CPP_PLUGIN_EXECUTABLE)
if (_gRPC_CPP_PLUGIN_EXECUTABLE) if (_gRPC_CPP_PLUGIN_EXECUTABLE)
set_property(TARGET gRPC::grpc_cpp_plugin set_property(
PROPERTY IMPORTED_LOCATION TARGET gRPC::grpc_cpp_plugin
${_gRPC_CPP_PLUGIN_EXECUTABLE}) PROPERTY IMPORTED_LOCATION ${_gRPC_CPP_PLUGIN_EXECUTABLE})
else () else ()
set(gRPC_FOUND "grpc_cpp_plugin-NOTFOUND") set(gRPC_FOUND "grpc_cpp_plugin-NOTFOUND")
endif () endif ()
@ -106,11 +106,9 @@ endfunction ()
function (_grpc_fix_grpc_target_definitions) function (_grpc_fix_grpc_target_definitions)
# Including gRPC headers without this definition results in a build error. # Including gRPC headers without this definition results in a build error.
if (WIN32) if (WIN32)
set_property(TARGET gRPC::grpc set_property(TARGET gRPC::grpc APPEND
APPEND
PROPERTY INTERFACE_COMPILE_DEFINITIONS _WIN32_WINNT=0x600) PROPERTY INTERFACE_COMPILE_DEFINITIONS _WIN32_WINNT=0x600)
set_property(TARGET gRPC::grpc++ set_property(TARGET gRPC::grpc++ APPEND
APPEND
PROPERTY INTERFACE_COMPILE_DEFINITIONS _WIN32_WINNT=0x600) PROPERTY INTERFACE_COMPILE_DEFINITIONS _WIN32_WINNT=0x600)
endif () endif ()
endfunction () endfunction ()
@ -158,7 +156,9 @@ function (_gRPC_find_library name filename)
) )
endif () endif ()
set(${name}_LIBRARY "${${name}_LIBRARY}" PARENT_SCOPE) set(${name}_LIBRARY
"${${name}_LIBRARY}"
PARENT_SCOPE)
endif () endif ()
endfunction () endfunction ()
@ -196,32 +196,29 @@ endif ()
if (_gRPC_grpc_LIBRARY) if (_gRPC_grpc_LIBRARY)
if (NOT TARGET gRPC::grpc) if (NOT TARGET gRPC::grpc)
add_library(gRPC::grpc IMPORTED UNKNOWN) add_library(gRPC::grpc IMPORTED UNKNOWN)
set_target_properties(gRPC::grpc set_target_properties(
PROPERTIES INTERFACE_INCLUDE_DIRECTORIES gRPC::grpc PROPERTIES INTERFACE_INCLUDE_DIRECTORIES
"${_gRPC_INCLUDE_DIR}") "${_gRPC_INCLUDE_DIR}")
if (EXISTS "${_gRPC_grpc_LIBRARY}") if (EXISTS "${_gRPC_grpc_LIBRARY}")
set_target_properties(gRPC::grpc set_target_properties(gRPC::grpc PROPERTIES IMPORTED_LOCATION
PROPERTIES IMPORTED_LOCATION
"${_gRPC_grpc_LIBRARY}") "${_gRPC_grpc_LIBRARY}")
endif () endif ()
if (EXISTS "${_gRPC_grpc_LIBRARY_RELEASE}") if (EXISTS "${_gRPC_grpc_LIBRARY_RELEASE}")
set_property(TARGET gRPC::grpc set_property(TARGET gRPC::grpc APPEND
APPEND
PROPERTY IMPORTED_CONFIGURATIONS RELEASE) PROPERTY IMPORTED_CONFIGURATIONS RELEASE)
set_target_properties(gRPC::grpc set_target_properties(
PROPERTIES IMPORTED_LOCATION_RELEASE gRPC::grpc PROPERTIES IMPORTED_LOCATION_RELEASE
"${_gRPC_grpc_LIBRARY_RELEASE}") "${_gRPC_grpc_LIBRARY_RELEASE}")
endif () endif ()
if (EXISTS "${_gRPC_grpc_LIBRARY_DEBUG}") if (EXISTS "${_gRPC_grpc_LIBRARY_DEBUG}")
set_property(TARGET gRPC::grpc set_property(TARGET gRPC::grpc APPEND
APPEND
PROPERTY IMPORTED_CONFIGURATIONS DEBUG) PROPERTY IMPORTED_CONFIGURATIONS DEBUG)
set_target_properties(gRPC::grpc set_target_properties(
PROPERTIES IMPORTED_LOCATION_DEBUG gRPC::grpc PROPERTIES IMPORTED_LOCATION_DEBUG
"${_gRPC_grpc_LIBRARY_DEBUG}") "${_gRPC_grpc_LIBRARY_DEBUG}")
endif () endif ()
set_property(TARGET gRPC::grpc set_property(
APPEND TARGET gRPC::grpc APPEND
PROPERTY INTERFACE_LINK_LIBRARIES protobuf::libprotobuf PROPERTY INTERFACE_LINK_LIBRARIES protobuf::libprotobuf
Threads::Threads) Threads::Threads)
endif () endif ()
@ -230,51 +227,44 @@ endif ()
if (_gRPC_grpc++_LIBRARY) if (_gRPC_grpc++_LIBRARY)
if (NOT TARGET gRPC::grpc++) if (NOT TARGET gRPC::grpc++)
add_library(gRPC::grpc++ IMPORTED UNKNOWN) add_library(gRPC::grpc++ IMPORTED UNKNOWN)
set_target_properties(gRPC::grpc++ set_target_properties(
PROPERTIES INTERFACE_INCLUDE_DIRECTORIES gRPC::grpc++ PROPERTIES INTERFACE_INCLUDE_DIRECTORIES
"${_gRPC++_INCLUDE_DIR}") "${_gRPC++_INCLUDE_DIR}")
if (EXISTS "${_gRPC_grpc++_LIBRARY}") if (EXISTS "${_gRPC_grpc++_LIBRARY}")
set_target_properties(gRPC::grpc++ set_target_properties(
PROPERTIES IMPORTED_LOCATION gRPC::grpc++ PROPERTIES IMPORTED_LOCATION
"${_gRPC_grpc++_LIBRARY}") "${_gRPC_grpc++_LIBRARY}")
endif () endif ()
if (EXISTS "${_gRPC_grpc++_LIBRARY_RELEASE}") if (EXISTS "${_gRPC_grpc++_LIBRARY_RELEASE}")
set_property(TARGET gRPC::grpc++ set_property(TARGET gRPC::grpc++ APPEND
APPEND
PROPERTY IMPORTED_CONFIGURATIONS RELEASE) PROPERTY IMPORTED_CONFIGURATIONS RELEASE)
set_target_properties(gRPC::grpc++ set_target_properties(
PROPERTIES IMPORTED_LOCATION_RELEASE gRPC::grpc++ PROPERTIES IMPORTED_LOCATION_RELEASE
"${_gRPC_grpc++_LIBRARY_RELEASE}") "${_gRPC_grpc++_LIBRARY_RELEASE}")
endif () endif ()
if (EXISTS "${_gRPC_grpc++_LIBRARY_DEBUG}") if (EXISTS "${_gRPC_grpc++_LIBRARY_DEBUG}")
set_property(TARGET gRPC::grpc++ set_property(TARGET gRPC::grpc++ APPEND
APPEND
PROPERTY IMPORTED_CONFIGURATIONS DEBUG) PROPERTY IMPORTED_CONFIGURATIONS DEBUG)
set_target_properties(gRPC::grpc++ set_target_properties(
PROPERTIES IMPORTED_LOCATION_DEBUG gRPC::grpc++ PROPERTIES IMPORTED_LOCATION_DEBUG
"${_gRPC_grpc++_LIBRARY_DEBUG}") "${_gRPC_grpc++_LIBRARY_DEBUG}")
endif () endif ()
set_property(TARGET gRPC::grpc++ set_property(
APPEND TARGET gRPC::grpc++ APPEND
PROPERTY INTERFACE_LINK_LIBRARIES PROPERTY INTERFACE_LINK_LIBRARIES gRPC::grpc protobuf::libprotobuf
gRPC::grpc
protobuf::libprotobuf
Threads::Threads) Threads::Threads)
if (CMAKE_VERSION VERSION_GREATER 3.8) if (CMAKE_VERSION VERSION_GREATER 3.8)
# gRPC++ requires C++11, but only CMake-3.8 introduced a target # gRPC++ requires C++11, but only CMake-3.8 introduced a target
# compiler feature to meet that requirement. # compiler feature to meet that requirement.
set_property(TARGET gRPC::grpc++ set_property(TARGET gRPC::grpc++ APPEND
APPEND
PROPERTY INTERFACE_COMPILE_FEATURES cxx_std_11) PROPERTY INTERFACE_COMPILE_FEATURES cxx_std_11)
elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU") elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
# CMake 3.5 is still alive and kicking in some older distros, use # CMake 3.5 is still alive and kicking in some older distros, use
# the compiler-specific versions in these cases. # the compiler-specific versions in these cases.
set_property(TARGET gRPC::grpc++ set_property(TARGET gRPC::grpc++ APPEND
APPEND
PROPERTY INTERFACE_COMPILE_OPTIONS "-std=c++11") PROPERTY INTERFACE_COMPILE_OPTIONS "-std=c++11")
elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
set_property(TARGET gRPC::grpc++ set_property(TARGET gRPC::grpc++ APPEND
APPEND
PROPERTY INTERFACE_COMPILE_OPTIONS "-std=c++11") PROPERTY INTERFACE_COMPILE_OPTIONS "-std=c++11")
else () else ()
message( message(
@ -294,7 +284,9 @@ if (_gRPC_USE_STATIC_LIBS)
set(CMAKE_FIND_LIBRARY_PREFIXES "${_gRPC_ORIG_FIND_LIBRARY_PREFIXES}") set(CMAKE_FIND_LIBRARY_PREFIXES "${_gRPC_ORIG_FIND_LIBRARY_PREFIXES}")
endif () endif ()
file(WRITE "${CMAKE_BINARY_DIR}/get_gRPC_version.cc" [====[ file(
WRITE "${CMAKE_BINARY_DIR}/get_gRPC_version.cc"
[====[
#include <grpcpp/grpcpp.h> #include <grpcpp/grpcpp.h>
#include <iostream> #include <iostream>
int main() { int main() {
@ -303,7 +295,8 @@ int main() {
} }
]====]) ]====])
try_run(_gRPC_GET_VERSION_STATUS try_run(
_gRPC_GET_VERSION_STATUS
_gRPC_GET_VERSION_COMPILE_STATUS _gRPC_GET_VERSION_COMPILE_STATUS
"${CMAKE_BINARY_DIR}" "${CMAKE_BINARY_DIR}"
"${CMAKE_BINARY_DIR}/get_gRPC_version.cc" "${CMAKE_BINARY_DIR}/get_gRPC_version.cc"
@ -318,7 +311,8 @@ file(REMOVE "${CMAKE_BINARY_DIR}/get_gRPC_version.cc")
_grpc_fix_grpc_cpp_plugin_target() _grpc_fix_grpc_cpp_plugin_target()
if (gRPC_DEBUG) if (gRPC_DEBUG)
foreach (_var foreach (
_var
_gRPC_CPP_PLUGIN_EXECUTABLE _gRPC_CPP_PLUGIN_EXECUTABLE
_gRPC_VERSION_RAW _gRPC_VERSION_RAW
_gRPC_GET_VERSION_STATUS _gRPC_GET_VERSION_STATUS
@ -335,9 +329,5 @@ if (gRPC_DEBUG)
endif () endif ()
include(FindPackageHandleStandardArgs) include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(gRPC find_package_handle_standard_args(gRPC REQUIRED_VARS _gRPC_grpc_LIBRARY
REQUIRED_VARS _gRPC_INCLUDE_DIR VERSION_VAR gRPC_VERSION)
_gRPC_grpc_LIBRARY
_gRPC_INCLUDE_DIR
VERSION_VAR
gRPC_VERSION)

View file

@ -29,17 +29,10 @@
# #
if (MSVC AND VCPKG_TARGET_TRIPLET MATCHES "-static$") if (MSVC AND VCPKG_TARGET_TRIPLET MATCHES "-static$")
foreach (flag_var foreach (flag_var
CMAKE_CXX_FLAGS CMAKE_CXX_FLAGS CMAKE_CXX_FLAGS_DEBUG CMAKE_CXX_FLAGS_RELEASE
CMAKE_CXX_FLAGS_DEBUG CMAKE_CXX_FLAGS_MINSIZEREL CMAKE_CXX_FLAGS_RELWITHDEBINFO)
CMAKE_CXX_FLAGS_RELEASE
CMAKE_CXX_FLAGS_MINSIZEREL
CMAKE_CXX_FLAGS_RELWITHDEBINFO)
if (${flag_var} MATCHES "/MD") if (${flag_var} MATCHES "/MD")
string(REGEX string(REGEX REPLACE "/MD" "/MT" ${flag_var} "${${flag_var}}")
REPLACE "/MD"
"/MT"
${flag_var}
"${${flag_var}}")
endif () endif ()
endforeach (flag_var) endforeach (flag_var)
unset(flag_var) unset(flag_var)