From 01d6739d9d1a8bc0674267a7c7bbf1455f82f92f Mon Sep 17 00:00:00 2001 From: Dennis Oberst Date: Fri, 14 Jun 2024 10:50:05 +0200 Subject: [PATCH] testservers: add conditional proto3_optional support protoc versions 3.12 - 3.15 need to enable optional support explicitly Pick-to: 6.8 Change-Id: Ie672e1bb06fb8665f2517bad9c39cdfcc9b3b728 Reviewed-by: Alexey Edelev --- tests/auto/grpc/client/shared/test_server/CMakeLists.txt | 7 +++++++ .../auto/grpc/client/shared/test_server_go/CMakeLists.txt | 8 ++++++++ 2 files changed, 15 insertions(+) diff --git a/tests/auto/grpc/client/shared/test_server/CMakeLists.txt b/tests/auto/grpc/client/shared/test_server/CMakeLists.txt index 9df8c21e..f94f55a5 100644 --- a/tests/auto/grpc/client/shared/test_server/CMakeLists.txt +++ b/tests/auto/grpc/client/shared/test_server/CMakeLists.txt @@ -17,11 +17,18 @@ set(generated_files "${out_dir}/testservice.pb.h" "${out_dir}/testservice.pb.cc" "${out_dir}/testservice.grpc.pb.h" "${out_dir}/testservice.grpc.pb.cc") +set(extra_protoc_args "") +get_target_property(protoc_version WrapProtoc::WrapProtoc _qt_internal_protobuf_version) +if(protoc_version VERSION_GREATER_EQUAL "3.12" AND protoc_version VERSION_LESS "3.15") + list(APPEND extra_protoc_args "--experimental_allow_proto3_optional") +endif() + add_custom_command( OUTPUT ${generated_files} COMMAND $ ARGS + ${extra_protoc_args} --grpc_out "${out_dir}" --cpp_out "${out_dir}" -I "${CMAKE_CURRENT_LIST_DIR}/../../../shared/proto/" diff --git a/tests/auto/grpc/client/shared/test_server_go/CMakeLists.txt b/tests/auto/grpc/client/shared/test_server_go/CMakeLists.txt index d1c95086..af58f7b7 100644 --- a/tests/auto/grpc/client/shared/test_server_go/CMakeLists.txt +++ b/tests/auto/grpc/client/shared/test_server_go/CMakeLists.txt @@ -28,12 +28,20 @@ set(testserver_gen_output "${CMAKE_CURRENT_BINARY_DIR}/qtgrpc/tests/testservice_grpc.pb.go" "${CMAKE_CURRENT_BINARY_DIR}/qtgrpc/tests/testservice.pb.go" ) + +set(extra_protoc_args "") +get_target_property(protoc_version WrapProtoc::WrapProtoc _qt_internal_protobuf_version) +if(protoc_version VERSION_GREATER_EQUAL "3.12" AND protoc_version VERSION_LESS "3.15") + list(APPEND extra_protoc_args "--experimental_allow_proto3_optional") +endif() + add_custom_command( OUTPUT ${testserver_gen_output} COMMAND ${CMAKE_COMMAND} -E env "PATH=$ENV{PATH}:${go_path}/bin" "GOPATH=${go_path}" -- $ + ${extra_protoc_args} --go_out=${CMAKE_CURRENT_BINARY_DIR} --go-grpc_out=${CMAKE_CURRENT_BINARY_DIR} -I${CMAKE_CURRENT_LIST_DIR}/../../../shared/proto