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