From 5430fb22439db9fc1ad1df4cbf0319b63346b0a5 Mon Sep 17 00:00:00 2001 From: Joerg Bornemann Date: Thu, 29 Sep 2022 13:06:12 +0200 Subject: CMake: Set RPATH of deployed plugins on Linux When deploying into some directory structure where CMAKE_INSTALL_LIBDIR is different from Qt's lib dir, we need to set the RPATH of installed plugins such that Qt libraries are found. We do this using CMake's undocumented file(RPATH_SET) command and pray that this command is safe to use across current and future CMake versions. For CMake versions < 3.21, we use patchelf, which must be installed on the host system. The adjustment of rpaths can be turned on explicitly by setting QT_DEPLOY_FORCE_ADJUST_RPATHS to ON. The usage of patchelf can be forced by setting QT_DEPLOY_USE_PATCHELF to ON regardless of the CMake version. Change-Id: I62ced496b4c12bf6d46735d2af7ff35130148acb Reviewed-by: Alexandru Croitor --- tests/auto/cmake/CMakeLists.txt | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) (limited to 'tests/auto/cmake/CMakeLists.txt') diff --git a/tests/auto/cmake/CMakeLists.txt b/tests/auto/cmake/CMakeLists.txt index e841308fc8..afc6002ff6 100644 --- a/tests/auto/cmake/CMakeLists.txt +++ b/tests/auto/cmake/CMakeLists.txt @@ -46,6 +46,7 @@ cmake_minimum_required(VERSION 3.16) project(cmake_usage_tests) +include(GNUInstallDirs) # Building the CMake tests as part of a Qt prefix build + in-tree tests, currently doesn't work. # Each CMake test will fail with a message like @@ -335,12 +336,16 @@ set(deploy_args NO_RUN_ENVIRONMENT_PLUGIN_PATH ) -# For now, the test should only pass on Windows and macOS shared and static builds and fail on -# other platforms, because there is no support for runtime dependency deployment -# on those platforms. +set(is_desktop_linux FALSE) +if(UNIX AND NOT APPLE AND NOT ANDROID AND NOT CMAKE_CROSSCOMPILING) + set(is_desktop_linux TRUE) +endif() + +# For now, the test should only pass on Windows, macOS and desktop Linux shared and static builds +# and fail on other platforms, because there is no support for runtime dependency deployment on +# those platforms. # With static builds the runtime dependencies are just skipped, but the test should still pass. -if(WIN32 OR (APPLE AND NOT IOS) - OR (UNIX AND NOT APPLE AND NOT ANDROID AND NOT CMAKE_CROSSCOMPILING)) +if(WIN32 OR (APPLE AND NOT IOS) OR is_desktop_linux) _qt_internal_test_expect_pass(${deploy_args}) else() _qt_internal_test_expect_fail(${deploy_args}) -- cgit v1.2.3