Qt6 GRPCのCMakeコマンド
プロジェクトでQt6::Grpcモジュールを使用するには、以下のCMakeコマンドを呼び出す必要があります:
find_package(Qt6 REQUIRED COMPONENTS Grpc) target_link_libraries(mytarget PRIVATE Qt6::Grpc)
qt_add_grpcCMake コマンドを使用すると、暗黙的にQt GRPC のコード生成を呼び出すことができます。
Qt6::Grpcモジュールをプロジェクトで使用するには gRPC™Qt GRPC サービスを生成してプログラムにリンクするには、次の例を考えてみてください:
cmake_minimum_required(VERSION 3.16...3.22) project(MyProject) find_package(Qt6 REQUIRED COMPONENTS Protobuf Grpc) qt_standard_project_setup() qt_add_executable(MyApp main.cpp) qt_add_protobuf(MyApp PROTO_FILES path/to/messages.proto ) qt_add_grpc(MyApp CLIENT PROTO_FILES path/to/service.proto ) target_link_libraries(MyApp PRIVATE Qt6::Protobuf Qt6::Grpc)
上記の例では、qt_add_grpc()
CMake 関数を呼び出して、指定された protobuf スキーマ内のservice
セクションに対してQt GRPC コード生成を開始しています。
注: protobufスキーマにmessage
定義も含まれている場合は、qt_add_protobuf()
CMake関数も呼び出して、Qt Protobuf コード生成を開始する必要があります。
実行可能ターゲットを再利用するので、生成されたファイルはすべてターゲットに追加され、インクルードディレクトリもそれに応じて更新されます。
CMakeコマンドリファレンスも参照してください 。
Protobuf スキーマを使用して Qt ベースの C++ サービスを生成します。 |
© 2025 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.