Qt6 GRPC의 CMake 명령어

프로젝트에서 Qt6::Grpc 모듈을 사용하려면 다음 CMake 명령을 호출해야 합니다:

find_package(Qt6 REQUIRED COMPONENTS Grpc)

target_link_libraries(mytarget PRIVATE Qt6::Grpc)

프로젝트에 대한 Qt GRPC 코드 생성을 암시적으로 호출하기 위해 qt_add_grpc CMake 명령을 사용할 수 있습니다.

생성하려면 gRPCQt 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 함수를 호출하여 제공된 프로토뷰 스키마 내의 service 섹션에 대한 Qt GRPC 코드 생성을 시작합니다.

참고: protobuf 스키마에 message 정의도 포함된 경우 qt_add_protobuf() CMake 함수도 호출하여 Qt Protobuf 코드 생성을 시작해야 합니다.

실행 가능한 대상을 재사용하므로 생성된 모든 파일이 대상에 추가되고 그에 따라 포함 디렉터리가 업데이트됩니다.

CMake 명령 참조도참조 하세요.

qt_add_grpc

Qt 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.