Commit Graph

15 Commits

Author SHA1 Message Date
Dennis Oberst bfa2607a72 GrpcToolsMacros.cmake: continue on invalid files
Previously the helper returned early in case no service section was
found in the proto file. If we supply multiple files, this function
should simply skip those. Otherwise it's not possible to process such a
list variable.

Pick-to: 6.10 6.9 6.8
Change-Id: Iab31fa81404f2df2ec4ad628810ff7f948b3eb5f
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
2025-09-02 15:26:58 +02:00
Alexey Edelev 77fd311761 Add the early return from qt6_add_<protobuf|grpc>
If preparsing of the .proto schemes doesn't detect the definitions
that can be processed by our generators, make the early return
from qt6_add_<protobuf|grpc> with the respective warning message.

We require that provided .proto files contain either message/enum
for protobuf generator or services for the grpc generator.

The warning can be suppressed by setting the
QT_SKIP_PROTOBUF_MISSING_DEFINITIONS_WARNING variable to TRUE.

[ChangeLog][CMake] The qt6_add_protobuf and qt6_add_grpc functions
do not generate CMake targets if provided in PROTO_FILES argument
protobuf schemes do not contain the corresponding for the generator
definitions. qtprotobufgen requires messages or enums, qtgrpcgen
requires services. Functions now make early return and warn about the
missing definitions. Previosly the functions generated unclear
FATAL_ERROR. The QT_SKIP_PROTOBUF_MISSING_DEFINITIONS_WARNING CMake
variable suppresses the warning.

Pick-to: 6.8 6.9
Fixes: QTBUG-132848
Change-Id: I620c2b5bab719a61510c5cbc2ae8224e3df70fcf
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2025-01-28 15:22:24 +01:00
Alexey Edelev 6d28b38872 Error out if Protobuf|GrpcQuick components are not found
QML option of both qt_add_protobuf and qt_add_grpc calls requires
ProtobufQuick and GrpcQuick targets to be found, accordingly.
Currently calls will fail with non-intuitive error that points to
the missing linking dependencies. Trigger a FATAL_ERROR at configure
time and give a hint on how to solve this.

Fixes: QTBUG-131780
Pick-to: 6.8 6.9
Change-Id: I571aa35839a6b68b54f5a71f0ee1947445b5eb2c
Reviewed-by: Dennis Oberst <dennis.oberst@qt.io>
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2025-01-10 14:55:59 +01:00
Dennis Oberst fe9cc6b342 Move the QtProtobuf and QtGrpc modules out of technical preview
We survived the 6.8 API review and, as a result, we’ve been promoted to
first-class Qt citizens. Time to retire the technical-preview label and
let these modules enjoy their new status.

Remove all mentions of technical preview from the module.

Pick-to: 6.8.0 6.8
Change-Id: I0adc9db13f9845119776ea7e2a2f666414bf9620
Reviewed-by:  Alexey Edelev <alexey.edelev@qt.io>
Reviewed-by: Alex Blasche <alexander.blasche@qt.io>
2024-09-13 14:26:58 +02:00
Alexey Edelev 2bed0bc836 Make sure that we require the cpp exports
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>
2024-02-21 11:52:57 +01:00
Alexey Edelev b75bc17c33 Add the missing generating of the C++ exports to the qtgrpcgen
Make the generating of C++ exports common for both generators.
The confilicting generation should be resolved by the tools that
running the generators. Qt CMake API handles this situation.

Fixes: QTBUG-121856
Pick-to: 6.7
Change-Id: Ie2452f52d755ade2909107885dac774ff8678daa
Reviewed-by: Tatiana Borisova <tatiana.borisova@qt.io>
2024-02-06 17:23:19 +01:00
Alexey Edelev ae2f1ed3d3 Fix the generation of the export macro
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>
2024-02-06 06:59:48 +01:00
Alexey Edelev c649de9633 Enable AUTOMOC for Qt GRPC and Qt Protobuf targets unconditionally
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>
2024-01-12 14:44:45 +01:00
Tatiana Borisova 42ce3ecdc5 qtgrpcgen code is updated for QtGrpcQuick plugin usage
Change generates QmlClient class inherited from CPP Client class,
and registers QmlClient in QML;
Also, added QML key usage into qtgrpcgen test,
updated tst_client object name;

Task-number: QTBUG-115184
Task-number: QTBUG-114893
Change-Id: I7b9fcab9c976ae7bc708d29eb14069018b79380b
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
Reviewed-by: Konrad Kujawa <konrad.kujawa@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2023-07-28 14:21:10 +02:00
Alexey Edelev 822d8b12fd Make sure that .proto files are displayed in IDE
Add .proto files using _qt_internal_expose_source_file_to_ide.

Pick-to: 6.5 6.6
Fixes: QTBUG-115057
Change-Id: I5051e4554ba3bc7a7c261de5a1e7b7c503021df1
Reviewed-by: Konrad Kujawa <konrad.kujawa@qt.io>
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2023-07-27 11:55:23 +02:00
Alexey Edelev 66e5efc5ec Use the type of the created protobuf/grpc library but don't predict it
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>
2023-07-06 18:37:30 +02:00
Alexey Edelev 0b14713b1e Fix arguments for _qt_internal_protoc_generate
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>
2023-05-31 17:01:53 +02:00
Konrad Kujawa 70033adc96 Add missing handling of MODULE_LIBRARY in qt6_add_grpc() CMake method
Handle MODULE_LIBRARY target type in the qt6_add_grpc() CMake method.
The same behavior exists in the qt6_add_protobuf() and it seems missing
int the GRPC counterpart.
It fixed calls to the method in the Android environment, for example
building GRPC examples.

Pick-to: 6.5 6.5.0
Change-Id: I947587f8942dcfcced62029e39b3385e842d7933
Reviewed-by: Tatiana Borisova <tatiana.borisova@qt.io>
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2023-03-20 12:20:19 +01:00
Alexey Edelev 227557ad36 Avoid adding the generated header files to PUBLIC_HEADERS by default
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>
2023-02-02 18:28:11 +01:00
Tatiana Borisova 326ebfaadb QtGrpc: Update code generator to generate gRPC structures
Split the .proto files generator into QtProtobuf and QtGrpc parts.

Pick-to: 6.5
Task-number: QTBUG-105496
Change-Id: Ib43abe4c1fb849ecf68952b82af9d3988e88e02a
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
2023-01-11 12:04:11 +01:00