Add "--experimental_allow_proto3_optional" for legacy protoc versions

The protoc tool doesn't support field presence for proto3 syntax in
versions less than 3.15. In versions higher than or equal to 3.12 the
support can be enabled using the --experimental_allow_proto3_optional
flag.

This fixes the build issue in LTS Ubuntu.

Pick-to: 6.5
Change-Id: I3b897139e184c307e8d21839cca3aa9fdc9d9f7f
Reviewed-by: Tatiana Borisova <tatiana.borisova@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
(cherry picked from commit 8a32a7c8b9)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
Alexey Edelev 2023-11-24 12:37:43 +01:00 committed by Qt Cherry-pick Bot
parent 297f9df594
commit 24e9dee0cf
1 changed files with 8 additions and 0 deletions

View File

@ -117,7 +117,15 @@ function(_qt_internal_protoc_generate target generator output_directory)
else()
set(generation_options_string "")
endif()
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()
string(JOIN "\\$<SEMICOLON>" protoc_arguments
${extra_protoc_args}
"--plugin=protoc-gen-${generator}=${generator_file}"
"--${generator}_out=${tmp_output_directory}"
"--${generator}_opt=${generation_options_string}"