CMake: Don't reset install prefix upon standalone test reconfiguration

CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT might be empty on the
first configuration, but because QtBuildInternalsExtra sets the
CMAKE_INSTALL_PREFIX, a second reconfiguration of a test would
stop setting the fake install prefix.

After some further consideration, there's no need to set the local
fake prefix conditionally, we can always do it (unless explicitly
opted out).

This makes sure that a reconfiguration of a test doesn't suddenly
install into the Qt prefix again.

Amends 37b132cd4e081821ddc261d24abe8f914123547a

Task-number: QTBUG-84346
Change-Id: Ic61aefe18418658455d8cdb9ebe6bcbcb8d67c99
Reviewed-by: Cristian Adam <cristian.adam@qt.io>
This commit is contained in:
Alexandru Croitor 2020-06-05 13:46:48 +02:00
parent b12f82018d
commit 2d9c9ab874

View File

@ -302,19 +302,11 @@ endfunction()
function(qt_set_up_fake_standalone_tests_install_prefix)
# Set a fake local (non-cache) CMAKE_INSTALL_PREFIX.
# Needed for standalone tests, we don't want to accidentally install a test into the Qt prefix.
#
# If CMAKE_INSTALL_PREFIX was default initialized, that means it points to something
# like /usr/local which we don't want. Why? When metatype json files are created
# during standalone tests configuration, the folder creation might fail due to missing
# permissions in the /usr/local (which is the wrong place anyway).
#
# If the prefix was specified by the user at the command line, honor it, hoping that the
# user knows what they are doing.
if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
set(new_install_prefix "${CMAKE_BINARY_DIR}/standalone_tests_fake_install_prefix")
else()
set(new_install_prefix "${QT_BACKUP_CMAKE_INSTALL_PREFIX_BEFORE_EXTRA_INCLUDE}")
# Allow opt-out, if a user knows what they're doing.
if(QT_NO_FAKE_STANDALONE_TESTS_INSTALL_PREFIX)
return()
endif()
set(new_install_prefix "${CMAKE_BINARY_DIR}/fake_prefix")
# It's IMPORTANT that this is not a cache variable. Otherwise
# qt_get_standalone_tests_confg_files_path() will not work on re-configuration.