This repository has been archived by the owner on Jun 24, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 25
/
protobuf.patch
184 lines (171 loc) · 7.28 KB
/
protobuf.patch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
diff --git a/cmake/CMakeLists.txt b/cmake/CMakeLists.txt
index 71a0f37a..d8e16f6b 100644
--- a/cmake/CMakeLists.txt
+++ b/cmake/CMakeLists.txt
@@ -33,6 +33,7 @@ option(protobuf_BUILD_TESTS "Build tests" ON)
option(protobuf_BUILD_CONFORMANCE "Build conformance tests" OFF)
option(protobuf_BUILD_EXAMPLES "Build examples" OFF)
option(protobuf_BUILD_PROTOC_BINARIES "Build libprotoc and protoc compiler" ON)
+option(protobuf_BUILD_PROTOBUF_LITE "Build libprotobuf-lite" ON)
if (BUILD_SHARED_LIBS)
set(protobuf_BUILD_SHARED_LIBS_DEFAULT ON)
else (BUILD_SHARED_LIBS)
@@ -180,7 +181,8 @@ if (MSVC)
configure_file(extract_includes.bat.in extract_includes.bat)
# Suppress linker warnings about files with no symbols defined.
- set(CMAKE_STATIC_LINKER_FLAGS /ignore:4221)
+ # Bincrafters: https://github.com/protocolbuffers/protobuf/issues/6098
+ set(CMAKE_STATIC_LINKER_FLAGS "${CMAKE_STATIC_LINKER_FLAGS} /ignore:4221")
# Configure Resource Compiler
enable_language(RC)
@@ -213,11 +215,16 @@ if (protobuf_UNICODE)
add_definitions(-DUNICODE -D_UNICODE)
endif (protobuf_UNICODE)
-include(libprotobuf-lite.cmake)
-include(libprotobuf.cmake)
+if (protobuf_BUILD_PROTOBUF_LITE)
+ include(libprotobuf-lite.cmake)
+endif (protobuf_BUILD_PROTOBUF_LITE)
+
+if (protobuf_BUILD_PROTOC_BINARIES OR NOT protobuf_BUILD_PROTOBUF_LITE)
+ include(libprotobuf.cmake)
+endif (protobuf_BUILD_PROTOC_BINARIES OR NOT protobuf_BUILD_PROTOBUF_LITE)
+
if (protobuf_BUILD_PROTOC_BINARIES)
include(libprotoc.cmake)
- include(protoc.cmake)
endif (protobuf_BUILD_PROTOC_BINARIES)
if (protobuf_BUILD_TESTS)
diff --git a/cmake/install.cmake b/cmake/install.cmake
index be47c54a..bb1e9e25 100644
--- a/cmake/install.cmake
+++ b/cmake/install.cmake
@@ -5,7 +5,16 @@ configure_file(${CMAKE_CURRENT_SOURCE_DIR}/protobuf.pc.cmake
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/protobuf-lite.pc.cmake
${CMAKE_CURRENT_BINARY_DIR}/protobuf-lite.pc @ONLY)
-set(_protobuf_libraries libprotobuf-lite libprotobuf)
+set(_protobuf_libraries)
+
+if (protobuf_BUILD_PROTOBUF_LITE)
+ list(APPEND _protobuf_libraries libprotobuf-lite)
+endif (protobuf_BUILD_PROTOBUF_LITE)
+
+if (NOT protobuf_BUILD_PROTOBUF_LITE)
+ list(APPEND _protobuf_libraries libprotobuf)
+endif ()
+
if (protobuf_BUILD_PROTOC_BINARIES)
list(APPEND _protobuf_libraries libprotoc)
endif (protobuf_BUILD_PROTOC_BINARIES)
@@ -28,18 +37,6 @@ foreach(_library ${_protobuf_libraries})
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT ${_library})
endforeach()
-if (protobuf_BUILD_PROTOC_BINARIES)
- install(TARGETS protoc EXPORT protobuf-targets
- RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} COMPONENT protoc)
- if (UNIX AND NOT APPLE)
- set_property(TARGET protoc
- PROPERTY INSTALL_RPATH "$ORIGIN/../${CMAKE_INSTALL_LIBDIR}")
- elseif (APPLE)
- set_property(TARGET protoc
- PROPERTY INSTALL_RPATH "@loader_path/../lib")
- endif()
-endif (protobuf_BUILD_PROTOC_BINARIES)
-
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/protobuf.pc ${CMAKE_CURRENT_BINARY_DIR}/protobuf-lite.pc DESTINATION "${CMAKE_INSTALL_LIBDIR}/pkgconfig")
file(STRINGS extract_includes.bat.in _extract_strings
@@ -119,18 +116,10 @@ configure_file(protobuf-options.cmake
${CMAKE_INSTALL_CMAKEDIR}/protobuf-options.cmake @ONLY)
# Allows the build directory to be used as a find directory.
-
-if (protobuf_BUILD_PROTOC_BINARIES)
- export(TARGETS libprotobuf-lite libprotobuf libprotoc protoc
- NAMESPACE protobuf::
- FILE ${CMAKE_INSTALL_CMAKEDIR}/protobuf-targets.cmake
- )
-else (protobuf_BUILD_PROTOC_BINARIES)
- export(TARGETS libprotobuf-lite libprotobuf
- NAMESPACE protobuf::
- FILE ${CMAKE_INSTALL_CMAKEDIR}/protobuf-targets.cmake
- )
-endif (protobuf_BUILD_PROTOC_BINARIES)
+export(TARGETS ${_protobuf_libraries}
+ NAMESPACE protobuf::
+ FILE ${CMAKE_INSTALL_CMAKEDIR}/protobuf-targets.cmake
+)
install(EXPORT protobuf-targets
DESTINATION "${CMAKE_INSTALL_CMAKEDIR}"
diff --git a/cmake/libprotobuf.cmake b/cmake/libprotobuf.cmake
index fd70da7e..0f864e9b 100644
--- a/cmake/libprotobuf.cmake
+++ b/cmake/libprotobuf.cmake
@@ -114,9 +114,46 @@ set(libprotobuf_rc_files
)
endif()
+set(libprotobuf_lite_files
+ ${protobuf_source_dir}/src/google/protobuf/any_lite.cc
+ ${protobuf_source_dir}/src/google/protobuf/arena.cc
+ ${protobuf_source_dir}/src/google/protobuf/extension_set.cc
+ ${protobuf_source_dir}/src/google/protobuf/generated_enum_util.cc
+ ${protobuf_source_dir}/src/google/protobuf/generated_message_table_driven_lite.cc
+ ${protobuf_source_dir}/src/google/protobuf/generated_message_util.cc
+ ${protobuf_source_dir}/src/google/protobuf/implicit_weak_message.cc
+ ${protobuf_source_dir}/src/google/protobuf/io/coded_stream.cc
+ ${protobuf_source_dir}/src/google/protobuf/io/io_win32.cc
+ ${protobuf_source_dir}/src/google/protobuf/io/strtod.cc
+ ${protobuf_source_dir}/src/google/protobuf/io/zero_copy_stream.cc
+ ${protobuf_source_dir}/src/google/protobuf/io/zero_copy_stream_impl.cc
+ ${protobuf_source_dir}/src/google/protobuf/io/zero_copy_stream_impl_lite.cc
+ ${protobuf_source_dir}/src/google/protobuf/message_lite.cc
+ ${protobuf_source_dir}/src/google/protobuf/parse_context.cc
+ ${protobuf_source_dir}/src/google/protobuf/repeated_field.cc
+ ${protobuf_source_dir}/src/google/protobuf/stubs/bytestream.cc
+ ${protobuf_source_dir}/src/google/protobuf/stubs/common.cc
+ ${protobuf_source_dir}/src/google/protobuf/stubs/int128.cc
+ ${protobuf_source_dir}/src/google/protobuf/stubs/status.cc
+ ${protobuf_source_dir}/src/google/protobuf/stubs/statusor.cc
+ ${protobuf_source_dir}/src/google/protobuf/stubs/stringpiece.cc
+ ${protobuf_source_dir}/src/google/protobuf/stubs/stringprintf.cc
+ ${protobuf_source_dir}/src/google/protobuf/stubs/structurally_valid.cc
+ ${protobuf_source_dir}/src/google/protobuf/stubs/strutil.cc
+ ${protobuf_source_dir}/src/google/protobuf/stubs/time.cc
+ ${protobuf_source_dir}/src/google/protobuf/wire_format_lite.cc
+)
+
add_library(libprotobuf ${protobuf_SHARED_OR_STATIC}
${libprotobuf_lite_files} ${libprotobuf_files} ${libprotobuf_includes} ${libprotobuf_rc_files})
-target_link_libraries(libprotobuf ${CMAKE_THREAD_LIBS_INIT})
+
+string(FIND "${CMAKE_LIBRARY_ARCHITECTURE}" "arm" ARM_CROSSCOMPILING)
+if (${ARM_CROSSCOMPILING} GREATER -1)
+ target_link_libraries(libprotobuf ${CMAKE_THREAD_LIBS_INIT} atomic)
+else()
+ target_link_libraries(libprotobuf ${CMAKE_THREAD_LIBS_INIT})
+endif()
+
if(protobuf_WITH_ZLIB)
target_link_libraries(libprotobuf ${ZLIB_LIBRARIES})
endif()
diff --git a/cmake/protoc.cmake b/cmake/protoc.cmake
index f90e525e..fd0c1f68 100644
--- a/cmake/protoc.cmake
+++ b/cmake/protoc.cmake
@@ -2,6 +2,7 @@ set(protoc_files
${protobuf_source_dir}/src/google/protobuf/compiler/main.cc
)
+
if (MSVC)
set(protoc_rc_files
${CMAKE_CURRENT_BINARY_DIR}/version.rc
@@ -9,7 +10,12 @@ set(protoc_rc_files
endif()
add_executable(protoc ${protoc_files} ${protoc_rc_files})
-target_link_libraries(protoc libprotoc libprotobuf)
+# Clang x86 requires atomic lib
+if (${CMAKE_SIZEOF_VOID_P} EQUAL 4 AND "${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang" AND NOT ${CMAKE_LIBRARY_ARCHITECTURE})
+ target_link_libraries(protoc libprotobuf libprotoc atomic)
+else ()
+ target_link_libraries(protoc libprotobuf libprotoc)
+endif ()
add_executable(protobuf::protoc ALIAS protoc)
set_target_properties(protoc PROPERTIES