diff --git a/examples/grpc/chat/CMakeLists.txt b/examples/grpc/chat/CMakeLists.txt index d8d6904a..41ceb190 100644 --- a/examples/grpc/chat/CMakeLists.txt +++ b/examples/grpc/chat/CMakeLists.txt @@ -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) diff --git a/examples/grpc/chat/client/CMakeLists.txt b/examples/grpc/chat/client/CMakeLists.txt index f16210f4..ea411aeb 100644 --- a/examples/grpc/chat/client/CMakeLists.txt +++ b/examples/grpc/chat/client/CMakeLists.txt @@ -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}" diff --git a/examples/grpc/chat/server/CMakeLists.txt b/examples/grpc/chat/server/CMakeLists.txt index e253d2cb..ee66d9e1 100644 --- a/examples/grpc/chat/server/CMakeLists.txt +++ b/examples/grpc/chat/server/CMakeLists.txt @@ -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="$" +) + install(TARGETS qtgrpc_chat_server RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}" BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}" diff --git a/examples/grpc/chat/server/main.cpp b/examples/grpc/chat/server/main.cpp index f401f4b1..14e51675 100644 --- a/examples/grpc/chat/server/main.cpp +++ b/examples/grpc/chat/server/main.cpp @@ -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());