mirror of https://github.com/qt/qtgrpc.git
qtgrpc chat example: fix deployment
The deployment was incomplete. Fix it by:
* Building the dependent qtgrpc_chat_client_proto library as
a static library
* Add the server directory path for reading credentials universally
Amends: cb35d20adb.
Fixes: QTBUG-134266
Pick-to: 6.9.0 6.9 6.8.3 6.8
Change-Id: I0666c445fbce159436c5b084ffd77d4191e04213
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
This commit is contained in:
parent
fb72130351
commit
9437a1f2bd
|
|
@ -4,5 +4,7 @@
|
|||
cmake_minimum_required(VERSION 3.16)
|
||||
project(QtGrpcChat LANGUAGES CXX)
|
||||
|
||||
find_package(Qt6 REQUIRED COMPONENTS Qml) # Needed for deployment
|
||||
|
||||
add_subdirectory(server)
|
||||
add_subdirectory(client)
|
||||
|
|
|
|||
|
|
@ -78,6 +78,7 @@ if(GRPC_CHAT_USE_EMOJI_FONT)
|
|||
endif()
|
||||
|
||||
#! [client-setup-1]
|
||||
add_library(qtgrpc_chat_client_proto STATIC)
|
||||
qt_add_protobuf(qtgrpc_chat_client_proto
|
||||
QML
|
||||
QML_URI QtGrpcChat.Proto
|
||||
|
|
@ -132,7 +133,7 @@ target_link_libraries(qtgrpc_chat_client
|
|||
qtgrpc_chat_client_proto
|
||||
)
|
||||
|
||||
install(TARGETS qtgrpc_chat_client
|
||||
install(TARGETS qtgrpc_chat_client qtgrpc_chat_client_proto
|
||||
RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}"
|
||||
BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}"
|
||||
LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}"
|
||||
|
|
|
|||
|
|
@ -77,6 +77,10 @@ add_executable(qtgrpc_chat_server
|
|||
target_include_directories(qtgrpc_chat_server PRIVATE ${proto_out})
|
||||
target_link_libraries(qtgrpc_chat_server PRIVATE gRPC::grpc++ gRPC::grpc++_reflection)
|
||||
|
||||
target_compile_definitions(qtgrpc_chat_server
|
||||
PRIVATE SERVER_DIR="$<TARGET_FILE_DIR:qtgrpc_chat_server>"
|
||||
)
|
||||
|
||||
install(TARGETS qtgrpc_chat_server
|
||||
RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}"
|
||||
BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}"
|
||||
|
|
|
|||
|
|
@ -374,8 +374,8 @@ int main(int /* argc */, char * /* argv */[])
|
|||
//! [server-ssl]
|
||||
grpc::SslServerCredentialsOptions sslOpts;
|
||||
sslOpts.pem_key_cert_pairs.emplace_back(grpc::SslServerCredentialsOptions::PemKeyCertPair{
|
||||
readFromFile("credentials/localhost.key"),
|
||||
readFromFile("credentials/localhost.crt"),
|
||||
readFromFile(SERVER_DIR "/credentials/localhost.key"),
|
||||
readFromFile(SERVER_DIR "/credentials/localhost.crt"),
|
||||
});
|
||||
builder.AddListeningPort(QtGrpcChatService::httpsAddress(), grpc::SslServerCredentials(sslOpts));
|
||||
builder.AddListeningPort(QtGrpcChatService::httpAddress(), grpc::InsecureServerCredentials());
|
||||
|
|
|
|||
Loading…
Reference in New Issue