blob: 884ee3745bf3fde0abfdbb4ad79d2473eb18933b [file] [log] [blame]
Adam Cozzette52be7c22022-10-25 19:08:20 +00001# This file was generated from BUILD using tools/make_cmakelists.py.
2
3cmake_minimum_required(VERSION 3.1)
4
5if(${CMAKE_VERSION} VERSION_LESS 3.12)
6 cmake_policy(VERSION ${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION})
7else()
8 cmake_policy(VERSION 3.12)
9endif()
10
11cmake_minimum_required (VERSION 3.0)
12cmake_policy(SET CMP0048 NEW)
13
14project(upb)
15set(CMAKE_C_STANDARD 99)
16
17
18# Prevent CMake from setting -rdynamic on Linux (!!).
19SET(CMAKE_SHARED_LIBRARY_LINK_C_FLAGS "")
20SET(CMAKE_SHARED_LIBRARY_LINK_CXX_FLAGS "")
21
22# Set default build type.
23if(NOT CMAKE_BUILD_TYPE)
24 message(STATUS "Setting build type to 'RelWithDebInfo' as none was specified.")
25 set(CMAKE_BUILD_TYPE "RelWithDebInfo" CACHE STRING
26 "Choose the type of build, options are: Debug Release RelWithDebInfo MinSizeRel."
27 FORCE)
28endif()
29
30# When using Ninja, compiler output won't be colorized without this.
31include(CheckCXXCompilerFlag)
32CHECK_CXX_COMPILER_FLAG(-fdiagnostics-color=always SUPPORTS_COLOR_ALWAYS)
33if(SUPPORTS_COLOR_ALWAYS)
34 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fdiagnostics-color=always")
35endif()
36
37# Implement ASAN/UBSAN options
38if(UPB_ENABLE_ASAN)
39 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=address")
40 set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fsanitize=address")
41 set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fsanitize=address")
42 set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -fsanitize=address")
43endif()
44
45if(UPB_ENABLE_UBSAN)
46 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=undefined")
47 set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fsanitize=address")
48 set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fsanitize=address")
49 set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -fsanitize=address")
50endif()
51
52include_directories(..)
53include_directories(../cmake)
54include_directories(${CMAKE_CURRENT_BINARY_DIR})
55
Mike Kruskal40696492022-12-01 17:32:49 -080056if(EXISTS ../external/utf8_range)
57 # utf8_range is already installed
58 include_directories(../external/utf8_range)
59else()
60 include(FetchContent)
61 FetchContent_Declare(
62 utf8_range
63 GIT_REPOSITORY "https://github.com/protocolbuffers/utf8_range.git"
64 GIT_TAG "de0b4a8ff9b5d4c98108bdfe723291a33c52c54f"
65 )
66 FetchContent_GetProperties(utf8_range)
67 if(NOT utf8_range_POPULATED)
68 FetchContent_Populate(utf8_range)
69 include_directories(${utf8_range_SOURCE_DIR})
70 endif()
71 #FetchContent_MakeAvailable(utf8_range)
72 #include_directories(${utf8_range_SOURCE_DIR})
73 #
74 #include(ExternalProject)
75 #ExternalProject_Add(utf8_range
76 # PREFIX ${CMAKE_BINARY_DIR}/external
77 # GIT_REPOSITORY "https://github.com/protocolbuffers/utf8_range.git"
78 # GIT_TAG "de0b4a8ff9b5d4c98108bdfe723291a33c52c54f"
79 # SOURCE_DIR ${CMAKE_BINARY_DIR}/external/utf8_range
80 # UPDATE_COMMAND ""
81 # PATCH_COMMAND ""
82 # CONFIGURE_COMMAND ""
83 # BUILD_COMMAND ""
84 # BUILD_BYPRODUCTS ${CMAKE_BINARY_DIR}/external/utf8_range/utf8_range.h)
85 #include_directories(${CMAKE_BINARY_DIR}/external/utf8_range)
86endif()
87
Adam Cozzette52be7c22022-10-25 19:08:20 +000088if(APPLE)
89 set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -undefined dynamic_lookup -flat_namespace")
90elseif(UNIX)
91 set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,--build-id")
92endif()
93
94enable_testing()
95
96add_library(port INTERFACE)
Mike Kruskal40696492022-12-01 17:32:49 -080097add_library(upb INTERFACE)
98target_link_libraries(upb INTERFACE
99 base
100 collections_internal
Adam Cozzette52be7c22022-10-25 19:08:20 +0000101 fastdecode
Mike Kruskal40696492022-12-01 17:32:49 -0800102 hash
103 lex
104 mem
105 message_internal
Adam Cozzette52be7c22022-10-25 19:08:20 +0000106 mini_table_internal
107 port
Mike Kruskal40696492022-12-01 17:32:49 -0800108 wire)
109add_library(base
110 ../upb/base/status.c
111 ../upb/base/descriptor_constants.h
112 ../upb/base/log2.h
113 ../upb/base/status.h
114 ../upb/base/string_view.h)
115target_link_libraries(base
116 port)
117add_library(mini_table INTERFACE)
118target_link_libraries(mini_table INTERFACE
119 base
120 mem
121 mini_table_internal
122 port)
123add_library(mini_table_internal
124 ../upb/mini_table/common.c
125 ../upb/mini_table/decode.c
126 ../upb/mini_table/encode.c
127 ../upb/mini_table/extension_registry.c
128 ../upb/mini_table/common.h
129 ../upb/mini_table/common_internal.h
130 ../upb/mini_table/decode.h
131 ../upb/mini_table/encode_internal.h
132 ../upb/mini_table/encode_internal.hpp
133 ../upb/mini_table/enum_internal.h
134 ../upb/mini_table/extension_internal.h
135 ../upb/mini_table/extension_registry.h
136 ../upb/mini_table/field_internal.h
137 ../upb/mini_table/file_internal.h
138 ../upb/mini_table/message_internal.h
139 ../upb/mini_table/sub_internal.h
140 ../upb/mini_table/types.h)
141target_link_libraries(mini_table_internal
142 base
143 hash
144 mem
145 port)
146add_library(message INTERFACE)
147target_link_libraries(message INTERFACE
148 mem
149 message_internal
Adam Cozzette52be7c22022-10-25 19:08:20 +0000150 mini_table
Mike Kruskal40696492022-12-01 17:32:49 -0800151 port)
152add_library(message_internal
153 ../upb/message/message.c
154 ../upb/message/extension_internal.h
155 ../upb/message/internal.h
156 ../upb/message/message.h)
157target_link_libraries(message_internal
158 base
159 hash
160 mem
161 mini_table_internal
162 port)
163add_library(message_accessors
164 ../upb/message/accessors.c
165 ../upb/message/accessors.h)
166target_link_libraries(message_accessors
167 collections_internal
168 hash
169 message_internal
Adam Cozzette52be7c22022-10-25 19:08:20 +0000170 mini_table_internal
171 port
Mike Kruskal40696492022-12-01 17:32:49 -0800172 upb
173 wire)
174add_library(fastdecode INTERFACE)
175target_link_libraries(fastdecode INTERFACE
176 base
177 collections_internal
178 hash
179 mem_internal
180 message_internal
181 mini_table_internal
Adam Cozzette52be7c22022-10-25 19:08:20 +0000182 port
Mike Kruskal40696492022-12-01 17:32:49 -0800183 wire)
Adam Cozzette52be7c22022-10-25 19:08:20 +0000184add_library(generated_code_support__only_for_generated_code_do_not_use__i_give_permission_to_break_me INTERFACE)
185target_link_libraries(generated_code_support__only_for_generated_code_do_not_use__i_give_permission_to_break_me INTERFACE
Mike Kruskal40696492022-12-01 17:32:49 -0800186 base
187 collections_internal
188 hash
Adam Cozzette52be7c22022-10-25 19:08:20 +0000189 upb)
190add_library(generated_cpp_support__only_for_generated_code_do_not_use__i_give_permission_to_break_me INTERFACE)
191target_link_libraries(generated_cpp_support__only_for_generated_code_do_not_use__i_give_permission_to_break_me INTERFACE
Mike Kruskal40696492022-12-01 17:32:49 -0800192 base
193 collections_internal
194 hash
Adam Cozzette52be7c22022-10-25 19:08:20 +0000195 mini_table
Adam Cozzette52be7c22022-10-25 19:08:20 +0000196 upb)
197add_library(generated_reflection_support__only_for_generated_code_do_not_use__i_give_permission_to_break_me INTERFACE)
198target_link_libraries(generated_reflection_support__only_for_generated_code_do_not_use__i_give_permission_to_break_me INTERFACE
Mike Kruskal40696492022-12-01 17:32:49 -0800199 base
Adam Cozzette52be7c22022-10-25 19:08:20 +0000200 descriptor_upb_proto
Mike Kruskal40696492022-12-01 17:32:49 -0800201 hash
202 reflection_internal)
203add_library(collections INTERFACE)
204target_link_libraries(collections INTERFACE
205 base
206 collections_internal
207 mem
208 port)
209add_library(collections_internal
210 ../upb/collections/array.c
211 ../upb/collections/map.c
212 ../upb/collections/map_sorter.c
213 ../upb/collections/array.h
214 ../upb/collections/array_internal.h
215 ../upb/collections/map.h
216 ../upb/collections/map_gencode_util.h
217 ../upb/collections/map_internal.h
218 ../upb/collections/map_sorter_internal.h
219 ../upb/collections/message_value.h)
220target_link_libraries(collections_internal
221 base
222 hash
223 mem
224 mini_table_internal
225 port)
226add_library(reflection INTERFACE)
227target_link_libraries(reflection INTERFACE
228 collections
Adam Cozzette52be7c22022-10-25 19:08:20 +0000229 port
Mike Kruskal40696492022-12-01 17:32:49 -0800230 reflection_internal
Adam Cozzette52be7c22022-10-25 19:08:20 +0000231 upb)
Mike Kruskal40696492022-12-01 17:32:49 -0800232add_library(reflection_internal
Adam Cozzette52be7c22022-10-25 19:08:20 +0000233 ../upb/reflection/def_builder.c
Adam Cozzette52be7c22022-10-25 19:08:20 +0000234 ../upb/reflection/def_pool.c
Adam Cozzette52be7c22022-10-25 19:08:20 +0000235 ../upb/reflection/def_type.c
Adam Cozzette52be7c22022-10-25 19:08:20 +0000236 ../upb/reflection/desc_state.c
Adam Cozzette52be7c22022-10-25 19:08:20 +0000237 ../upb/reflection/enum_def.c
Mike Kruskal40696492022-12-01 17:32:49 -0800238 ../upb/reflection/enum_reserved_range.c
Adam Cozzette52be7c22022-10-25 19:08:20 +0000239 ../upb/reflection/enum_value_def.c
Adam Cozzette52be7c22022-10-25 19:08:20 +0000240 ../upb/reflection/extension_range.c
Adam Cozzette52be7c22022-10-25 19:08:20 +0000241 ../upb/reflection/field_def.c
Adam Cozzette52be7c22022-10-25 19:08:20 +0000242 ../upb/reflection/file_def.c
Adam Cozzette52be7c22022-10-25 19:08:20 +0000243 ../upb/reflection/message.c
244 ../upb/reflection/message_def.c
Mike Kruskal40696492022-12-01 17:32:49 -0800245 ../upb/reflection/message_reserved_range.c
Adam Cozzette52be7c22022-10-25 19:08:20 +0000246 ../upb/reflection/method_def.c
Adam Cozzette52be7c22022-10-25 19:08:20 +0000247 ../upb/reflection/oneof_def.c
Adam Cozzette52be7c22022-10-25 19:08:20 +0000248 ../upb/reflection/service_def.c
Mike Kruskal40696492022-12-01 17:32:49 -0800249 ../upb/reflection/common.h
Adam Cozzette52be7c22022-10-25 19:08:20 +0000250 ../upb/reflection/def.h
251 ../upb/reflection/def.hpp
Mike Kruskal40696492022-12-01 17:32:49 -0800252 ../upb/reflection/def_builder_internal.h
253 ../upb/reflection/def_pool.h
254 ../upb/reflection/def_pool_internal.h
255 ../upb/reflection/def_type.h
256 ../upb/reflection/desc_state_internal.h
257 ../upb/reflection/enum_def.h
258 ../upb/reflection/enum_def_internal.h
259 ../upb/reflection/enum_reserved_range.h
260 ../upb/reflection/enum_reserved_range_internal.h
261 ../upb/reflection/enum_value_def.h
262 ../upb/reflection/enum_value_def_internal.h
263 ../upb/reflection/extension_range.h
264 ../upb/reflection/extension_range_internal.h
265 ../upb/reflection/field_def.h
266 ../upb/reflection/field_def_internal.h
267 ../upb/reflection/file_def.h
268 ../upb/reflection/file_def_internal.h
Adam Cozzette52be7c22022-10-25 19:08:20 +0000269 ../upb/reflection/message.h
Mike Kruskal40696492022-12-01 17:32:49 -0800270 ../upb/reflection/message.hpp
271 ../upb/reflection/message_def.h
272 ../upb/reflection/message_def_internal.h
273 ../upb/reflection/message_reserved_range.h
274 ../upb/reflection/message_reserved_range_internal.h
275 ../upb/reflection/method_def.h
276 ../upb/reflection/method_def_internal.h
277 ../upb/reflection/oneof_def.h
278 ../upb/reflection/oneof_def_internal.h
279 ../upb/reflection/service_def.h
280 ../upb/reflection/service_def_internal.h)
281target_link_libraries(reflection_internal
Adam Cozzette52be7c22022-10-25 19:08:20 +0000282 collections
283 descriptor_upb_proto
Mike Kruskal40696492022-12-01 17:32:49 -0800284 hash
285 message_accessors
Adam Cozzette52be7c22022-10-25 19:08:20 +0000286 mini_table_internal
287 port
Adam Cozzette52be7c22022-10-25 19:08:20 +0000288 upb)
289add_library(textformat
Mike Kruskal40696492022-12-01 17:32:49 -0800290 ../upb/text/encode.c
291 ../upb/text/encode.h
Adam Cozzette52be7c22022-10-25 19:08:20 +0000292 ../upb/text_encode.h)
293target_link_libraries(textformat
Mike Kruskal40696492022-12-01 17:32:49 -0800294 collections_internal
295 lex
Adam Cozzette52be7c22022-10-25 19:08:20 +0000296 port
Mike Kruskal40696492022-12-01 17:32:49 -0800297 reflection
298 wire)
Adam Cozzette52be7c22022-10-25 19:08:20 +0000299add_library(json
300 ../upb/json/decode.c
301 ../upb/json/encode.c
302 ../upb/json/decode.h
303 ../upb/json/encode.h
304 ../upb/json_decode.h
305 ../upb/json_encode.h)
306target_link_libraries(json
Adam Cozzette52be7c22022-10-25 19:08:20 +0000307 collections
Mike Kruskal40696492022-12-01 17:32:49 -0800308 lex
Adam Cozzette52be7c22022-10-25 19:08:20 +0000309 port
310 reflection
Adam Cozzette52be7c22022-10-25 19:08:20 +0000311 upb)
Mike Kruskal40696492022-12-01 17:32:49 -0800312add_library(mem INTERFACE)
313target_link_libraries(mem INTERFACE
314 mem_internal
Adam Cozzette52be7c22022-10-25 19:08:20 +0000315 port)
Mike Kruskal40696492022-12-01 17:32:49 -0800316add_library(mem_internal
317 ../upb/mem/alloc.c
318 ../upb/mem/arena.c
319 ../upb/mem/alloc.h
320 ../upb/mem/arena.h
321 ../upb/mem/arena_internal.h)
322target_link_libraries(mem_internal
Adam Cozzette52be7c22022-10-25 19:08:20 +0000323 port)
Mike Kruskal40696492022-12-01 17:32:49 -0800324add_library(wire INTERFACE)
325target_link_libraries(wire INTERFACE
326 mem
327 message_internal
328 mini_table_internal
Adam Cozzette52be7c22022-10-25 19:08:20 +0000329 port
Mike Kruskal40696492022-12-01 17:32:49 -0800330 wire_internal)
331add_library(wire_internal
332 ../upb/wire/decode.c
333 ../upb/wire/decode_fast.c
334 ../upb/wire/encode.c
335 ../upb/wire/common_internal.h
336 ../upb/wire/decode.h
337 ../upb/wire/decode_fast.h
338 ../upb/wire/decode_internal.h
339 ../upb/wire/encode.h
340 ../upb/wire/swap_internal.h
341 ../upb/wire/types.h)
342target_link_libraries(wire_internal
343 base
344 collections_internal
345 hash
346 mem_internal
347 message_internal
348 mini_table_internal
349 port
350 utf8_range//:utf8_range)
351add_library(hash
352 ../upb/hash/common.c
353 ../upb/hash/common.h
354 ../upb/hash/int_table.h
355 ../upb/hash/str_table.h)
356target_link_libraries(hash
357 base
358 mem
Adam Cozzette52be7c22022-10-25 19:08:20 +0000359 port)
Mike Kruskal40696492022-12-01 17:32:49 -0800360add_library(lex
361 ../upb/lex/atoi.c
362 ../upb/lex/round_trip.c
363 ../upb/lex/strtod.c
364 ../upb/lex/unicode.c
365 ../upb/lex/atoi.h
366 ../upb/lex/round_trip.h
367 ../upb/lex/strtod.h
368 ../upb/lex/unicode.h)
369target_link_libraries(lex
Adam Cozzette52be7c22022-10-25 19:08:20 +0000370 port)
371
372