Fix DESTDIR support on Windows for versioned hard-links

On Windows, we need to strip drive letter and colon before prepending
DESTDIR when creating our versioned hard links.

This fixes CI submodule updates.

Change-Id: I41bc5f27b714ef74d3fadc4a0fb16c3d8b20da1a
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
(cherry picked from commit 88886f193230292f38987ac4f1503753f50786f0)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
Joerg Bornemann 2021-03-31 11:11:31 +02:00 committed by Qt Cherry-pick Bot
parent f64ccc5f53
commit f584356eef

View File

@ -136,13 +136,25 @@ function(qt_internal_install_versioned_link install_dir target)
return()
endif()
qt_path_join(install_base_file_path "$ENV\{DESTDIR}$\{CMAKE_INSTALL_PREFIX}"
qt_path_join(install_base_file_path "$\{qt_full_install_prefix}"
"${install_dir}" "$<TARGET_FILE_BASE_NAME:${target}>")
set(original "${install_base_file_path}$<TARGET_FILE_SUFFIX:${target}>")
set(linkname "${install_base_file_path}${PROJECT_VERSION_MAJOR}$<TARGET_FILE_SUFFIX:${target}>")
set(code
"message(STATUS \"Creating hard link ${original} -> ${linkname}\")"
"file(CREATE_LINK \"${original}\" \"${linkname}\" COPY_ON_ERROR)")
set(code "set(qt_full_install_prefix \"$\{CMAKE_INSTALL_PREFIX}\")"
" if(NOT \"$ENV\{DESTDIR}\" STREQUAL \"\")"
)
if(CMAKE_HOST_WIN32)
list(APPEND code
" if(qt_full_install_prefix MATCHES \"^[a-zA-Z]:\")"
" string(SUBSTRING \"$\{qt_full_install_prefix}\" 2 -1 qt_full_install_prefix)"
" endif()"
)
endif()
list(APPEND code
" string(PREPEND qt_full_install_prefix \"$ENV\{DESTDIR}\")"
" endif()"
" message(STATUS \"Creating hard link ${original} -> ${linkname}\")"
" file(CREATE_LINK \"${original}\" \"${linkname}\" COPY_ON_ERROR)")
if(QT_GENERATOR_IS_MULTI_CONFIG)
# Wrap the code in a configuration check,