Skip to content

Commit

Permalink
CMake: Make paths in qt-cmake-standalone-test relative
Browse files Browse the repository at this point in the history
Make paths in qt-cmake-standalone-test relative to script's PWD.

Fixes: QTBUG-88380
Change-Id: I6ab507c31ebed391f4e85bc6fe3f7f747dd97d54
Reviewed-by: Alexandru Croitor <[email protected]>
  • Loading branch information
semlanik committed Nov 17, 2020
1 parent 996255b commit 4456ebc
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 15 deletions.
3 changes: 2 additions & 1 deletion bin/qt-cmake-standalone-test.in
Original file line number Diff line number Diff line change
@@ -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@
35 changes: 21 additions & 14 deletions cmake/QtWrapperScriptHelpers.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 4456ebc

Please sign in to comment.