Skip to content

Commit adf2932

Browse files
committed
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>
1 parent d81a920 commit adf2932

4 files changed

+34
-16
lines changed

cmake/QtBaseGlobalTargets.cmake

+3
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ qt_path_join(__GlobalConfig_build_dir ${QT_CONFIG_BUILD_DIR} ${__GlobalConfig_pa
33
qt_path_join(__GlobalConfig_install_dir ${QT_CONFIG_INSTALL_DIR} ${__GlobalConfig_path_suffix})
44
set(__GlobalConfig_install_dir_absolute "${__GlobalConfig_install_dir}")
55
set(__qt_bin_dir_absolute "${QT_INSTALL_DIR}/${INSTALL_BINDIR}")
6+
set(__qt_libexec_dir_absolute "${QT_INSTALL_DIR}/${INSTALL_LIBEXECDIR}")
67
if(QT_WILL_INSTALL)
78
# Need to prepend the install prefix when doing prefix builds, because the config install dir
89
# is relative then.
@@ -11,6 +12,8 @@ if(QT_WILL_INSTALL)
1112
${__GlobalConfig_install_dir_absolute})
1213
qt_path_join(__qt_bin_dir_absolute
1314
${QT_BUILD_INTERNALS_RELOCATABLE_INSTALL_PREFIX} ${__qt_bin_dir_absolute})
15+
qt_path_join(__qt_libexec_dir_absolute
16+
${QT_BUILD_INTERNALS_RELOCATABLE_INSTALL_PREFIX} ${__qt_libexec_dir_absolute})
1417
endif()
1518
# Compute relative path from $qt_prefix/bin dir to global CMake config install dir, to use in the
1619
# unix-y qt-cmake shell script, to make it work even if the installed Qt is relocated.

cmake/QtWrapperScriptHelpers.cmake

+18-14
Original file line numberDiff line numberDiff line change
@@ -138,24 +138,28 @@ function(qt_internal_create_qt_configure_tests_wrapper_script)
138138
#
139139
# The script takes a path to the repo for which the standalone tests will be configured.
140140
set(script_name "qt-internal-configure-tests")
141-
set(qt_cmake_path
142-
"${QT_STAGING_PREFIX}/${INSTALL_BINDIR}/qt-cmake")
143141

144-
set(common_args "-DQT_BUILD_STANDALONE_TESTS=ON")
142+
set(script_passed_args "-DQT_BUILD_STANDALONE_TESTS=ON")
143+
144+
file(RELATIVE_PATH relative_path_from_libexec_dir_to_bin_dir
145+
${__qt_libexec_dir_absolute}
146+
${__qt_bin_dir_absolute})
147+
file(TO_NATIVE_PATH "${relative_path_from_libexec_dir_to_bin_dir}"
148+
relative_path_from_libexec_dir_to_bin_dir)
149+
145150
if(CMAKE_HOST_UNIX)
146-
set(script_os_prelude "#!/bin/sh")
147-
string(PREPEND qt_cmake_path "exec ")
148-
set(script_passed_args "${common_args} \"$@\"")
151+
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/libexec/${script_name}.in"
152+
"${QT_BUILD_DIR}/${INSTALL_LIBEXECDIR}/${script_name}" @ONLY)
153+
154+
qt_install(PROGRAMS "${QT_BUILD_DIR}/${INSTALL_LIBEXECDIR}/${script_name}"
155+
DESTINATION "${INSTALL_LIBEXECDIR}")
149156
else()
150-
set(script_os_prelude "@echo off")
151-
string(APPEND script_name ".bat")
152-
string(APPEND qt_cmake_path ".bat")
153-
set(script_passed_args "${common_args} %*")
157+
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/libexec/${script_name}.bat.in"
158+
"${QT_BUILD_DIR}/${INSTALL_LIBEXECDIR}/${script_name}.bat" @ONLY)
159+
160+
qt_install(PROGRAMS "${QT_BUILD_DIR}/${INSTALL_LIBEXECDIR}/${script_name}.bat"
161+
DESTINATION "${INSTALL_LIBEXECDIR}")
154162
endif()
155-
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/libexec/qt-internal-configure-tests.in"
156-
"${QT_BUILD_DIR}/${INSTALL_LIBEXECDIR}/${script_name}")
157-
qt_install(PROGRAMS "${QT_BUILD_DIR}/${INSTALL_LIBEXECDIR}/${script_name}"
158-
DESTINATION "${INSTALL_LIBEXECDIR}")
159163
endfunction()
160164

161165
function(qt_internal_install_android_helper_scripts)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
@echo off
2+
setlocal ENABLEDELAYEDEXPANSION ENABLEEXTENSIONS
3+
set script_dir_path=%~dp0
4+
set script_dir_path=%script_dir_path:~0,-1%
5+
6+
set cmake_scripts_dir=%script_dir_path%
7+
8+
call "%script_dir_path%"\"@relative_path_from_libexec_dir_to_bin_dir@"\qt-cmake.bat ^
9+
@script_passed_args@ %*
+4-2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1-
@script_os_prelude@
1+
#!/bin/sh
2+
script_dir_path=`dirname $0`
3+
script_dir_path=`(cd "$script_dir_path"; /bin/pwd)`
24

3-
@qt_cmake_path@ @script_passed_args@
5+
"$script_dir_path/@relative_path_from_libexec_dir_to_bin_dir@/qt-cmake" @script_passed_args@ "$@"

0 commit comments

Comments
 (0)