Skip to content

Commit d7d95e7

Browse files
committed
Update protobuf3 and use CMake
1 parent 729b995 commit d7d95e7

2 files changed

Lines changed: 64 additions & 36 deletions

File tree

CMake/External_Protobuf.cmake

Lines changed: 59 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,71 @@
1-
if (WIN32)
2-
# Build option for windows not yet generated
3-
message( FATAL_ERROR "Protobuf on windows not yet supported" )
4-
endif()
51

6-
# Check that python and protobuf versions are compatible
7-
if(fletch_BUILD_WITH_PYTHON AND fletch_ENABLE_Protobuf)
8-
# Note the python protobuf wrapper is not installed here.
9-
# Instead it must be installed via `pip install protobuf`
10-
if (${Protobuf_version} LESS 3.0 AND fletch_PYTHON_MAJOR_VERSION MATCHES "^3.*")
11-
message(ERROR " Must use Protobuf >= 3.x with Python 3.x")
2+
if (Protobuf_SELECT_VERSION STREQUAL "3.9.0")
3+
# Check that python and protobuf versions are compatible
4+
if(fletch_BUILD_WITH_PYTHON)
5+
# Note the python protobuf wrapper is not installed here.
6+
# Instead it must be installed via `pip install protobuf`
7+
if (fletch_PYTHON_MAJOR_VERSION MATCHES "^2.*")
8+
message(ERROR " Must use Python >= 3.x with Protobuf 3.x")
9+
endif()
1210
endif()
13-
endif()
1411

1512

13+
ExternalProject_Add(Protobuf
14+
# PREFIX protobuf
15+
URL ${Protobuf_url}
16+
URL_MD5 ${Protobuf_md5}
17+
SOURCE_SUBDIR ./cmake
18+
${COMMON_EP_ARGS}
19+
${COMMON_CMAKE_EP_ARGS}
20+
# UPDATE_COMMAND
21+
# COMMAND ${CMAKE_COMMAND} -DPULSE_IL2CPP_PATCH=${PULSE_IL2CPP_PATCH} -Dprotobuf_source=${protobuf_SRC} -Dprotobuf_patch=${protobuf_Patch} -P ${protobuf_Patch}/Patch.cmake
22+
CMAKE_ARGS
23+
${COMMON_CMAKE_ARGS}
24+
-DBUILD_SHARED_LIBS:BOOL=${BUILD_SHARED_LIBS}
25+
-Dprotobuf_BUILD_TESTS:BOOL=OFF
26+
-Dprotobuf_BUILD_EXAMPLES:BOOL=OFF
27+
-Dprotobuf_BUILD_SHARED_LIBS:BOOL=OFF
28+
-Dprotobuf_MSVC_STATIC_RUNTIME:BOOL=OFF#Don't change MSVC runtime settings (/MD or /MT)
29+
-Dprotobuf_WITH_ZLIB:BOOL=OFF
30+
)
31+
elseif (NOT WIN32)
1632

17-
set (Protobuf_PATCH_DIR ${fletch_SOURCE_DIR}/Patches/Protobuf/${Protobuf_SELECT_VERSION})
18-
if (EXISTS ${Protobuf_PATCH_DIR})
19-
set(Protobuf_PATCH_COMMAND ${CMAKE_COMMAND}
20-
-DProtobuf_PATCH_DIR=${Protobuf_PATCH_DIR}
21-
-DProtobuf_SOURCE_DIR=${fletch_BUILD_PREFIX}/src/Protobuf
22-
-P ${Protobuf_PATCH_DIR}/Patch.cmake)
23-
else()
24-
set(Protobuf_PATCH_COMMAND "")
25-
endif()
33+
# Check that python and protobuf versions are compatible
34+
if(fletch_BUILD_WITH_PYTHON AND fletch_ENABLE_Protobuf)
35+
# Note the python protobuf wrapper is not installed here.
36+
# Instead it must be installed via `pip install protobuf`
37+
if (${Protobuf_version} LESS 3.0 AND fletch_PYTHON_MAJOR_VERSION MATCHES "^3.*")
38+
message(ERROR " You must use Protobuf >= 3.x with Python 3.x")
39+
endif()
40+
endif()
2641

42+
set (Protobuf_PATCH_DIR ${fletch_SOURCE_DIR}/Patches/Protobuf/${Protobuf_SELECT_VERSION})
43+
if (EXISTS ${Protobuf_PATCH_DIR})
44+
set(Protobuf_PATCH_COMMAND ${CMAKE_COMMAND}
45+
-DProtobuf_PATCH_DIR=${Protobuf_PATCH_DIR}
46+
-DProtobuf_SOURCE_DIR=${fletch_BUILD_PREFIX}/src/Protobuf
47+
-P ${Protobuf_PATCH_DIR}/Patch.cmake)
48+
else()
49+
set(Protobuf_PATCH_COMMAND "")
50+
endif()
2751

28-
Fletch_Require_Make()
29-
ExternalProject_Add(Protobuf
30-
URL ${Protobuf_url}
31-
URL_MD5 ${Protobuf_md5}
32-
${COMMON_EP_ARGS}
33-
PATCH_COMMAND ${CMAKE_COMMAND}
52+
Fletch_Require_Make()
53+
ExternalProject_Add(Protobuf
54+
URL ${Protobuf_url}
55+
URL_MD5 ${Protobuf_md5}
56+
${COMMON_EP_ARGS}
57+
PATCH_COMMAND ${CMAKE_COMMAND}
3458
${Protobuf_PATCH_COMMAND}
35-
BUILD_IN_SOURCE 1
36-
CONFIGURE_COMMAND ./configure
59+
BUILD_IN_SOURCE 1
60+
CONFIGURE_COMMAND ./configure
3761
--prefix=${fletch_BUILD_INSTALL_PREFIX}
38-
BUILD_COMMAND ${MAKE_EXECUTABLE}
39-
INSTALL_COMMAND ${MAKE_EXECUTABLE} install
40-
)
62+
BUILD_COMMAND ${MAKE_EXECUTABLE}
63+
INSTALL_COMMAND ${MAKE_EXECUTABLE} install
64+
)
65+
else()
66+
# Build option for windows not yet generated
67+
message( FATAL_ERROR "Protobuf 2 not yet supported on windows" )
68+
endif()
4169

4270
fletch_external_project_force_install(PACKAGE Protobuf)
4371

CMake/fletch-tarballs.cmake

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -492,18 +492,18 @@ endif()
492492
# Protobuf
493493
if(NOT WIN32)
494494
if (fletch_ENABLE_Protobuf OR fletch_ENABLE_ALL_PACKAGES OR AUTO_ENABLE_CAFFE_DEPENDENCY)
495-
set(Protobuf_SELECT_VERSION "2.5.0" CACHE STRING "Select the version of ProtoBuf to build.")
496-
set_property(CACHE Protobuf_SELECT_VERSION PROPERTY STRINGS "2.5.0" "3.4.1")
495+
set(Protobuf_SELECT_VERSION "3.9.0" CACHE STRING "Select the version of ProtoBuf to build.")
496+
set_property(CACHE Protobuf_SELECT_VERSION PROPERTY STRINGS "2.5.0" "3.9.0")
497497
endif()
498498

499499
set(Protobuf_version ${Protobuf_SELECT_VERSION})
500500

501501
if (Protobuf_version VERSION_EQUAL 2.5.0)
502502
set(Protobuf_url "https://github.com/google/protobuf/releases/download/v${Protobuf_version}/protobuf-${Protobuf_version}.tar.bz2" )
503503
set(Protobuf_md5 "a72001a9067a4c2c4e0e836d0f92ece4" )
504-
elseif (Protobuf_version VERSION_EQUAL 3.4.1)
505-
set(Protobuf_url "https://github.com/google/protobuf/releases/download/v${Protobuf_version}/protobuf-cpp-${Protobuf_version}.tar.gz" )
506-
set(Protobuf_md5 "74446d310ce79cf20bab3ffd0e8f8f8f" )
504+
elseif (Protobuf_version VERSION_EQUAL 3.9.0)
505+
set(Protobuf_url "https://github.com/protocolbuffers/protobuf/releases/download/v${Protobuf_version}/protobuf-all-${Protobuf_version}.zip")
506+
set(Protobuf_md5 "4f042c8b46823a69db3dcbc7381b73f4" )
507507
elseif(Protobuf_version)
508508
message(ERROR "Protobuf Version ${Protobuf_version} Not Supported")
509509
endif()

0 commit comments

Comments
 (0)