• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# 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)
15
16
17# Prevent CMake from setting -rdynamic on Linux (!!).
18SET(CMAKE_SHARED_LIBRARY_LINK_C_FLAGS "")
19SET(CMAKE_SHARED_LIBRARY_LINK_CXX_FLAGS "")
20
21# Set default build type.
22if(NOT CMAKE_BUILD_TYPE)
23  message(STATUS "Setting build type to 'RelWithDebInfo' as none was specified.")
24  set(CMAKE_BUILD_TYPE "RelWithDebInfo" CACHE STRING
25      "Choose the type of build, options are: Debug Release RelWithDebInfo MinSizeRel."
26      FORCE)
27endif()
28
29# When using Ninja, compiler output won't be colorized without this.
30include(CheckCXXCompilerFlag)
31CHECK_CXX_COMPILER_FLAG(-fdiagnostics-color=always SUPPORTS_COLOR_ALWAYS)
32if(SUPPORTS_COLOR_ALWAYS)
33  set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fdiagnostics-color=always")
34endif()
35
36# Implement ASAN/UBSAN options
37if(UPB_ENABLE_ASAN)
38  set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=address")
39  set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fsanitize=address")
40  set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fsanitize=address")
41  set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -fsanitize=address")
42endif()
43
44if(UPB_ENABLE_UBSAN)
45  set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=undefined")
46  set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fsanitize=address")
47  set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fsanitize=address")
48  set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -fsanitize=address")
49endif()
50
51include_directories(.)
52include_directories(generated_for_cmake)
53include_directories(${CMAKE_CURRENT_BINARY_DIR})
54
55if(APPLE)
56  set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -undefined dynamic_lookup -flat_namespace")
57elseif(UNIX)
58  set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,--build-id")
59endif()
60
61enable_testing()
62
63add_library(port
64  upb/port.c)
65add_library(upb
66  upb/decode.c
67  upb/encode.c
68  upb/msg.c
69  upb/msg.h
70  upb/table.c
71  upb/table.int.h
72  upb/upb.c
73  upb/decode.h
74  upb/encode.h
75  upb/upb.h
76  upb/upb.hpp)
77target_link_libraries(upb
78  port)
79add_library(generated_code_support__only_for_generated_code_do_not_use__i_give_permission_to_break_me INTERFACE)
80target_link_libraries(generated_code_support__only_for_generated_code_do_not_use__i_give_permission_to_break_me INTERFACE
81  table
82  upb)
83add_library(reflection
84  upb/def.c
85  upb/msg.h
86  upb/reflection.c
87  upb/def.h
88  upb/def.hpp
89  upb/reflection.h)
90target_link_libraries(reflection
91  descriptor_upb_proto
92  port
93  table
94  upb)
95add_library(textformat
96  upb/text_encode.c
97  upb/text_encode.h)
98target_link_libraries(textformat
99  port
100  reflection)
101add_library(json
102  upb/json_decode.c
103  upb/json_encode.c
104  upb/json_decode.h
105  upb/json_encode.h)
106target_link_libraries(json
107  port
108  reflection
109  upb)
110add_library(table INTERFACE)
111target_link_libraries(table INTERFACE
112  port
113  upb)
114add_library(handlers
115  upb/handlers.c
116  upb/handlers-inl.h
117  upb/sink.c
118  upb/handlers.h
119  upb/sink.h)
120target_link_libraries(handlers
121  port
122  reflection
123  table
124  upb)
125add_library(upb_pb
126  upb/pb/compile_decoder.c
127  upb/pb/decoder.c
128  upb/pb/decoder.int.h
129  upb/pb/encoder.c
130  upb/pb/textprinter.c
131  upb/pb/varint.c
132  upb/pb/varint.int.h
133  upb/pb/decoder.h
134  upb/pb/encoder.h
135  upb/pb/textprinter.h)
136target_link_libraries(upb_pb
137  descriptor_upb_proto
138  handlers
139  port
140  reflection
141  table
142  upb)
143add_library(upb_json
144  generated_for_cmake/upb/json/parser.c
145  upb/json/printer.c
146  upb/json/parser.h
147  upb/json/printer.h)
148target_link_libraries(upb_json
149  upb
150  upb_pb)
151add_library(upb_cc_bindings INTERFACE)
152target_link_libraries(upb_cc_bindings INTERFACE
153  descriptor_upb_proto
154  handlers
155  port
156  upb)
157add_library(upb_test
158  tests/testmain.cc
159  tests/test_util.h
160  tests/upb_test.h)
161target_link_libraries(upb_test
162  handlers
163  port
164  upb)
165
166
167