Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Tetragramm
GitHub Repository: Tetragramm/opencv
Path: blob/master/3rdparty/protobuf/CMakeLists.txt
16337 views
1
project(libprotobuf)
2
include(CheckIncludeFiles)
3
4
if(HAVE_PTHREAD)
5
add_definitions(-DHAVE_PTHREAD=1)
6
endif()
7
8
if(MSVC)
9
add_definitions( -D_CRT_SECURE_NO_WARNINGS=1 )
10
ocv_warnings_disable(CMAKE_CXX_FLAGS /wd4244 /wd4267 /wd4018 /wd4355 /wd4800 /wd4251 /wd4996 /wd4146
11
/wd4305 /wd4127 /wd4100 /wd4512 /wd4125 /wd4389 /wd4510 /wd4610
12
/wd4702 /wd4456 /wd4457 /wd4065 /wd4310 /wd4661 /wd4506
13
/wd4701 /wd4703 # potentially uninitialized local/pointer variable 'value' used
14
/wd4505 # unreferenced local function has been removed
15
)
16
else()
17
#NOTE: -Wno-invalid-offsetof was used as solution for invalid offset warning on protobuf #3450
18
ocv_warnings_disable(CMAKE_CXX_FLAGS -Wno-deprecated -Wmissing-prototypes -Wmissing-declarations -Wshadow
19
-Wunused-parameter -Wunused-local-typedefs -Wsign-compare -Wsign-promo
20
-Wundef -Wtautological-undefined-compare -Wignored-qualifiers -Wextra
21
-Wunused-function -Wunused-const-variable -Wshorten-64-to-32 -Wno-invalid-offsetof
22
-Wenum-compare-switch
23
-Wsuggest-override -Winconsistent-missing-override
24
-Wimplicit-fallthrough
25
)
26
endif()
27
if(CV_ICC)
28
ocv_warnings_disable(CMAKE_CXX_FLAGS
29
-wd265 -wd858 -wd873 -wd2196
30
)
31
endif()
32
if(CV_GCC AND CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 8.0)
33
ocv_warnings_disable(CMAKE_CXX_FLAGS -Wclass-memaccess)
34
endif()
35
36
# Easier to support different versions of protobufs
37
function(append_if_exist OUTPUT_LIST)
38
set(${OUTPUT_LIST})
39
foreach(fil ${ARGN})
40
if(EXISTS ${fil})
41
list(APPEND ${OUTPUT_LIST} "${fil}")
42
else()
43
message(WARNING "file missing: ${fil}")
44
endif()
45
endforeach()
46
set(${OUTPUT_LIST} ${${OUTPUT_LIST}} PARENT_SCOPE)
47
endfunction()
48
49
set(PROTOBUF_ROOT "${CMAKE_CURRENT_LIST_DIR}")
50
51
if(MSVC)
52
set(ATOMICOPS_INTERNALS ${PROTOBUF_ROOT}/src/google/protobuf/stubs/atomicops_internals_x86_msvc.cc)
53
else()
54
set(ATOMICOPS_INTERNALS ${PROTOBUF_ROOT}/src/google/protobuf/stubs/atomicops_internals_x86_gcc.cc)
55
endif()
56
57
58
append_if_exist(Protobuf_SRCS
59
# libprotobuf-lite
60
${PROTOBUF_ROOT}/src/google/protobuf/arena.cc
61
${PROTOBUF_ROOT}/src/google/protobuf/arenastring.cc
62
${PROTOBUF_ROOT}/src/google/protobuf/extension_set.cc
63
${PROTOBUF_ROOT}/src/google/protobuf/generated_message_table_driven_lite.cc
64
${PROTOBUF_ROOT}/src/google/protobuf/generated_message_util.cc
65
${PROTOBUF_ROOT}/src/google/protobuf/io/coded_stream.cc
66
${PROTOBUF_ROOT}/src/google/protobuf/io/zero_copy_stream.cc
67
${PROTOBUF_ROOT}/src/google/protobuf/io/zero_copy_stream_impl_lite.cc
68
${PROTOBUF_ROOT}/src/google/protobuf/message_lite.cc
69
${PROTOBUF_ROOT}/src/google/protobuf/repeated_field.cc
70
${ATOMICOPS_INTERNALS}
71
${PROTOBUF_ROOT}/src/google/protobuf/stubs/bytestream.cc
72
${PROTOBUF_ROOT}/src/google/protobuf/stubs/common.cc
73
${PROTOBUF_ROOT}/src/google/protobuf/stubs/int128.cc
74
${PROTOBUF_ROOT}/src/google/protobuf/stubs/io_win32.cc
75
${PROTOBUF_ROOT}/src/google/protobuf/stubs/once.cc
76
${PROTOBUF_ROOT}/src/google/protobuf/stubs/status.cc
77
${PROTOBUF_ROOT}/src/google/protobuf/stubs/statusor.cc
78
${PROTOBUF_ROOT}/src/google/protobuf/stubs/stringpiece.cc
79
${PROTOBUF_ROOT}/src/google/protobuf/stubs/stringprintf.cc
80
${PROTOBUF_ROOT}/src/google/protobuf/stubs/structurally_valid.cc
81
${PROTOBUF_ROOT}/src/google/protobuf/stubs/strutil.cc
82
${PROTOBUF_ROOT}/src/google/protobuf/stubs/time.cc
83
${PROTOBUF_ROOT}/src/google/protobuf/wire_format_lite.cc
84
# libprotobuf
85
${PROTOBUF_ROOT}/src/google/protobuf/any.cc
86
${PROTOBUF_ROOT}/src/google/protobuf/any.pb.cc
87
${PROTOBUF_ROOT}/src/google/protobuf/api.pb.cc
88
# ${PROTOBUF_ROOT}/src/google/protobuf/compiler/importer.cc
89
# ${PROTOBUF_ROOT}/src/google/protobuf/compiler/parser.cc
90
${PROTOBUF_ROOT}/src/google/protobuf/descriptor.cc
91
${PROTOBUF_ROOT}/src/google/protobuf/descriptor.pb.cc
92
${PROTOBUF_ROOT}/src/google/protobuf/descriptor_database.cc
93
${PROTOBUF_ROOT}/src/google/protobuf/duration.pb.cc
94
${PROTOBUF_ROOT}/src/google/protobuf/dynamic_message.cc
95
${PROTOBUF_ROOT}/src/google/protobuf/empty.pb.cc
96
${PROTOBUF_ROOT}/src/google/protobuf/extension_set_heavy.cc
97
${PROTOBUF_ROOT}/src/google/protobuf/field_mask.pb.cc
98
${PROTOBUF_ROOT}/src/google/protobuf/generated_message_reflection.cc
99
${PROTOBUF_ROOT}/src/google/protobuf/generated_message_table_driven.cc
100
${PROTOBUF_ROOT}/src/google/protobuf/io/gzip_stream.cc
101
${PROTOBUF_ROOT}/src/google/protobuf/io/printer.cc
102
${PROTOBUF_ROOT}/src/google/protobuf/io/strtod.cc
103
${PROTOBUF_ROOT}/src/google/protobuf/io/tokenizer.cc
104
${PROTOBUF_ROOT}/src/google/protobuf/io/zero_copy_stream_impl.cc
105
${PROTOBUF_ROOT}/src/google/protobuf/map_field.cc
106
${PROTOBUF_ROOT}/src/google/protobuf/message.cc
107
${PROTOBUF_ROOT}/src/google/protobuf/reflection_ops.cc
108
${PROTOBUF_ROOT}/src/google/protobuf/service.cc
109
${PROTOBUF_ROOT}/src/google/protobuf/source_context.pb.cc
110
${PROTOBUF_ROOT}/src/google/protobuf/struct.pb.cc
111
${PROTOBUF_ROOT}/src/google/protobuf/stubs/mathlimits.cc
112
${PROTOBUF_ROOT}/src/google/protobuf/stubs/substitute.cc
113
${PROTOBUF_ROOT}/src/google/protobuf/text_format.cc
114
${PROTOBUF_ROOT}/src/google/protobuf/timestamp.pb.cc
115
${PROTOBUF_ROOT}/src/google/protobuf/type.pb.cc
116
${PROTOBUF_ROOT}/src/google/protobuf/unknown_field_set.cc
117
${PROTOBUF_ROOT}/src/google/protobuf/util/delimited_message_util.cc
118
${PROTOBUF_ROOT}/src/google/protobuf/util/field_comparator.cc
119
${PROTOBUF_ROOT}/src/google/protobuf/util/field_mask_util.cc
120
${PROTOBUF_ROOT}/src/google/protobuf/util/internal/datapiece.cc
121
${PROTOBUF_ROOT}/src/google/protobuf/util/internal/default_value_objectwriter.cc
122
# ${PROTOBUF_ROOT}/src/google/protobuf/util/internal/error_listener.cc
123
${PROTOBUF_ROOT}/src/google/protobuf/util/internal/field_mask_utility.cc
124
${PROTOBUF_ROOT}/src/google/protobuf/util/internal/json_escaping.cc
125
${PROTOBUF_ROOT}/src/google/protobuf/util/internal/json_objectwriter.cc
126
${PROTOBUF_ROOT}/src/google/protobuf/util/internal/json_stream_parser.cc
127
${PROTOBUF_ROOT}/src/google/protobuf/util/internal/object_writer.cc
128
${PROTOBUF_ROOT}/src/google/protobuf/util/internal/proto_writer.cc
129
${PROTOBUF_ROOT}/src/google/protobuf/util/internal/protostream_objectsource.cc
130
${PROTOBUF_ROOT}/src/google/protobuf/util/internal/protostream_objectwriter.cc
131
${PROTOBUF_ROOT}/src/google/protobuf/util/internal/type_info.cc
132
# ${PROTOBUF_ROOT}/src/google/protobuf/util/internal/type_info_test_helper.cc
133
${PROTOBUF_ROOT}/src/google/protobuf/util/internal/utility.cc
134
${PROTOBUF_ROOT}/src/google/protobuf/util/json_util.cc
135
${PROTOBUF_ROOT}/src/google/protobuf/util/message_differencer.cc
136
${PROTOBUF_ROOT}/src/google/protobuf/util/time_util.cc
137
${PROTOBUF_ROOT}/src/google/protobuf/util/type_resolver_util.cc
138
${PROTOBUF_ROOT}/src/google/protobuf/wire_format.cc
139
${PROTOBUF_ROOT}/src/google/protobuf/wrappers.pb.cc
140
)
141
142
add_library(libprotobuf STATIC ${Protobuf_SRCS})
143
target_include_directories(libprotobuf SYSTEM PUBLIC $<BUILD_INTERFACE:${PROTOBUF_ROOT}/src>)
144
set_target_properties(libprotobuf
145
PROPERTIES
146
FOLDER "3rdparty"
147
OUTPUT_NAME libprotobuf
148
DEBUG_POSTFIX "${OPENCV_DEBUG_POSTFIX}"
149
COMPILE_PDB_NAME libprotobuf
150
COMPILE_PDB_NAME_DEBUG "libprotobuf${OPENCV_DEBUG_POSTFIX}"
151
ARCHIVE_OUTPUT_DIRECTORY ${3P_LIBRARY_OUTPUT_PATH}
152
)
153
154
get_protobuf_version(Protobuf_VERSION "${PROTOBUF_ROOT}/src")
155
set(Protobuf_VERSION ${Protobuf_VERSION} CACHE INTERNAL "" FORCE)
156
157
if(NOT BUILD_SHARED_LIBS)
158
ocv_install_target(libprotobuf EXPORT OpenCVModules ARCHIVE DESTINATION ${OPENCV_3P_LIB_INSTALL_PATH} COMPONENT dev)
159
endif()
160
161
ocv_install_3rdparty_licenses(protobuf LICENSE README.md)
162
163