From 20292250d44e08437306096e9096fc655cc9fb8b Mon Sep 17 00:00:00 2001 From: Alexandru Croitor Date: Fri, 23 Oct 2020 12:45:10 +0200 Subject: [PATCH] CMake: Fix handling of rpaths for tests with CMAKE_STAGING_PREFIX Task-number: QTBUG-86053 Change-Id: I2f368d9dc2d871b67bd6261aadd8ef4c1dd1ae54 Reviewed-by: Joerg Bornemann --- cmake/QtBuildInternals/QtBuildInternalsConfig.cmake | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/cmake/QtBuildInternals/QtBuildInternalsConfig.cmake b/cmake/QtBuildInternals/QtBuildInternalsConfig.cmake index 246ee3b17b..40d495d414 100644 --- a/cmake/QtBuildInternals/QtBuildInternalsConfig.cmake +++ b/cmake/QtBuildInternals/QtBuildInternalsConfig.cmake @@ -452,6 +452,18 @@ function(qt_set_up_fake_standalone_tests_install_prefix) message(STATUS "Setting local standalone test install prefix (non-cached) to '${new_install_prefix}'.") set(CMAKE_INSTALL_PREFIX "${new_install_prefix}" PARENT_SCOPE) + + # We also need to clear the staging prefix if it's set, otherwise CMake will modify any computed + # rpaths containing the staging prefix to point to the new fake prefix, which is not what we + # want. This replacement is done in cmComputeLinkInformation::GetRPath(). + # + # By clearing the staging prefix for the standalone tests, any detected link time + # rpaths will be embedded as-is, which will point to the place where Qt was installed (aka + # the staging prefix). + if(DEFINED CMAKE_STAGING_PREFIX) + message(STATUS "Clearing local standalone test staging prefix (non-cached).") + set(CMAKE_STAGING_PREFIX "" PARENT_SCOPE) + endif() endfunction() # Mean to be called when configuring examples as part of the main build tree, as well as for CMake