CMake: Fix handling of rpaths for tests with CMAKE_STAGING_PREFIX

Task-number: QTBUG-86053
Change-Id: I2f368d9dc2d871b67bd6261aadd8ef4c1dd1ae54
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
This commit is contained in:
Alexandru Croitor 2020-10-23 12:45:10 +02:00
parent 5fa823491b
commit 20292250d4

View File

@ -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