Update third_party protobuf to v3.6.1

Summary: Pull Request resolved: https://github.com/pytorch/pytorch/pull/16251

Reviewed By: ezyang

Differential Revision: D13781444

Pulled By: bddppq

fbshipit-source-id: b713a021033d214f30a49ee02b95edf8633bcc50
This commit is contained in:
Junjie Bai
2019-01-23 09:31:14 -08:00
committed by Facebook Github Bot
parent e669f72466
commit 9310eb1fd0
3 changed files with 23 additions and 12 deletions

View File

@ -63,7 +63,12 @@ macro(custom_protobuf_find)
if (NOT TARGET protobuf::libprotobuf)
add_library(protobuf::libprotobuf ALIAS libprotobuf)
add_library(protobuf::libprotobuf-lite ALIAS libprotobuf-lite)
add_executable(protobuf::protoc ALIAS protoc)
# There is link error when cross compiling protoc on mobile:
# https://github.com/protocolbuffers/protobuf/issues/2719
# And protoc is very unlikely needed for mobile builds.
if (NOT (ANDROID OR IOS))
add_executable(protobuf::protoc ALIAS protoc)
endif()
endif()
endmacro()
@ -78,17 +83,13 @@ if (ANDROID OR IOS)
"change in the future, and you will need to specify "
"-DBUILD_CUSTOM_PROTOBUF=ON explicitly.")
endif()
# There is link error when cross compiling protoc on mobile:
# https://github.com/protocolbuffers/protobuf/issues/2719
# And protoc is very unlikely needed for mobile builds.
set(__caffe2_protobuf_BUILD_PROTOC_BINARIES ${protobuf_BUILD_PROTOC_BINARIES})
set(protobuf_BUILD_PROTOC_BINARIES OFF CACHE BOOL "" FORCE)
custom_protobuf_find()
# Unfortunately, new protobuf does not support libprotoc and protoc
# cross-compilation so we will need to exclude it.
# The problem of using EXCLUDE_FROM_ALL is that one is not going to be able
# to run cmake install. A proper solution has to be implemented by protobuf
# since we derive our cmake files from there.
# TODO(jiayq): change this once https://github.com/google/protobuf/pull/3878
# merges.
set_target_properties(
libprotoc protoc PROPERTIES
EXCLUDE_FROM_ALL 1 EXCLUDE_FROM_DEFAULT_BUILD 1)
set(protobuf_BUILD_PROTOC_BINARIES ${__caffe2_protobuf_BUILD_PROTOC_BINARIES} CACHE BOOL "" FORCE)
elseif (BUILD_CUSTOM_PROTOBUF)
message(STATUS "Building using own protobuf under third_party per request.")
custom_protobuf_find()

View File

@ -18,6 +18,16 @@ string(
content
"${content}")
# https://github.com/protocolbuffers/protobuf/commit/0400cca3236de1ca303af38bf81eab332d042b7c
# changes PROTOBUF_CONSTEXPR to constexpr, which breaks windows
# build.
string(
REPLACE
"static constexpr int kIndexInFileMessages ="
"static int const kIndexInFileMessages ="
content
"${content}")
foreach(ns ${NAMESPACES})
# Insert "const ::std::string& GetEmptyStringAlreadyInited();" within
# the namespace and make sure we only do it once in the file. Unfortunately