Remove the redundant usage of Qt from SimpleVehicleServer

The example server doesn't really need to use Qt. Remove the
dependency on Qt Core.

Pick-to: 6.8
Change-Id: I8b64e9765f529baa1bcf041a801723ceaed85334
Reviewed-by: Dennis Oberst <dennis.oberst@qt.io>
This commit is contained in:
Alexey Edelev 2024-09-24 01:05:20 +02:00
parent 90334a0f6c
commit faa7b32ebc
3 changed files with 4 additions and 9 deletions

View File

@ -8,7 +8,6 @@ set(CMAKE_FIND_PACKAGE_PREFER_CONFIG TRUE)
# Qt6::Grpc module is not used directly in this project. But this allows to find Qt6::Grpc's
# dependencies without setting extra cmake module paths.
find_package(Qt6 COMPONENTS Core)
find_package(protobuf)
find_package(gRPC)
@ -54,7 +53,7 @@ add_custom_command(
set_source_files_properties(${generated_files} PROPERTIES GENERATED TRUE)
qt_add_executable(SimpleVehicleServer
add_executable(SimpleVehicleServer
${generated_files}
${CMAKE_CURRENT_LIST_DIR}/serverrunner.cpp
${CMAKE_CURRENT_LIST_DIR}/serverrunner.h
@ -69,7 +68,6 @@ target_include_directories(SimpleVehicleServer
target_link_libraries(SimpleVehicleServer PRIVATE
protobuf::libprotobuf
gRPC::grpc++
Qt6::Core
)
install(TARGETS SimpleVehicleServer

View File

@ -3,8 +3,6 @@
#include "serverrunner.h"
#include <QtCore/QCoreApplication>
#include <memory>
int main()

View File

@ -5,11 +5,10 @@
#include "naviservice.grpc.pb.h"
#include "vehicleservice.grpc.pb.h"
#include <QtCore/QDebug>
#include <QtCore/QThread>
#include <grpc++/grpc++.h>
#include <chrono>
#include <iostream>
#include <memory>
#include <thread>
@ -146,10 +145,10 @@ void VehicleServer::run()
std::unique_ptr<grpc::Server> server(builder.BuildAndStart());
if (!server) {
qWarning() << "Creating grpc::Server failed.";
std::cout << "Creating grpc::Server failed." << std::endl;
return;
}
qDebug() << "Server listening on " << serverUri;
std::cout << "Server listening on " << serverUri << std::endl;
server->Wait();
}