Skip to content

Commit 5f0d081

Browse files
authored
Merge pull request #6115 from qingqing01/protobuf-v3.2
Use protobuf v3.2.0 for MOBILE_INFERENCE compiling.
2 parents 8ac0227 + a0648ee commit 5f0d081

File tree

1 file changed

+19
-3
lines changed

1 file changed

+19
-3
lines changed

cmake/external/protobuf.cmake

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -188,14 +188,26 @@ FUNCTION(build_protobuf TARGET_NAME BUILD_FOR_HOST)
188188
SET(OPTIONAL_CACHE_ARGS "-DZLIB_ROOT:STRING=${ZLIB_ROOT}")
189189
ENDIF()
190190

191+
SET(PROTOBUF_REPO "https://github.com/google/protobuf.git")
192+
SET(PROTOBUF_TAG "9f75c5aa851cd877fb0d93ccc31b8567a6706546")
193+
IF(MOBILE_INFERENCE)
194+
# The reason why the official version is not used is described in
195+
# https://github.com/PaddlePaddle/Paddle/issues/6114
196+
SET(PROTOBUF_REPO "https://github.com/qingqing01/protobuf.git")
197+
SET(PROTOBUF_TAG "v3.2.0")
198+
IF(NOT BUILD_FOR_HOST)
199+
SET(OPTIONAL_ARGS ${OPTIONAL_ARGS} "-Dprotobuf_BUILD_PROTOC_BINARIES=OFF")
200+
ENDIF()
201+
ENDIF()
202+
191203
ExternalProject_Add(
192204
${TARGET_NAME}
193205
${EXTERNAL_PROJECT_LOG_ARGS}
194206
PREFIX ${PROTOBUF_SOURCES_DIR}
195207
UPDATE_COMMAND ""
196208
DEPENDS zlib
197-
GIT_REPOSITORY "https://github.com/google/protobuf.git"
198-
GIT_TAG "9f75c5aa851cd877fb0d93ccc31b8567a6706546"
209+
GIT_REPOSITORY ${PROTOBUF_REPO}
210+
GIT_TAG ${PROTOBUF_TAG}
199211
CONFIGURE_COMMAND
200212
${CMAKE_COMMAND} ${PROTOBUF_SOURCES_DIR}/src/${TARGET_NAME}/cmake
201213
${OPTIONAL_ARGS}
@@ -213,7 +225,11 @@ FUNCTION(build_protobuf TARGET_NAME BUILD_FOR_HOST)
213225
)
214226
ENDFUNCTION()
215227

216-
SET(PROTOBUF_VERSION 3.1)
228+
IF(NOT MOBILE_INFERENCE)
229+
SET(PROTOBUF_VERSION 3.1)
230+
ELSE()
231+
SET(PROTOBUF_VERSION 3.2)
232+
ENDIF()
217233
IF(CMAKE_CROSSCOMPILING)
218234
build_protobuf(protobuf_host TRUE)
219235
LIST(APPEND external_project_dependencies protobuf_host)

0 commit comments

Comments
 (0)