When building static libraries or shared libraries on Windows platforms
we need to make sure that _protobuf_registration targets depend on the
generated cpp exports. This add the header file containing exports as
the source file to the _protobuf_registration targets and also
makes sure that we add the dependencies when using both qt_add_protobuf
and qt_add_grpc calls on the same target.
Pick-to: 6.7
Change-Id: Ibc6c04e363093c54dc7ff1725fc6e816b3c9ffdf
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Consider the EXPORT_MACRO CMake argument of qt_add_<protobuf|grpc>
calls.
Add the support for the EXPORT_MACRO option extras to the
qt<protobuf|grpc>gen generators. The extras now allow setting:
- export file name
- boolean flag that indicates if export file needs to be generated
The EXPORT_MACRO option of the generators now has the following format:
EXPORT_MACRO=<export_name>[:export_filename[:<true|false>]]
If export_filename is not set, then generators fall back to the previos
behavior and use the export_name as the export filename base, the file
will be generated unconditionally. If export_filename is set and the
follow boolean flag is not set or is set to false, generators skip the
generating of the export file.
[ChangeLog][Protobuf][qtprotobufgen] EXPORT_MACRO option now has the
following format:
EXPORT_MACRO=<export_name>[:export_filename[:<true|false>]]
New option extras allow setting the generated export filename and
control if it should be generated at the generator run.
[ChangeLog][GRPC][qtgrpcgen] EXPORT_MACRO option now has the
following format:
EXPORT_MACRO=<export_name>[:export_filename[:<true|false>]]
New option extras allow setting the generated export filename and
control if it should be generated at the generator run.
Pick-to: 6.7
Fixes: QTBUG-121854
Change-Id: Ifff6506ab363d18dc417f222e9929d7eba135d8a
Reviewed-by: Tatiana Borisova <tatiana.borisova@qt.io>
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Add the protobuf output directory to the target include paths in a
build interface.
Pick-to: 6.7 6.6 6.5
Change-Id: I75fabb9b21267221b66a42fd118a78fe4fd80f9c
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Allow using the cached protobuf/grpc generated files only when the
CMake generator is Ninja-like. Other generators may ignore/not support
the add_custom_command by-products.
This shouldn't affect any officially supported build scenario, since
this feature is only applicable for QtGrpc builds, but not user
projects and we only officially support Ninja-like generators.
Ammends 152fe1748da638a1af1a7beedab8f3718432a607
Pick-to: 6.5 6.6 6.7
Task-number: QTBUG-121544
Change-Id: I339578500afd561d863550b2c6e24940a7231775
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Force Ninja to consider the temporary files produced by
qt<protobuf|grpc>gen. Timestamp of these files still has no effect on
the "main" dependency chain in developer builds, but if files were
changed during generating process, Ninja will rerun copy_if_different
rules.
Fixes: QTBUG-121544
Pick-to: 6.5 6.6 6.7
Change-Id: I7e3780d971cca9ae132b88ed2e927eb12e6bb551
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
We should enable AUTOMOC for all types of targets support by modules.
The current condition breaks executables and modules(plugins).
Pick-to: 6.7 6.6 6.5
Change-Id: I4c078d4dbadbbb26b2eb393da729a4d2c808de1b
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
Increase number of sections in object files if MinGW compiler is used.
We do the same for MSVC already.
Pick-to: 6.7 6.6 6.5
Change-Id: Ibc469809048db462e2e2c7b3236de801b6395d93
Reviewed-by: Tatiana Borisova <tatiana.borisova@qt.io>
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 6.6
Change-Id: I3b897139e184c307e8d21839cca3aa9fdc9d9f7f
Reviewed-by: Tatiana Borisova <tatiana.borisova@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
We should allow adding protobuf types to the existing QML modules.
This will allow users to create customized QML module targets and
compliment them with protobuf types. The qt_add_protobuf function
still requires the single package name for all .proto files passed
to the function. Also if QML_URI is passed to a qt_add_protobuf
call and target is QML module already, QML_URI argument will be
ignored. The target now collects protobuf package names in the
QT_PROTOBUF_PACKAGES variable.
Amends 0e6a605867
Pick-to: 6.6
Change-Id: I2cdaddb829be6b1ec32a3123d2bbf5136024d087
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Reviewed-by: Dennis Oberst <dennis.oberst@qt.io>
Somehow CMake does not really good job on escaping the arguments
we pass using PROTOC_ARGS. For VS generators it even wraps each
semicolon with quotes. Not sure if it's CMake-user bug or CMake
bug, but since the fix is easy, we probably shouldn't care much.
Pick-to: 6.5 6.6
Fixes: QTBUG-116463
Change-Id: I9b8db8ecce2e88134b708b5530e459572ac93e36
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Protobuf allows the following construction:
message A {
enum AEnum {
AVal0 = 0;
}
B.BEnum val = 1;
}
message B {
enum BEnum {
BVal0 = 0;
}
A.AEnum val = 1;
}
This requires forward declaration of nested enums, that is not possible
in C++. To solve this problem we may do the same trick that we do
for nested messages already.
This patch moves the nested enum type out of class to the
_QtProtobufNested namespace. The solution require the enum name
specification when using enums from this moment, since the owning
messages only contain type aliases now. So from example above to access
the AVal0 you need to use the full qualifier:
A::AEnum::AVal0
The new generated code structure registrates Qml types using the built-in
macros, that unlocks direct linking of backing library without the need
of Qml plugin usage.
[ChangeLog][Protobuf] Nested enums moved out of message classes to the
nested namespace, same as the nested messages.
[ChangeLog][Protobuf][Qml] The geneated protobuf Qml modules do not
require the use of Qml plugins.
Fixes: QTBUG-115800
Change-Id: Ia67fcbecf492c3fd41350eada4d62fc9e5ea4dab
Reviewed-by: Tatiana Borisova <tatiana.borisova@qt.io>
Reviewed-by: Konrad Kujawa <konrad.kujawa@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
The recent finding from CMake shown that if list contain the
open bracket '[', CMake ignores any semicolon separators as this
list chunk is treated as escaped string until the closing bracket
is faced. This happened with .proto files that have the open
bracket at one line and the closing bracket on another one, or
even miss the closing bracket.
Remove all brackets preliminary from .proto file content to make sure
we don't hit this issue.
Note: We are not interested in brackets in this parser.
Pick-to: 6.5 6.6
Fixes: QTBUG-116043
Change-Id: I282e1f4a93db4486fde0370045c22d1c8ecf9afa
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Reviewed-by: Tatiana Borisova <tatiana.borisova@qt.io>
Add the missing include directory to workaround QTBUG-115499.
Make sure that '$<TARGET_PROPERTY' genex is evaluated for
_protobuf_registration targets.
TODO: Extra include directories should be removed since they might
lead to ambiguous include records if .proto files contain messages
with same name but in different protobuf packages.
Fixes: QTBUG-114077
Task-number: QTBUG-115499
Pick-to: 6.6
Change-Id: Ifb9002435b20034967f202a5dc94ec51a3704f64
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Reviewed-by: Konrad Kujawa <konrad.kujawa@qt.io>
This approach allows reusing the existing backing target if it's
library and makes step towards plugin-less Qml module.
Pick-to: 6.6
Task-number: QTBUG-115117
Change-Id: I02243d700683ac9e01c1471c3ccccaae71841165
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Move the logic that is unreleated to the pre-parsing of the .proto
files to the qt6_add_protobuf function. This leave the single
responsibility for _qt_internal_protobuf_preparse_proto_files and
unlocks the file manipulations for the furter Qml API improvements.
Pick-to: 6.6
Task-number: QTBUG-114077
Task-number: QTBUG-104513
Change-Id: I9d18fbb5d26be1ffb19844cb7d7c3f8736136a76
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
BUILD_SHARED_LIBS cmake flag usually indicates the type of library
that will be created by the cmake add_library call. This solution
doesn't work with _qt_internal_add_library since the logic of library
creation differs there.
Instead of predicting, let's rely on creation result.
Pick-to: 6.6 6.5
Change-Id: Ie983b30377f1e0f3f42fdbb1a6dc8ec340770ee5
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Make sure that TARGET_PROPERTY will be properly
evaluated as recursive generator expression.
Pick-to: 6.5 6.6
Change-Id: Ia51f01a386c97ef543b44393081db693dd07a334
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Tatiana Borisova <tatiana.borisova@qt.io>
Reviewed-by: Konrad Kujawa <konrad.kujawa@qt.io>
In case of generating Qt protobuf source code with QML argument,
QML plugin will be created and included into Application build tree.
New QML_URI option is introduced. If there is no package name,
qtprotobufgen must request the QML_URI setting.
Also, it is possible to link several *.proto files to the same plugin
via common URI.
Add nopackage auto-test. Update protobufgen auto-test.
Remove the usage of RESOURCE_PREFIX, replaced by qt_policy.
Task-number: QTBUG-104513
Change-Id: If5c5496245144fa2b499730ab9fdf7d0ee7b2c25
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
Reviewed-by: Konrad Kujawa <konrad.kujawa@qt.io>
Fix the function arguments processing. Both generated_files and
generation_options were visible because of scope visibility and
were not processed by _qt_internal_protoc_generate correctly.
Fix this by using and processing arguments the proper way.
Pick-to: 6.5
Change-Id: I1eaad92cecfd9d8b415ec2d06cb947979d6baba6
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
QtProtobufgen registers global and local enums in QML context now.
Registration is in qml extension plugin part.
Task-number: QTBUG-104513
Change-Id: Iecbc08d4b915113e7d5753b1f1d24d3c34088ba2
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Enable QML flag for qtgrpcgen/qtprotobufgen plugins.
Generated output is updated: QProtobufMessage classes are Q_GADGETs,
such classes can be registered in QML code via QML_VALUE_TYPE macros only.
Also QProtobufMessages are not inherited from QObject class, it means
there is no full qmetaobject system support (no signals!).
Task-number: QTBUG-104513
Change-Id: I18c8f93782884efb8d923843df716ff8284ed8fb
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
The CMake list(JOIN command doesn't expand the generator expressions
before merging the list. This leads to the situation when generator
expressions that are empty string after the evaluation put an empty
-I argument to a protoc command line. Using '$<JOIN ' generator
expression we avoid this situation since list will be assembled into
argument only after evauation of the all nested genertor expressions.
Pick-to: 6.5
Change-Id: Ibbb141a46e89bb71c6f6151c70b7ec754b44355f
Reviewed-by: Tatiana Borisova <tatiana.borisova@qt.io>
Reviewed-by: Amir Masoud Abdol <amir.abdol@qt.io>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
This should be done by the qt_add_protobuf/grpc functions caller
instead. Otherwise this could break exising deployment rules, like it
happens for qt protobuf modules.
Amends 326ebfaadb
Pick-to: 6.5
Change-Id: I79e562cf1a0041b4bf7fc550b69dfa7fa41cb862
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
protoc doesn't check if file content is changed when writing data to
a generated file. This triggers rebuild of all the generated source
files even after minor changes in qtprotobuf/qtgrpcgen code. Use a
temporary output directory for the files generated by protoc and
copy them to a real output directory only if they are different from
previously generated files. This trick avoids rebuilding all the
generated source files that are not changed when debugging
qtprotobuf/qtgrpcgen.
The introduced behavior doesn't work if the generator executable is
imported or can be suppressed by setting the
QT_INTERNAL_AVOID_USING_PROTOBUF_TMP_OUTPUT_DIR option when configuring
qtgrpc repo.
Pick-to: 6.5
Change-Id: I8acbc3528298ecf3a266a7a0e33c34c3fb8e6527
Reviewed-by: Konrad Kujawa <konrad.kujawa@qt.io>
Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
As user may want to use generator expressions like in PROTO_INCLUDES
argument we need to add their evaluation before passing the merged
list to the command line.
Pick-to: 6.5
Change-Id: I4ab41ee42ff051e76882eac696af5eed315359c9
Reviewed-by: Tatiana Borisova <tatiana.borisova@qt.io>
Reviewed-by: Konrad Kujawa <konrad.kujawa@qt.io>
Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
QtGrpc provides support for serializing and deserializing
gRPC services using Qt.
The tool was originally written by Alexey Edelev, along with various
contributors, on GitHub. Originally under MIT license, but major
contributors have agreed to relicense the code under GPL/commercial for
inclusion in tools for Qt. Their copyright notice is retained and
the original source code, still licensed as MIT, can be found in its
original repository[0].
[0]: https://github.com/semlanik/qtprotobuf
Change-Id: Id29e70df1249e9369fbfaa2c543f3ff29efbdbea
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
Reviewed-by: Tatiana Borisova <tatiana.borisova@qt.io>
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
Rename:
FOLDER option to GENERATE_PACKAGE_SUBFOLDERS
COMMENTS option to COPY_COMMENTS
OUT_GENERATED_HEADERS option to OUTPUT_HEADERS
OUT_GENERATED_TARGETS option to OUTPUT_TARGETS
Adjust and cleanup the corresponding documentation.
Change-Id: I2fdeaaba89257c8bbca4389a08119abf3158702f
Reviewed-by: Konrad Kujawa <konrad.kujawa@qt.io>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Oneof fields depend on the enum that contains field numbers. Enable
the option by default.
Change-Id: I4d5dd63f328d26bdce15d6310489c4146fbf5c0d
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
The protoc tool has the generic mechanisms for plugin option handling.
The plugin-specific options can be specified using the
--<plugin_name>_opt argument or by prepending options to the
--<plugin_name>_out argument with colon separator. In both cases
options need to be separated by semicolon. Add the processing of this
argument to generator and use --<plugin_name>_opt as the default one
in CMake API. Also adjust format of the QT_PROTOBUF_OPTIONS environment
variable to make them consistent.
Change-Id: I269ca7b9b2a952d0d30b18cb57c1465ae261c83a
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
The generator generates Qt-based classes to be used in conjunction with
'QProtobuf' (separate patch).
qtprotobufgen works as an extension to the protoc tool from Google, and
thus also depends on its libraries for building.
The tool was originally written by Alexey Edelev, along with various
contributors, on GitHub. Originally under MIT license, but major
contributors have agreed to relicense the code under GPL/commercial for
inclusion in tools for Qt. Their copyright notice is retained and
the original source code, still licensed as MIT, can be found in its
original repository[0].
[0]: https://github.com/semlanik/qtprotobuf
Done-with: Alexey Edelev <alexey.edelev@qt.io>
Change-Id: I0d5f3d722cb98bca70fc0d4544ed840edb27430c
Reviewed-by: Alex Blasche <alexander.blasche@qt.io>
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
Reviewed-by: Tatiana Borisova <tatiana.borisova@qt.io>