Avoid using the relative path to the server executable in client guide

It's not necessary that the server executable is located and named
always the same. We may try to hijack this using various CMake
OUTPUT tricks, but it's easier to utilize the actual file path in
the client executable using definition.

Amends dedd3edd3f

Pick-to: 6.8 6.9
Task-number: QTBUG-125406
Change-Id: Ice60e22caa6c5c14024f57fe133f2268ad96f574
Reviewed-by: Dennis Oberst <dennis.oberst@qt.io>
This commit is contained in:
Alexey Edelev 2025-01-17 15:18:30 +01:00
parent a379d0c185
commit c3ee8ef3a6
2 changed files with 4 additions and 1 deletions

View File

@ -21,6 +21,9 @@ qt_add_grpc(clientguide_client CLIENT
target_link_libraries(clientguide_client PRIVATE Qt6::Protobuf Qt6::Grpc)
#! [0]
target_compile_definitions(clientguide_client PRIVATE
SERVER_PATH="$<TARGET_FILE:clientguide_server>")
install(TARGETS clientguide_client
RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}"
BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}"

View File

@ -243,7 +243,7 @@ void startServerProcess()
});
serverProcess.setProcessChannelMode(QProcess::MergedChannels);
serverProcess.setReadChannel(QProcess::StandardOutput);
serverProcess.start("./clientguide_server");
serverProcess.start(SERVER_PATH);
if (!serverProcess.waitForStarted()) {
qFatal() << "Couldn't start the server: " << serverProcess.errorString();
exit(EXIT_FAILURE);