From 4456ebc1e33684d506f45ff3a3cb2f90b747a696 Mon Sep 17 00:00:00 2001 From: Alexey Edelev Date: Fri, 13 Nov 2020 18:46:49 +0100 Subject: [PATCH] CMake: Make paths in qt-cmake-standalone-test relative Make paths in qt-cmake-standalone-test relative to script's PWD. Fixes: QTBUG-88380 Change-Id: I6ab507c31ebed391f4e85bc6fe3f7f747dd97d54 Reviewed-by: Alexandru Croitor --- bin/qt-cmake-standalone-test.in | 3 ++- cmake/QtWrapperScriptHelpers.cmake | 35 ++++++++++++++++++------------ 2 files changed, 23 insertions(+), 15 deletions(-) diff --git a/bin/qt-cmake-standalone-test.in b/bin/qt-cmake-standalone-test.in index 91413b21eb..d13c3eee40 100755 --- a/bin/qt-cmake-standalone-test.in +++ b/bin/qt-cmake-standalone-test.in @@ -1,3 +1,4 @@ @__qt_cmake_standalone_test_os_prelude@ -@__qt_cmake_private_path@ @__qt_cmake_standalone_test_path@ -DQT_STANDALONE_TEST_PATH=@__qt_cmake_standalone_passed_args@ +@__qt_cmake_standalone_test_script_relpath@ +@__qt_cmake_private_relpath@ @__qt_cmake_standalone_test_relpath@ -DQT_STANDALONE_TEST_PATH=@__qt_cmake_standalone_passed_args@ diff --git a/cmake/QtWrapperScriptHelpers.cmake b/cmake/QtWrapperScriptHelpers.cmake index 31abfca8b1..b1ae09262c 100644 --- a/cmake/QtWrapperScriptHelpers.cmake +++ b/cmake/QtWrapperScriptHelpers.cmake @@ -68,31 +68,38 @@ function(qt_internal_create_wrapper_scripts) # Instead a template CMakeLists.txt project is used which sets up all the necessary private bits # and then calls add_subdirectory on the provided project path. set(__qt_cmake_standalone_test_bin_name "qt-cmake-standalone-test") - set(__qt_cmake_private_path - "${QT_STAGING_PREFIX}/${INSTALL_BINDIR}/qt-cmake-private") + set(__qt_cmake_standalone_test_bin_path + "${INSTALL_BINDIR}/${__qt_cmake_standalone_test_bin_name}") set(__qt_cmake_standalone_test_path "${__build_internals_install_dir}/${__build_internals_standalone_test_template_dir}") - if(QT_WILL_INSTALL) - # Need to prepend the staging prefix when doing prefix builds, because the build internals - # install dir is relative in that case.. - qt_path_join(__qt_cmake_standalone_test_path - "${QT_STAGING_PREFIX}" - "${__qt_cmake_standalone_test_path}") - endif() + get_filename_component(rel_base_path + "${CMAKE_INSTALL_PREFIX}/${__qt_cmake_standalone_test_bin_path}" + DIRECTORY) + + file(RELATIVE_PATH __qt_cmake_private_relpath "${rel_base_path}" + "${CMAKE_INSTALL_PREFIX}/${INSTALL_BINDIR}/qt-cmake-private") + file(RELATIVE_PATH __qt_cmake_standalone_test_relpath "${rel_base_path}" + "${CMAKE_INSTALL_PREFIX}/${__qt_cmake_standalone_test_path}") + if(CMAKE_HOST_UNIX) set(__qt_cmake_standalone_test_os_prelude "#!/bin/sh") - string(PREPEND __qt_cmake_private_path "exec ") + set(__qt_cmake_standalone_test_script_relpath "SCRIPT_DIR=`dirname $0`") + string(PREPEND __qt_cmake_private_relpath "exec $SCRIPT_DIR/") + string(PREPEND __qt_cmake_standalone_test_relpath "$SCRIPT_DIR/") set(__qt_cmake_standalone_passed_args "\"$@\" -DPWD=\"$PWD\"") else() set(__qt_cmake_standalone_test_os_prelude "@echo off") - string(APPEND __qt_cmake_standalone_test_bin_name ".bat") - string(APPEND __qt_cmake_private_path ".bat") + set(__qt_cmake_standalone_test_script_relpath "set SCRIPT_DIR=%~dp0") + string(APPEND __qt_cmake_standalone_test_bin_path ".bat") + string(APPEND __qt_cmake_private_relpath ".bat") + string(PREPEND __qt_cmake_private_relpath "%SCRIPT_DIR%") + string(PREPEND __qt_cmake_standalone_test_relpath "%SCRIPT_DIR%") set(__qt_cmake_standalone_passed_args "%* -DPWD=\"%CD%\"") endif() configure_file("${CMAKE_CURRENT_SOURCE_DIR}/bin/qt-cmake-standalone-test.in" - "${QT_BUILD_DIR}/${INSTALL_BINDIR}/${__qt_cmake_standalone_test_bin_name}") - qt_install(PROGRAMS "${QT_BUILD_DIR}/${INSTALL_BINDIR}/${__qt_cmake_standalone_test_bin_name}" + "${QT_BUILD_DIR}/${__qt_cmake_standalone_test_bin_path}") + qt_install(PROGRAMS "${QT_BUILD_DIR}/${__qt_cmake_standalone_test_bin_path}" DESTINATION "${INSTALL_BINDIR}") # Create an installation script that the CI can use to handle installation for both