xref: /aosp_15_r20/external/protobuf/cmake/tests.cmake (revision 1b3f573f81763fcece89efc2b6a5209149e44ab8)
1*1b3f573fSAndroid Build Coastguard Workeroption(protobuf_USE_EXTERNAL_GTEST "Use external Google Test (i.e. not the one in third_party/googletest)" OFF)
2*1b3f573fSAndroid Build Coastguard Worker
3*1b3f573fSAndroid Build Coastguard Workeroption(protobuf_TEST_XML_OUTDIR "Output directory for XML logs from tests." "")
4*1b3f573fSAndroid Build Coastguard Worker
5*1b3f573fSAndroid Build Coastguard Workeroption(protobuf_ABSOLUTE_TEST_PLUGIN_PATH
6*1b3f573fSAndroid Build Coastguard Worker  "Using absolute test_plugin path in tests" ON)
7*1b3f573fSAndroid Build Coastguard Workermark_as_advanced(protobuf_ABSOLUTE_TEST_PLUGIN_PATH)
8*1b3f573fSAndroid Build Coastguard Worker
9*1b3f573fSAndroid Build Coastguard Workerif (protobuf_USE_EXTERNAL_GTEST)
10*1b3f573fSAndroid Build Coastguard Worker  find_package(GTest REQUIRED)
11*1b3f573fSAndroid Build Coastguard Workerelse()
12*1b3f573fSAndroid Build Coastguard Worker  if (NOT EXISTS "${protobuf_SOURCE_DIR}/third_party/googletest/CMakeLists.txt")
13*1b3f573fSAndroid Build Coastguard Worker    message(FATAL_ERROR
14*1b3f573fSAndroid Build Coastguard Worker            "Cannot find third_party/googletest directory that's needed to "
15*1b3f573fSAndroid Build Coastguard Worker            "build tests. If you use git, make sure you have cloned submodules:\n"
16*1b3f573fSAndroid Build Coastguard Worker            "  git submodule update --init --recursive\n"
17*1b3f573fSAndroid Build Coastguard Worker            "If instead you want to skip tests, run cmake with:\n"
18*1b3f573fSAndroid Build Coastguard Worker            "  cmake -Dprotobuf_BUILD_TESTS=OFF\n")
19*1b3f573fSAndroid Build Coastguard Worker  endif()
20*1b3f573fSAndroid Build Coastguard Worker
21*1b3f573fSAndroid Build Coastguard Worker  set(googlemock_source_dir "${protobuf_SOURCE_DIR}/third_party/googletest/googlemock")
22*1b3f573fSAndroid Build Coastguard Worker  set(googletest_source_dir "${protobuf_SOURCE_DIR}/third_party/googletest/googletest")
23*1b3f573fSAndroid Build Coastguard Worker  include_directories(
24*1b3f573fSAndroid Build Coastguard Worker    ${googlemock_source_dir}
25*1b3f573fSAndroid Build Coastguard Worker    ${googletest_source_dir}
26*1b3f573fSAndroid Build Coastguard Worker    ${googletest_source_dir}/include
27*1b3f573fSAndroid Build Coastguard Worker    ${googlemock_source_dir}/include
28*1b3f573fSAndroid Build Coastguard Worker  )
29*1b3f573fSAndroid Build Coastguard Worker
30*1b3f573fSAndroid Build Coastguard Worker  add_library(gmock STATIC
31*1b3f573fSAndroid Build Coastguard Worker    "${googlemock_source_dir}/src/gmock-all.cc"
32*1b3f573fSAndroid Build Coastguard Worker    "${googletest_source_dir}/src/gtest-all.cc"
33*1b3f573fSAndroid Build Coastguard Worker  )
34*1b3f573fSAndroid Build Coastguard Worker  target_link_libraries(gmock ${CMAKE_THREAD_LIBS_INIT})
35*1b3f573fSAndroid Build Coastguard Worker  add_library(gmock_main STATIC "${googlemock_source_dir}/src/gmock_main.cc")
36*1b3f573fSAndroid Build Coastguard Worker  target_link_libraries(gmock_main gmock)
37*1b3f573fSAndroid Build Coastguard Worker
38*1b3f573fSAndroid Build Coastguard Worker  add_library(GTest::gmock ALIAS gmock)
39*1b3f573fSAndroid Build Coastguard Worker  add_library(GTest::gmock_main ALIAS gmock_main)
40*1b3f573fSAndroid Build Coastguard Workerendif()
41*1b3f573fSAndroid Build Coastguard Worker
42*1b3f573fSAndroid Build Coastguard Workerset(lite_test_protos
43*1b3f573fSAndroid Build Coastguard Worker  ${protobuf_SOURCE_DIR}/src/google/protobuf/map_lite_unittest.proto
44*1b3f573fSAndroid Build Coastguard Worker  ${protobuf_SOURCE_DIR}/src/google/protobuf/unittest_import_lite.proto
45*1b3f573fSAndroid Build Coastguard Worker  ${protobuf_SOURCE_DIR}/src/google/protobuf/unittest_import_public_lite.proto
46*1b3f573fSAndroid Build Coastguard Worker  ${protobuf_SOURCE_DIR}/src/google/protobuf/unittest_lite.proto
47*1b3f573fSAndroid Build Coastguard Worker)
48*1b3f573fSAndroid Build Coastguard Worker
49*1b3f573fSAndroid Build Coastguard Workerset(tests_protos
50*1b3f573fSAndroid Build Coastguard Worker  ${protobuf_SOURCE_DIR}/src/google/protobuf/any_test.proto
51*1b3f573fSAndroid Build Coastguard Worker  ${protobuf_SOURCE_DIR}/src/google/protobuf/compiler/cpp/test_bad_identifiers.proto
52*1b3f573fSAndroid Build Coastguard Worker  ${protobuf_SOURCE_DIR}/src/google/protobuf/compiler/cpp/test_large_enum_value.proto
53*1b3f573fSAndroid Build Coastguard Worker  ${protobuf_SOURCE_DIR}/src/google/protobuf/map_proto2_unittest.proto
54*1b3f573fSAndroid Build Coastguard Worker  ${protobuf_SOURCE_DIR}/src/google/protobuf/map_unittest.proto
55*1b3f573fSAndroid Build Coastguard Worker  ${protobuf_SOURCE_DIR}/src/google/protobuf/unittest.proto
56*1b3f573fSAndroid Build Coastguard Worker  ${protobuf_SOURCE_DIR}/src/google/protobuf/unittest_arena.proto
57*1b3f573fSAndroid Build Coastguard Worker  ${protobuf_SOURCE_DIR}/src/google/protobuf/unittest_custom_options.proto
58*1b3f573fSAndroid Build Coastguard Worker  ${protobuf_SOURCE_DIR}/src/google/protobuf/unittest_drop_unknown_fields.proto
59*1b3f573fSAndroid Build Coastguard Worker  ${protobuf_SOURCE_DIR}/src/google/protobuf/unittest_embed_optimize_for.proto
60*1b3f573fSAndroid Build Coastguard Worker  ${protobuf_SOURCE_DIR}/src/google/protobuf/unittest_empty.proto
61*1b3f573fSAndroid Build Coastguard Worker  ${protobuf_SOURCE_DIR}/src/google/protobuf/unittest_enormous_descriptor.proto
62*1b3f573fSAndroid Build Coastguard Worker  ${protobuf_SOURCE_DIR}/src/google/protobuf/unittest_import.proto
63*1b3f573fSAndroid Build Coastguard Worker  ${protobuf_SOURCE_DIR}/src/google/protobuf/unittest_import_public.proto
64*1b3f573fSAndroid Build Coastguard Worker  ${protobuf_SOURCE_DIR}/src/google/protobuf/unittest_lazy_dependencies.proto
65*1b3f573fSAndroid Build Coastguard Worker  ${protobuf_SOURCE_DIR}/src/google/protobuf/unittest_lazy_dependencies_custom_option.proto
66*1b3f573fSAndroid Build Coastguard Worker  ${protobuf_SOURCE_DIR}/src/google/protobuf/unittest_lazy_dependencies_enum.proto
67*1b3f573fSAndroid Build Coastguard Worker  ${protobuf_SOURCE_DIR}/src/google/protobuf/unittest_lite_imports_nonlite.proto
68*1b3f573fSAndroid Build Coastguard Worker  ${protobuf_SOURCE_DIR}/src/google/protobuf/unittest_mset.proto
69*1b3f573fSAndroid Build Coastguard Worker  ${protobuf_SOURCE_DIR}/src/google/protobuf/unittest_mset_wire_format.proto
70*1b3f573fSAndroid Build Coastguard Worker  ${protobuf_SOURCE_DIR}/src/google/protobuf/unittest_no_field_presence.proto
71*1b3f573fSAndroid Build Coastguard Worker  ${protobuf_SOURCE_DIR}/src/google/protobuf/unittest_no_generic_services.proto
72*1b3f573fSAndroid Build Coastguard Worker  ${protobuf_SOURCE_DIR}/src/google/protobuf/unittest_optimize_for.proto
73*1b3f573fSAndroid Build Coastguard Worker  ${protobuf_SOURCE_DIR}/src/google/protobuf/unittest_preserve_unknown_enum.proto
74*1b3f573fSAndroid Build Coastguard Worker  ${protobuf_SOURCE_DIR}/src/google/protobuf/unittest_preserve_unknown_enum2.proto
75*1b3f573fSAndroid Build Coastguard Worker  ${protobuf_SOURCE_DIR}/src/google/protobuf/unittest_proto3.proto
76*1b3f573fSAndroid Build Coastguard Worker  ${protobuf_SOURCE_DIR}/src/google/protobuf/unittest_proto3_arena.proto
77*1b3f573fSAndroid Build Coastguard Worker  ${protobuf_SOURCE_DIR}/src/google/protobuf/unittest_proto3_arena_lite.proto
78*1b3f573fSAndroid Build Coastguard Worker  ${protobuf_SOURCE_DIR}/src/google/protobuf/unittest_proto3_lite.proto
79*1b3f573fSAndroid Build Coastguard Worker  ${protobuf_SOURCE_DIR}/src/google/protobuf/unittest_proto3_optional.proto
80*1b3f573fSAndroid Build Coastguard Worker  ${protobuf_SOURCE_DIR}/src/google/protobuf/unittest_well_known_types.proto
81*1b3f573fSAndroid Build Coastguard Worker  ${protobuf_SOURCE_DIR}/src/google/protobuf/util/internal/testdata/anys.proto
82*1b3f573fSAndroid Build Coastguard Worker  ${protobuf_SOURCE_DIR}/src/google/protobuf/util/internal/testdata/books.proto
83*1b3f573fSAndroid Build Coastguard Worker  ${protobuf_SOURCE_DIR}/src/google/protobuf/util/internal/testdata/default_value.proto
84*1b3f573fSAndroid Build Coastguard Worker  ${protobuf_SOURCE_DIR}/src/google/protobuf/util/internal/testdata/default_value_test.proto
85*1b3f573fSAndroid Build Coastguard Worker  ${protobuf_SOURCE_DIR}/src/google/protobuf/util/internal/testdata/field_mask.proto
86*1b3f573fSAndroid Build Coastguard Worker  ${protobuf_SOURCE_DIR}/src/google/protobuf/util/internal/testdata/maps.proto
87*1b3f573fSAndroid Build Coastguard Worker  ${protobuf_SOURCE_DIR}/src/google/protobuf/util/internal/testdata/oneofs.proto
88*1b3f573fSAndroid Build Coastguard Worker  ${protobuf_SOURCE_DIR}/src/google/protobuf/util/internal/testdata/proto3.proto
89*1b3f573fSAndroid Build Coastguard Worker  ${protobuf_SOURCE_DIR}/src/google/protobuf/util/internal/testdata/struct.proto
90*1b3f573fSAndroid Build Coastguard Worker  ${protobuf_SOURCE_DIR}/src/google/protobuf/util/internal/testdata/timestamp_duration.proto
91*1b3f573fSAndroid Build Coastguard Worker  ${protobuf_SOURCE_DIR}/src/google/protobuf/util/internal/testdata/wrappers.proto
92*1b3f573fSAndroid Build Coastguard Worker  ${protobuf_SOURCE_DIR}/src/google/protobuf/util/json_format.proto
93*1b3f573fSAndroid Build Coastguard Worker  ${protobuf_SOURCE_DIR}/src/google/protobuf/util/json_format_proto3.proto
94*1b3f573fSAndroid Build Coastguard Worker  ${protobuf_SOURCE_DIR}/src/google/protobuf/util/message_differencer_unittest.proto
95*1b3f573fSAndroid Build Coastguard Worker)
96*1b3f573fSAndroid Build Coastguard Worker
97*1b3f573fSAndroid Build Coastguard Workermacro(compile_proto_file filename)
98*1b3f573fSAndroid Build Coastguard Worker  string(REPLACE .proto .pb.cc pb_file ${filename})
99*1b3f573fSAndroid Build Coastguard Worker  add_custom_command(
100*1b3f573fSAndroid Build Coastguard Worker    OUTPUT ${pb_file}
101*1b3f573fSAndroid Build Coastguard Worker    DEPENDS ${protobuf_PROTOC_EXE} ${filename}
102*1b3f573fSAndroid Build Coastguard Worker    COMMAND ${protobuf_PROTOC_EXE} ${filename}
103*1b3f573fSAndroid Build Coastguard Worker        --proto_path=${protobuf_SOURCE_DIR}/src
104*1b3f573fSAndroid Build Coastguard Worker        --cpp_out=${protobuf_SOURCE_DIR}/src
105*1b3f573fSAndroid Build Coastguard Worker        --experimental_allow_proto3_optional
106*1b3f573fSAndroid Build Coastguard Worker  )
107*1b3f573fSAndroid Build Coastguard Workerendmacro(compile_proto_file)
108*1b3f573fSAndroid Build Coastguard Worker
109*1b3f573fSAndroid Build Coastguard Workerset(lite_test_proto_files)
110*1b3f573fSAndroid Build Coastguard Workerforeach(proto_file ${lite_test_protos})
111*1b3f573fSAndroid Build Coastguard Worker  compile_proto_file(${proto_file})
112*1b3f573fSAndroid Build Coastguard Worker  set(lite_test_proto_files ${lite_test_proto_files} ${pb_file})
113*1b3f573fSAndroid Build Coastguard Workerendforeach(proto_file)
114*1b3f573fSAndroid Build Coastguard Worker
115*1b3f573fSAndroid Build Coastguard Workerset(tests_proto_files)
116*1b3f573fSAndroid Build Coastguard Workerforeach(proto_file ${tests_protos})
117*1b3f573fSAndroid Build Coastguard Worker  compile_proto_file(${proto_file})
118*1b3f573fSAndroid Build Coastguard Worker  set(tests_proto_files ${tests_proto_files} ${pb_file})
119*1b3f573fSAndroid Build Coastguard Workerendforeach(proto_file)
120*1b3f573fSAndroid Build Coastguard Worker
121*1b3f573fSAndroid Build Coastguard Workerset(common_lite_test_files
122*1b3f573fSAndroid Build Coastguard Worker  ${protobuf_SOURCE_DIR}/src/google/protobuf/arena_test_util.cc
123*1b3f573fSAndroid Build Coastguard Worker  ${protobuf_SOURCE_DIR}/src/google/protobuf/map_lite_test_util.cc
124*1b3f573fSAndroid Build Coastguard Worker  ${protobuf_SOURCE_DIR}/src/google/protobuf/test_util_lite.cc
125*1b3f573fSAndroid Build Coastguard Worker)
126*1b3f573fSAndroid Build Coastguard Worker
127*1b3f573fSAndroid Build Coastguard Workeradd_library(protobuf-lite-test-common STATIC
128*1b3f573fSAndroid Build Coastguard Worker  ${common_lite_test_files} ${lite_test_proto_files})
129*1b3f573fSAndroid Build Coastguard Workertarget_link_libraries(protobuf-lite-test-common libprotobuf-lite GTest::gmock)
130*1b3f573fSAndroid Build Coastguard Worker
131*1b3f573fSAndroid Build Coastguard Workerset(common_test_files
132*1b3f573fSAndroid Build Coastguard Worker  ${common_lite_test_files}
133*1b3f573fSAndroid Build Coastguard Worker  ${protobuf_SOURCE_DIR}/src/google/protobuf/compiler/mock_code_generator.cc
134*1b3f573fSAndroid Build Coastguard Worker  ${protobuf_SOURCE_DIR}/src/google/protobuf/map_test_util.inc
135*1b3f573fSAndroid Build Coastguard Worker  ${protobuf_SOURCE_DIR}/src/google/protobuf/reflection_tester.cc
136*1b3f573fSAndroid Build Coastguard Worker  ${protobuf_SOURCE_DIR}/src/google/protobuf/test_util.cc
137*1b3f573fSAndroid Build Coastguard Worker  ${protobuf_SOURCE_DIR}/src/google/protobuf/testing/file.cc
138*1b3f573fSAndroid Build Coastguard Worker  ${protobuf_SOURCE_DIR}/src/google/protobuf/testing/googletest.cc
139*1b3f573fSAndroid Build Coastguard Worker)
140*1b3f573fSAndroid Build Coastguard Worker
141*1b3f573fSAndroid Build Coastguard Workeradd_library(protobuf-test-common STATIC
142*1b3f573fSAndroid Build Coastguard Worker  ${common_test_files} ${tests_proto_files})
143*1b3f573fSAndroid Build Coastguard Workertarget_link_libraries(protobuf-test-common libprotobuf GTest::gmock)
144*1b3f573fSAndroid Build Coastguard Worker
145*1b3f573fSAndroid Build Coastguard Workerset(tests_files
146*1b3f573fSAndroid Build Coastguard Worker  ${protobuf_SOURCE_DIR}/src/google/protobuf/any_test.cc
147*1b3f573fSAndroid Build Coastguard Worker  ${protobuf_SOURCE_DIR}/src/google/protobuf/arena_unittest.cc
148*1b3f573fSAndroid Build Coastguard Worker  ${protobuf_SOURCE_DIR}/src/google/protobuf/arenastring_unittest.cc
149*1b3f573fSAndroid Build Coastguard Worker  ${protobuf_SOURCE_DIR}/src/google/protobuf/arenaz_sampler_test.cc
150*1b3f573fSAndroid Build Coastguard Worker  ${protobuf_SOURCE_DIR}/src/google/protobuf/compiler/annotation_test_util.cc
151*1b3f573fSAndroid Build Coastguard Worker  ${protobuf_SOURCE_DIR}/src/google/protobuf/compiler/annotation_test_util.h
152*1b3f573fSAndroid Build Coastguard Worker  ${protobuf_SOURCE_DIR}/src/google/protobuf/compiler/command_line_interface_unittest.cc
153*1b3f573fSAndroid Build Coastguard Worker  ${protobuf_SOURCE_DIR}/src/google/protobuf/compiler/cpp/bootstrap_unittest.cc
154*1b3f573fSAndroid Build Coastguard Worker  ${protobuf_SOURCE_DIR}/src/google/protobuf/compiler/cpp/message_size_unittest.cc
155*1b3f573fSAndroid Build Coastguard Worker  ${protobuf_SOURCE_DIR}/src/google/protobuf/compiler/cpp/metadata_test.cc
156*1b3f573fSAndroid Build Coastguard Worker  ${protobuf_SOURCE_DIR}/src/google/protobuf/compiler/cpp/move_unittest.cc
157*1b3f573fSAndroid Build Coastguard Worker  ${protobuf_SOURCE_DIR}/src/google/protobuf/compiler/cpp/plugin_unittest.cc
158*1b3f573fSAndroid Build Coastguard Worker  ${protobuf_SOURCE_DIR}/src/google/protobuf/compiler/cpp/unittest.cc
159*1b3f573fSAndroid Build Coastguard Worker  ${protobuf_SOURCE_DIR}/src/google/protobuf/compiler/cpp/unittest.inc
160*1b3f573fSAndroid Build Coastguard Worker  ${protobuf_SOURCE_DIR}/src/google/protobuf/compiler/csharp/csharp_bootstrap_unittest.cc
161*1b3f573fSAndroid Build Coastguard Worker  ${protobuf_SOURCE_DIR}/src/google/protobuf/compiler/csharp/csharp_generator_unittest.cc
162*1b3f573fSAndroid Build Coastguard Worker  ${protobuf_SOURCE_DIR}/src/google/protobuf/compiler/importer_unittest.cc
163*1b3f573fSAndroid Build Coastguard Worker  ${protobuf_SOURCE_DIR}/src/google/protobuf/compiler/java/doc_comment_unittest.cc
164*1b3f573fSAndroid Build Coastguard Worker  ${protobuf_SOURCE_DIR}/src/google/protobuf/compiler/java/plugin_unittest.cc
165*1b3f573fSAndroid Build Coastguard Worker  ${protobuf_SOURCE_DIR}/src/google/protobuf/compiler/objectivec/objectivec_helpers_unittest.cc
166*1b3f573fSAndroid Build Coastguard Worker  ${protobuf_SOURCE_DIR}/src/google/protobuf/compiler/parser_unittest.cc
167*1b3f573fSAndroid Build Coastguard Worker  ${protobuf_SOURCE_DIR}/src/google/protobuf/compiler/python/plugin_unittest.cc
168*1b3f573fSAndroid Build Coastguard Worker  ${protobuf_SOURCE_DIR}/src/google/protobuf/compiler/ruby/ruby_generator_unittest.cc
169*1b3f573fSAndroid Build Coastguard Worker  ${protobuf_SOURCE_DIR}/src/google/protobuf/descriptor_database_unittest.cc
170*1b3f573fSAndroid Build Coastguard Worker  ${protobuf_SOURCE_DIR}/src/google/protobuf/descriptor_unittest.cc
171*1b3f573fSAndroid Build Coastguard Worker  ${protobuf_SOURCE_DIR}/src/google/protobuf/drop_unknown_fields_test.cc
172*1b3f573fSAndroid Build Coastguard Worker  ${protobuf_SOURCE_DIR}/src/google/protobuf/dynamic_message_unittest.cc
173*1b3f573fSAndroid Build Coastguard Worker  ${protobuf_SOURCE_DIR}/src/google/protobuf/extension_set_unittest.cc
174*1b3f573fSAndroid Build Coastguard Worker  ${protobuf_SOURCE_DIR}/src/google/protobuf/generated_message_reflection_unittest.cc
175*1b3f573fSAndroid Build Coastguard Worker  ${protobuf_SOURCE_DIR}/src/google/protobuf/generated_message_tctable_lite_test.cc
176*1b3f573fSAndroid Build Coastguard Worker  ${protobuf_SOURCE_DIR}/src/google/protobuf/inlined_string_field_unittest.cc
177*1b3f573fSAndroid Build Coastguard Worker  ${protobuf_SOURCE_DIR}/src/google/protobuf/io/coded_stream_unittest.cc
178*1b3f573fSAndroid Build Coastguard Worker  ${protobuf_SOURCE_DIR}/src/google/protobuf/io/io_win32_unittest.cc
179*1b3f573fSAndroid Build Coastguard Worker  ${protobuf_SOURCE_DIR}/src/google/protobuf/io/printer_unittest.cc
180*1b3f573fSAndroid Build Coastguard Worker  ${protobuf_SOURCE_DIR}/src/google/protobuf/io/tokenizer_unittest.cc
181*1b3f573fSAndroid Build Coastguard Worker  ${protobuf_SOURCE_DIR}/src/google/protobuf/io/zero_copy_stream_unittest.cc
182*1b3f573fSAndroid Build Coastguard Worker  ${protobuf_SOURCE_DIR}/src/google/protobuf/map_field_test.cc
183*1b3f573fSAndroid Build Coastguard Worker  ${protobuf_SOURCE_DIR}/src/google/protobuf/map_test.cc
184*1b3f573fSAndroid Build Coastguard Worker  ${protobuf_SOURCE_DIR}/src/google/protobuf/map_test.inc
185*1b3f573fSAndroid Build Coastguard Worker  ${protobuf_SOURCE_DIR}/src/google/protobuf/message_unittest.cc
186*1b3f573fSAndroid Build Coastguard Worker  ${protobuf_SOURCE_DIR}/src/google/protobuf/message_unittest.inc
187*1b3f573fSAndroid Build Coastguard Worker  ${protobuf_SOURCE_DIR}/src/google/protobuf/no_field_presence_test.cc
188*1b3f573fSAndroid Build Coastguard Worker  ${protobuf_SOURCE_DIR}/src/google/protobuf/preserve_unknown_enum_test.cc
189*1b3f573fSAndroid Build Coastguard Worker  ${protobuf_SOURCE_DIR}/src/google/protobuf/proto3_arena_lite_unittest.cc
190*1b3f573fSAndroid Build Coastguard Worker  ${protobuf_SOURCE_DIR}/src/google/protobuf/proto3_arena_unittest.cc
191*1b3f573fSAndroid Build Coastguard Worker  ${protobuf_SOURCE_DIR}/src/google/protobuf/proto3_lite_unittest.cc
192*1b3f573fSAndroid Build Coastguard Worker  ${protobuf_SOURCE_DIR}/src/google/protobuf/proto3_lite_unittest.inc
193*1b3f573fSAndroid Build Coastguard Worker  ${protobuf_SOURCE_DIR}/src/google/protobuf/reflection_ops_unittest.cc
194*1b3f573fSAndroid Build Coastguard Worker  ${protobuf_SOURCE_DIR}/src/google/protobuf/repeated_field_reflection_unittest.cc
195*1b3f573fSAndroid Build Coastguard Worker  ${protobuf_SOURCE_DIR}/src/google/protobuf/repeated_field_unittest.cc
196*1b3f573fSAndroid Build Coastguard Worker  ${protobuf_SOURCE_DIR}/src/google/protobuf/stubs/bytestream_unittest.cc
197*1b3f573fSAndroid Build Coastguard Worker  ${protobuf_SOURCE_DIR}/src/google/protobuf/stubs/common_unittest.cc
198*1b3f573fSAndroid Build Coastguard Worker  ${protobuf_SOURCE_DIR}/src/google/protobuf/stubs/int128_unittest.cc
199*1b3f573fSAndroid Build Coastguard Worker  ${protobuf_SOURCE_DIR}/src/google/protobuf/stubs/status_test.cc
200*1b3f573fSAndroid Build Coastguard Worker  ${protobuf_SOURCE_DIR}/src/google/protobuf/stubs/statusor_test.cc
201*1b3f573fSAndroid Build Coastguard Worker  ${protobuf_SOURCE_DIR}/src/google/protobuf/stubs/stringpiece_unittest.cc
202*1b3f573fSAndroid Build Coastguard Worker  ${protobuf_SOURCE_DIR}/src/google/protobuf/stubs/stringprintf_unittest.cc
203*1b3f573fSAndroid Build Coastguard Worker  ${protobuf_SOURCE_DIR}/src/google/protobuf/stubs/structurally_valid_unittest.cc
204*1b3f573fSAndroid Build Coastguard Worker  ${protobuf_SOURCE_DIR}/src/google/protobuf/stubs/strutil_unittest.cc
205*1b3f573fSAndroid Build Coastguard Worker  ${protobuf_SOURCE_DIR}/src/google/protobuf/stubs/template_util_unittest.cc
206*1b3f573fSAndroid Build Coastguard Worker  ${protobuf_SOURCE_DIR}/src/google/protobuf/stubs/time_test.cc
207*1b3f573fSAndroid Build Coastguard Worker  ${protobuf_SOURCE_DIR}/src/google/protobuf/text_format_unittest.cc
208*1b3f573fSAndroid Build Coastguard Worker  ${protobuf_SOURCE_DIR}/src/google/protobuf/unknown_field_set_unittest.cc
209*1b3f573fSAndroid Build Coastguard Worker  ${protobuf_SOURCE_DIR}/src/google/protobuf/util/delimited_message_util_test.cc
210*1b3f573fSAndroid Build Coastguard Worker  ${protobuf_SOURCE_DIR}/src/google/protobuf/util/field_comparator_test.cc
211*1b3f573fSAndroid Build Coastguard Worker  ${protobuf_SOURCE_DIR}/src/google/protobuf/util/field_mask_util_test.cc
212*1b3f573fSAndroid Build Coastguard Worker  ${protobuf_SOURCE_DIR}/src/google/protobuf/util/internal/default_value_objectwriter_test.cc
213*1b3f573fSAndroid Build Coastguard Worker  ${protobuf_SOURCE_DIR}/src/google/protobuf/util/internal/json_objectwriter_test.cc
214*1b3f573fSAndroid Build Coastguard Worker  ${protobuf_SOURCE_DIR}/src/google/protobuf/util/internal/json_stream_parser_test.cc
215*1b3f573fSAndroid Build Coastguard Worker  ${protobuf_SOURCE_DIR}/src/google/protobuf/util/internal/protostream_objectsource_test.cc
216*1b3f573fSAndroid Build Coastguard Worker  ${protobuf_SOURCE_DIR}/src/google/protobuf/util/internal/protostream_objectwriter_test.cc
217*1b3f573fSAndroid Build Coastguard Worker  ${protobuf_SOURCE_DIR}/src/google/protobuf/util/internal/type_info_test_helper.cc
218*1b3f573fSAndroid Build Coastguard Worker  ${protobuf_SOURCE_DIR}/src/google/protobuf/util/json_util_test.cc
219*1b3f573fSAndroid Build Coastguard Worker  ${protobuf_SOURCE_DIR}/src/google/protobuf/util/message_differencer_unittest.cc
220*1b3f573fSAndroid Build Coastguard Worker  ${protobuf_SOURCE_DIR}/src/google/protobuf/util/time_util_test.cc
221*1b3f573fSAndroid Build Coastguard Worker  ${protobuf_SOURCE_DIR}/src/google/protobuf/util/type_resolver_util_test.cc
222*1b3f573fSAndroid Build Coastguard Worker  ${protobuf_SOURCE_DIR}/src/google/protobuf/well_known_types_unittest.cc
223*1b3f573fSAndroid Build Coastguard Worker  ${protobuf_SOURCE_DIR}/src/google/protobuf/wire_format_unittest.cc
224*1b3f573fSAndroid Build Coastguard Worker  ${protobuf_SOURCE_DIR}/src/google/protobuf/wire_format_unittest.inc
225*1b3f573fSAndroid Build Coastguard Worker)
226*1b3f573fSAndroid Build Coastguard Worker
227*1b3f573fSAndroid Build Coastguard Workerif(protobuf_ABSOLUTE_TEST_PLUGIN_PATH)
228*1b3f573fSAndroid Build Coastguard Worker  add_compile_options(-DGOOGLE_PROTOBUF_TEST_PLUGIN_PATH="$<TARGET_FILE:test_plugin>")
229*1b3f573fSAndroid Build Coastguard Workerendif()
230*1b3f573fSAndroid Build Coastguard Worker
231*1b3f573fSAndroid Build Coastguard Workerif(MINGW)
232*1b3f573fSAndroid Build Coastguard Worker  set_source_files_properties(${tests_files} PROPERTIES COMPILE_FLAGS "-Wno-narrowing")
233*1b3f573fSAndroid Build Coastguard Worker
234*1b3f573fSAndroid Build Coastguard Worker  # required for tests on MinGW Win64
235*1b3f573fSAndroid Build Coastguard Worker  if (CMAKE_SIZEOF_VOID_P EQUAL 8)
236*1b3f573fSAndroid Build Coastguard Worker    set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,--stack,16777216")
237*1b3f573fSAndroid Build Coastguard Worker    set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wa,-mbig-obj")
238*1b3f573fSAndroid Build Coastguard Worker  endif()
239*1b3f573fSAndroid Build Coastguard Worker
240*1b3f573fSAndroid Build Coastguard Workerendif()
241*1b3f573fSAndroid Build Coastguard Worker
242*1b3f573fSAndroid Build Coastguard Workerif(protobuf_TEST_XML_OUTDIR)
243*1b3f573fSAndroid Build Coastguard Worker  if(NOT "${protobuf_TEST_XML_OUTDIR}" MATCHES "[/\\]$")
244*1b3f573fSAndroid Build Coastguard Worker    string(APPEND protobuf_TEST_XML_OUTDIR "/")
245*1b3f573fSAndroid Build Coastguard Worker  endif()
246*1b3f573fSAndroid Build Coastguard Worker  set(protobuf_GTEST_ARGS "--gtest_output=xml:${protobuf_TEST_XML_OUTDIR}")
247*1b3f573fSAndroid Build Coastguard Workerelse()
248*1b3f573fSAndroid Build Coastguard Worker  set(protobuf_GTEST_ARGS)
249*1b3f573fSAndroid Build Coastguard Workerendif()
250*1b3f573fSAndroid Build Coastguard Worker
251*1b3f573fSAndroid Build Coastguard Workeradd_executable(tests ${tests_files})
252*1b3f573fSAndroid Build Coastguard Workerif (MSVC)
253*1b3f573fSAndroid Build Coastguard Worker  target_compile_options(tests PRIVATE
254*1b3f573fSAndroid Build Coastguard Worker    /wd4146 # unary minus operator applied to unsigned type, result still unsigned
255*1b3f573fSAndroid Build Coastguard Worker  )
256*1b3f573fSAndroid Build Coastguard Workerendif()
257*1b3f573fSAndroid Build Coastguard Workertarget_link_libraries(tests protobuf-lite-test-common protobuf-test-common libprotoc libprotobuf GTest::gmock_main)
258*1b3f573fSAndroid Build Coastguard Worker
259*1b3f573fSAndroid Build Coastguard Workerset(test_plugin_files
260*1b3f573fSAndroid Build Coastguard Worker  ${protobuf_SOURCE_DIR}/src/google/protobuf/compiler/mock_code_generator.cc
261*1b3f573fSAndroid Build Coastguard Worker  ${protobuf_SOURCE_DIR}/src/google/protobuf/compiler/test_plugin.cc
262*1b3f573fSAndroid Build Coastguard Worker  ${protobuf_SOURCE_DIR}/src/google/protobuf/testing/file.cc
263*1b3f573fSAndroid Build Coastguard Worker  ${protobuf_SOURCE_DIR}/src/google/protobuf/testing/file.h
264*1b3f573fSAndroid Build Coastguard Worker)
265*1b3f573fSAndroid Build Coastguard Worker
266*1b3f573fSAndroid Build Coastguard Workeradd_executable(test_plugin ${test_plugin_files})
267*1b3f573fSAndroid Build Coastguard Workertarget_link_libraries(test_plugin libprotoc libprotobuf GTest::gmock)
268*1b3f573fSAndroid Build Coastguard Worker
269*1b3f573fSAndroid Build Coastguard Workerset(lite_test_files
270*1b3f573fSAndroid Build Coastguard Worker  ${protobuf_SOURCE_DIR}/src/google/protobuf/lite_unittest.cc
271*1b3f573fSAndroid Build Coastguard Worker)
272*1b3f573fSAndroid Build Coastguard Workeradd_executable(lite-test ${lite_test_files})
273*1b3f573fSAndroid Build Coastguard Workertarget_link_libraries(lite-test protobuf-lite-test-common libprotobuf-lite GTest::gmock_main)
274*1b3f573fSAndroid Build Coastguard Worker
275*1b3f573fSAndroid Build Coastguard Workeradd_test(NAME lite-test
276*1b3f573fSAndroid Build Coastguard Worker  COMMAND lite-test ${protobuf_GTEST_ARGS})
277*1b3f573fSAndroid Build Coastguard Worker
278*1b3f573fSAndroid Build Coastguard Workerset(lite_arena_test_files
279*1b3f573fSAndroid Build Coastguard Worker  ${protobuf_SOURCE_DIR}/src/google/protobuf/lite_arena_unittest.cc
280*1b3f573fSAndroid Build Coastguard Worker)
281*1b3f573fSAndroid Build Coastguard Workeradd_executable(lite-arena-test ${lite_arena_test_files})
282*1b3f573fSAndroid Build Coastguard Workertarget_link_libraries(lite-arena-test protobuf-lite-test-common libprotobuf-lite GTest::gmock_main)
283*1b3f573fSAndroid Build Coastguard Worker
284*1b3f573fSAndroid Build Coastguard Workeradd_test(NAME lite-arena-test
285*1b3f573fSAndroid Build Coastguard Worker  COMMAND lite-arena-test ${protobuf_GTEST_ARGS})
286*1b3f573fSAndroid Build Coastguard Worker
287*1b3f573fSAndroid Build Coastguard Workeradd_custom_target(check
288*1b3f573fSAndroid Build Coastguard Worker  COMMAND tests
289*1b3f573fSAndroid Build Coastguard Worker  DEPENDS tests test_plugin
290*1b3f573fSAndroid Build Coastguard Worker  WORKING_DIRECTORY ${protobuf_SOURCE_DIR})
291*1b3f573fSAndroid Build Coastguard Worker
292*1b3f573fSAndroid Build Coastguard Workeradd_test(NAME check
293*1b3f573fSAndroid Build Coastguard Worker  COMMAND tests ${protobuf_GTEST_ARGS}
294*1b3f573fSAndroid Build Coastguard Worker  WORKING_DIRECTORY "${protobuf_SOURCE_DIR}")
295