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

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

View file

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

View file

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

View file

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