CMake: Clarify qt_deploy_runtime_dependencies' EXECUTABLE argument

In a subsequent commit we will add Linux support for
qt_deploy_runtime_dependencies based on file(GET_RUNTIME_DEPENDENCIES).

The file(GRD) command expects that we pass the not-yet-installed
executable to it, because the command reads the RUNPATH/RPATH from the
executable and resolves libraries against these paths.  This resolution
is likely going to fail if file(GRD) is run on an installed executable,
because the RPATH was modified to be relocatable in the installation
phase.

This patch adds a recommendation to use the build directory's executable
for qt_deploy_runtime_dependencies on non-macOS platforms.

Also, the Windows code path of qt_deploy_runtime_dependencies is
adjusted to support both, the .exe in the build dir and the .exe in the
installation prefix.

For consistency, qt_generate_deploy_app_script calls
qt_deploy_runtime_dependencies with EXECUTABLE pointing to the build
directory's executable.

[ChangeLog][CMake] On non-macOS platforms,
qt_deploy_runtime_dependencies' EXECUTABLE argument now expects the
executable in the build directory instead of the installation directory.

Change-Id: Id76b52cc5a0f285586679d7ae600a8c7996429c1
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
This commit is contained in:
Joerg Bornemann 2022-09-02 12:53:40 +02:00
parent c288733541
commit 542f837fa2
3 changed files with 6 additions and 7 deletions

View File

@ -173,7 +173,7 @@ function(qt6_deploy_runtime_dependencies)
set(arg_EXECUTABLE "${CMAKE_MATCH_1}")
endif()
elseif(arg_GENERATE_QT_CONF)
get_filename_component(exe_dir "${arg_EXECUTABLE}" DIRECTORY)
set(exe_dir "${QT_DEPLOY_BIN_DIR}")
if(exe_dir STREQUAL "" OR exe_dir STREQUAL ".")
set(exe_dir ".")
set(prefix ".")

View File

@ -2647,7 +2647,7 @@ qt6_deploy_runtime_dependencies(
qt6_generate_deploy_script(${generate_args}
CONTENT "
qt6_deploy_runtime_dependencies(
EXECUTABLE \${QT_DEPLOY_BIN_DIR}/$<TARGET_FILE_NAME:${arg_TARGET}>
EXECUTABLE $<TARGET_FILE:${arg_TARGET}>
GENERATE_QT_CONF
)")

View File

@ -58,11 +58,10 @@ see \l{qt_deploy_qml_imports()} for that.
The \c{EXECUTABLE} option must be provided.
The \c{executable} argument should be a path to the executable file, relative to
the base install location. For example, \c{bin/MyApp.exe}, or more dynamically
\c{\${QT_DEPLOY_BIN_DIR}/$<TARGET_FILE_NAME:MyApp>}.
Specifying raw target names not wrapped in a generator epxression like
\c{<TARGET_FILE_NAME:>} is not supported.
The \c{executable} argument should be the path to the executable file in the
build directory. For example, \c{${CMAKE_CURRENT_BINARY_DIR}/MyApp.exe}, or more
dynamically \c{$<TARGET_FILE:MyApp>}. Specifying raw target names not wrapped in
a generator expression like \c{<TARGET_FILE:>} is not supported.
For macOS app bundles, the \c{executable} argument should be a path to the
bundle directory, relative to the base install location.