From 542f837fa2bc5d6009e966c7fa9d7909cef22d2d Mon Sep 17 00:00:00 2001 From: Joerg Bornemann Date: Fri, 2 Sep 2022 12:53:40 +0200 Subject: [PATCH] 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 --- src/corelib/Qt6CoreDeploySupport.cmake | 2 +- src/corelib/Qt6CoreMacros.cmake | 2 +- .../doc/src/cmake/qt_deploy_runtime_dependencies.qdoc | 9 ++++----- 3 files changed, 6 insertions(+), 7 deletions(-) diff --git a/src/corelib/Qt6CoreDeploySupport.cmake b/src/corelib/Qt6CoreDeploySupport.cmake index 6db33d2609..24ddc47bcb 100644 --- a/src/corelib/Qt6CoreDeploySupport.cmake +++ b/src/corelib/Qt6CoreDeploySupport.cmake @@ -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 ".") diff --git a/src/corelib/Qt6CoreMacros.cmake b/src/corelib/Qt6CoreMacros.cmake index 3d7b911827..aefcc34838 100644 --- a/src/corelib/Qt6CoreMacros.cmake +++ b/src/corelib/Qt6CoreMacros.cmake @@ -2647,7 +2647,7 @@ qt6_deploy_runtime_dependencies( qt6_generate_deploy_script(${generate_args} CONTENT " qt6_deploy_runtime_dependencies( - EXECUTABLE \${QT_DEPLOY_BIN_DIR}/$ + EXECUTABLE $ GENERATE_QT_CONF )") diff --git a/src/corelib/doc/src/cmake/qt_deploy_runtime_dependencies.qdoc b/src/corelib/doc/src/cmake/qt_deploy_runtime_dependencies.qdoc index 6f950b4020..f199e62594 100644 --- a/src/corelib/doc/src/cmake/qt_deploy_runtime_dependencies.qdoc +++ b/src/corelib/doc/src/cmake/qt_deploy_runtime_dependencies.qdoc @@ -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}/$}. -Specifying raw target names not wrapped in a generator epxression like -\c{} 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{$}. Specifying raw target names not wrapped in +a generator expression like \c{} 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.