CMake: Make qt-internal-configure-tests relocatable

It's important for conan CI builds where the correct installation
location of Qt should be used when configuring standalone tests.

Task-number: QTBUG-93037
Change-Id: I2465a439aea6826dedfb3217d1c909ad639d4ac0
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
This commit is contained in:
Alexandru Croitor 2021-04-26 15:45:29 +02:00
parent d81a9206ac
commit adf29329ea
4 changed files with 34 additions and 16 deletions

View File

@ -3,6 +3,7 @@ qt_path_join(__GlobalConfig_build_dir ${QT_CONFIG_BUILD_DIR} ${__GlobalConfig_pa
qt_path_join(__GlobalConfig_install_dir ${QT_CONFIG_INSTALL_DIR} ${__GlobalConfig_path_suffix})
set(__GlobalConfig_install_dir_absolute "${__GlobalConfig_install_dir}")
set(__qt_bin_dir_absolute "${QT_INSTALL_DIR}/${INSTALL_BINDIR}")
set(__qt_libexec_dir_absolute "${QT_INSTALL_DIR}/${INSTALL_LIBEXECDIR}")
if(QT_WILL_INSTALL)
# Need to prepend the install prefix when doing prefix builds, because the config install dir
# is relative then.
@ -11,6 +12,8 @@ if(QT_WILL_INSTALL)
${__GlobalConfig_install_dir_absolute})
qt_path_join(__qt_bin_dir_absolute
${QT_BUILD_INTERNALS_RELOCATABLE_INSTALL_PREFIX} ${__qt_bin_dir_absolute})
qt_path_join(__qt_libexec_dir_absolute
${QT_BUILD_INTERNALS_RELOCATABLE_INSTALL_PREFIX} ${__qt_libexec_dir_absolute})
endif()
# Compute relative path from $qt_prefix/bin dir to global CMake config install dir, to use in the
# unix-y qt-cmake shell script, to make it work even if the installed Qt is relocated.

View File

@ -138,24 +138,28 @@ function(qt_internal_create_qt_configure_tests_wrapper_script)
#
# The script takes a path to the repo for which the standalone tests will be configured.
set(script_name "qt-internal-configure-tests")
set(qt_cmake_path
"${QT_STAGING_PREFIX}/${INSTALL_BINDIR}/qt-cmake")
set(common_args "-DQT_BUILD_STANDALONE_TESTS=ON")
set(script_passed_args "-DQT_BUILD_STANDALONE_TESTS=ON")
file(RELATIVE_PATH relative_path_from_libexec_dir_to_bin_dir
${__qt_libexec_dir_absolute}
${__qt_bin_dir_absolute})
file(TO_NATIVE_PATH "${relative_path_from_libexec_dir_to_bin_dir}"
relative_path_from_libexec_dir_to_bin_dir)
if(CMAKE_HOST_UNIX)
set(script_os_prelude "#!/bin/sh")
string(PREPEND qt_cmake_path "exec ")
set(script_passed_args "${common_args} \"$@\"")
else()
set(script_os_prelude "@echo off")
string(APPEND script_name ".bat")
string(APPEND qt_cmake_path ".bat")
set(script_passed_args "${common_args} %*")
endif()
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/libexec/qt-internal-configure-tests.in"
"${QT_BUILD_DIR}/${INSTALL_LIBEXECDIR}/${script_name}")
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/libexec/${script_name}.in"
"${QT_BUILD_DIR}/${INSTALL_LIBEXECDIR}/${script_name}" @ONLY)
qt_install(PROGRAMS "${QT_BUILD_DIR}/${INSTALL_LIBEXECDIR}/${script_name}"
DESTINATION "${INSTALL_LIBEXECDIR}")
else()
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/libexec/${script_name}.bat.in"
"${QT_BUILD_DIR}/${INSTALL_LIBEXECDIR}/${script_name}.bat" @ONLY)
qt_install(PROGRAMS "${QT_BUILD_DIR}/${INSTALL_LIBEXECDIR}/${script_name}.bat"
DESTINATION "${INSTALL_LIBEXECDIR}")
endif()
endfunction()
function(qt_internal_install_android_helper_scripts)

View File

@ -0,0 +1,9 @@
@echo off
setlocal ENABLEDELAYEDEXPANSION ENABLEEXTENSIONS
set script_dir_path=%~dp0
set script_dir_path=%script_dir_path:~0,-1%
set cmake_scripts_dir=%script_dir_path%
call "%script_dir_path%"\"@relative_path_from_libexec_dir_to_bin_dir@"\qt-cmake.bat ^
@script_passed_args@ %*

View File

@ -1,3 +1,5 @@
@script_os_prelude@
#!/bin/sh
script_dir_path=`dirname $0`
script_dir_path=`(cd "$script_dir_path"; /bin/pwd)`
@qt_cmake_path@ @script_passed_args@
"$script_dir_path/@relative_path_from_libexec_dir_to_bin_dir@/qt-cmake" @script_passed_args@ "$@"