Debian Codegraph @

extra/protobuf/protobuf-24.4/cmake/conformance.cmake

raw
1 if (protobuf_JSONCPP_PROVIDER STREQUAL "module")
2 if (NOT EXISTS "${protobuf_SOURCE_DIR}/third_party/jsoncpp/CMakeLists.txt")
3 message(FATAL_ERROR
4 "Cannot find third_party/jsoncpp directory that's needed to "
5 "build conformance tests. If you use git, make sure you have cloned "
6 "submodules:\n"
7 " git submodule update --init --recursive\n"
8 "If instead you want to skip them, run cmake with:\n"
9 " cmake -Dprotobuf_BUILD_CONFORMANCE=OFF\n")
10 endif()
11 elseif(protobuf_JSONCPP_PROVIDER STREQUAL "package")
12 find_package(jsoncpp REQUIRED)
13 endif()
14
15 add_custom_command(
16 OUTPUT
17 ${protobuf_SOURCE_DIR}/conformance/conformance.pb.h
18 ${protobuf_SOURCE_DIR}/conformance/conformance.pb.cc
19 DEPENDS ${protobuf_PROTOC_EXE} ${protobuf_SOURCE_DIR}/conformance/conformance.proto
20 COMMAND ${protobuf_PROTOC_EXE} ${protobuf_SOURCE_DIR}/conformance/conformance.proto
21 --proto_path=${protobuf_SOURCE_DIR}/conformance
22 --cpp_out=${protobuf_SOURCE_DIR}/conformance
23 )
24
25 add_custom_command(
26 OUTPUT
27 ${protobuf_SOURCE_DIR}/src/google/protobuf/test_messages_proto3.pb.h
28 ${protobuf_SOURCE_DIR}/src/google/protobuf/test_messages_proto3.pb.cc
29 ${protobuf_SOURCE_DIR}/src/google/protobuf/test_messages_proto2.pb.h
30 ${protobuf_SOURCE_DIR}/src/google/protobuf/test_messages_proto2.pb.cc
31 DEPENDS ${protobuf_PROTOC_EXE} ${protobuf_SOURCE_DIR}/src/google/protobuf/test_messages_proto3.proto
32 ${protobuf_PROTOC_EXE} ${protobuf_SOURCE_DIR}/src/google/protobuf/test_messages_proto2.proto
33 COMMAND ${protobuf_PROTOC_EXE} ${protobuf_SOURCE_DIR}/src/google/protobuf/test_messages_proto3.proto
34 ${protobuf_SOURCE_DIR}/src/google/protobuf/test_messages_proto2.proto
35 --proto_path=${protobuf_SOURCE_DIR}/src
36 --cpp_out=${protobuf_SOURCE_DIR}/src
37 )
38
39 add_executable(conformance_test_runner
40 ${protobuf_SOURCE_DIR}/conformance/binary_json_conformance_suite.cc
41 ${protobuf_SOURCE_DIR}/conformance/binary_json_conformance_suite.h
42 ${protobuf_SOURCE_DIR}/conformance/conformance.pb.h
43 ${protobuf_SOURCE_DIR}/conformance/conformance.pb.cc
44 ${protobuf_SOURCE_DIR}/conformance/conformance_test.cc
45 ${protobuf_SOURCE_DIR}/conformance/conformance_test_runner.cc
46 ${protobuf_SOURCE_DIR}/conformance/conformance_test_main.cc
47 ${protobuf_SOURCE_DIR}/conformance/text_format_conformance_suite.cc
48 ${protobuf_SOURCE_DIR}/conformance/text_format_conformance_suite.h
49 ${protobuf_SOURCE_DIR}/src/google/protobuf/test_messages_proto2.pb.h
50 ${protobuf_SOURCE_DIR}/src/google/protobuf/test_messages_proto2.pb.cc
51 ${protobuf_SOURCE_DIR}/src/google/protobuf/test_messages_proto3.pb.h
52 ${protobuf_SOURCE_DIR}/src/google/protobuf/test_messages_proto3.pb.cc
53 )
54
55 add_executable(conformance_cpp
56 ${protobuf_SOURCE_DIR}/conformance/conformance.pb.h
57 ${protobuf_SOURCE_DIR}/conformance/conformance.pb.cc
58 ${protobuf_SOURCE_DIR}/conformance/conformance_cpp.cc
59 ${protobuf_SOURCE_DIR}/src/google/protobuf/test_messages_proto2.pb.h
60 ${protobuf_SOURCE_DIR}/src/google/protobuf/test_messages_proto2.pb.cc
61 ${protobuf_SOURCE_DIR}/src/google/protobuf/test_messages_proto3.pb.h
62 ${protobuf_SOURCE_DIR}/src/google/protobuf/test_messages_proto3.pb.cc
63 )
64
65 target_include_directories(
66 conformance_test_runner
67 PUBLIC ${protobuf_SOURCE_DIR} ${protobuf_SOURCE_DIR}/conformance)
68
69 target_include_directories(
70 conformance_cpp
71 PUBLIC ${protobuf_SOURCE_DIR})
72
73 target_include_directories(conformance_test_runner PRIVATE ${ABSL_ROOT_DIR})
74 target_include_directories(conformance_cpp PRIVATE ${ABSL_ROOT_DIR})
75
76 target_link_libraries(conformance_test_runner ${protobuf_LIB_PROTOBUF})
77 target_link_libraries(conformance_test_runner ${protobuf_ABSL_USED_TARGETS})
78 target_link_libraries(conformance_cpp ${protobuf_LIB_PROTOBUF})
79 target_link_libraries(conformance_cpp ${protobuf_ABSL_USED_TARGETS})
80
81 add_test(NAME conformance_cpp_test
82 COMMAND ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/conformance_test_runner
83 --failure_list ${protobuf_SOURCE_DIR}/conformance/failure_list_cpp.txt
84 --text_format_failure_list ${protobuf_SOURCE_DIR}/conformance/text_format_failure_list_cpp.txt
85 --output_dir ${protobuf_TEST_XML_OUTDIR}
86 ${CMAKE_CURRENT_BINARY_DIR}/conformance_cpp
87 DEPENDS conformance_test_runner conformance_cpp)
88
89 set(JSONCPP_WITH_TESTS OFF CACHE BOOL "Disable tests")
90 if(protobuf_JSONCPP_PROVIDER STREQUAL "module")
91 add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/third_party/jsoncpp third_party/jsoncpp)
92 target_include_directories(conformance_test_runner PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/third_party/jsoncpp/include)
93 if(BUILD_SHARED_LIBS)
94 target_link_libraries(conformance_test_runner jsoncpp_lib)
95 else()
96 target_link_libraries(conformance_test_runner jsoncpp_static)
97 endif()
98 else()
99 target_link_libraries(conformance_test_runner jsoncpp)
100 endif()