Adjust ProtoBufPatch to protobuf-3.11.x (#35008)
Summary:
`GetEmptyStringAlreadyInited` invocation pattern in protobuf generated header files chanegd to
`:PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited`, where `PROTOBUF_NAMESPACE_ID` is defined in `protobuf/port_def.inc` as `google::protobuf`
This likely to have changed around protobuf-3.8.x time, but I've only tested it using protobuf-3.11.4
Pull Request resolved: https://github.com/pytorch/pytorch/pull/35008
Test Plan: Update `third-party/protobuf` submodule to 3.11.4, compile and run `pattern_net_transform_test`
Differential Revision: D20526949
Pulled By: malfet
fbshipit-source-id: fddaa3622c48ad883612c73c40a20d306d88d66b
diff --git a/cmake/ProtoBufPatch.cmake b/cmake/ProtoBufPatch.cmake
index dfe06e0..759b108 100644
--- a/cmake/ProtoBufPatch.cmake
+++ b/cmake/ProtoBufPatch.cmake
@@ -4,6 +4,7 @@
file(READ ${FILENAME} content)
+# protobuf-3.6.0 pattern
string(
REPLACE
"::google::protobuf::internal::GetEmptyStringAlreadyInited"
@@ -11,6 +12,14 @@
content
"${content}")
+# protobuf-3.8.0+ pattern
+string(
+ REPLACE
+ "::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited"
+ "GetEmptyStringAlreadyInited"
+ content
+ "${content}")
+
string(
REPLACE
"PROTOBUF_CONSTEXPR"