summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlexandru Croitor <alexandru.croitor@qt.io>2021-04-26 15:45:29 +0200
committerAlexandru Croitor <alexandru.croitor@qt.io>2021-04-26 23:11:28 +0200
commitadf29329ead34e4fa805ef19370b2e5172bd61e0 (patch)
treecc9fd378c2748b5ef302912dcc0f41ab85b82eae
parentd81a9206ac528ad7b5093305d7fe0037053468b8 (diff)
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>
-rw-r--r--cmake/QtBaseGlobalTargets.cmake3
-rw-r--r--cmake/QtWrapperScriptHelpers.cmake32
-rw-r--r--libexec/qt-internal-configure-tests.bat.in9
-rwxr-xr-xlibexec/qt-internal-configure-tests.in6
4 files changed, 34 insertions, 16 deletions
diff --git a/cmake/QtBaseGlobalTargets.cmake b/cmake/QtBaseGlobalTargets.cmake
index df0be95510..a1f81ecb90 100644
--- a/cmake/QtBaseGlobalTargets.cmake
+++ b/cmake/QtBaseGlobalTargets.cmake
@@ -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.
diff --git a/cmake/QtWrapperScriptHelpers.cmake b/cmake/QtWrapperScriptHelpers.cmake
index 14958d2ce6..cee9bfd1ed 100644
--- a/cmake/QtWrapperScriptHelpers.cmake
+++ b/cmake/QtWrapperScriptHelpers.cmake
@@ -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} \"$@\"")
+ 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()
- set(script_os_prelude "@echo off")
- string(APPEND script_name ".bat")
- string(APPEND qt_cmake_path ".bat")
- set(script_passed_args "${common_args} %*")
+ 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()
- configure_file("${CMAKE_CURRENT_SOURCE_DIR}/libexec/qt-internal-configure-tests.in"
- "${QT_BUILD_DIR}/${INSTALL_LIBEXECDIR}/${script_name}")
- qt_install(PROGRAMS "${QT_BUILD_DIR}/${INSTALL_LIBEXECDIR}/${script_name}"
- DESTINATION "${INSTALL_LIBEXECDIR}")
endfunction()
function(qt_internal_install_android_helper_scripts)
diff --git a/libexec/qt-internal-configure-tests.bat.in b/libexec/qt-internal-configure-tests.bat.in
new file mode 100644
index 0000000000..dd2b0cc9c4
--- /dev/null
+++ b/libexec/qt-internal-configure-tests.bat.in
@@ -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@ %*
diff --git a/libexec/qt-internal-configure-tests.in b/libexec/qt-internal-configure-tests.in
index 396cda7bf8..d0bf333ee6 100755
--- a/libexec/qt-internal-configure-tests.in
+++ b/libexec/qt-internal-configure-tests.in
@@ -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@ "$@"