Skip to content

Commit ca24ee1

Browse files
Create the versioned variant of Qt tools in cross platform build
In cross builds, we are not creating versioned links for qt tools. This patch addresses that. I've changed the signature of the `qt_internal_install_versioned_link` such that it can be used for non-target as well, so in cross build the qmake or qtmake.bat can be processed with the same function. Fixes: QTBUG-109024 Change-Id: I246621c18325d084622ca92b422e815ed06f1381 Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
1 parent d8abcc9 commit ca24ee1

6 files changed

+67
-10
lines changed

bin/qmake-and-qtpaths-wrapper.bat.in

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
@echo off
2-
@host_qt_bindir@\@tool_name@.exe -qtconf "%~dp0\target_qt.conf" %*
2+
@host_qt_bindir@\@tool_name@@tool_version@.exe -qtconf "%~dp0\target_qt.conf" %*

bin/qmake-and-qtpaths-wrapper.in

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@
44
script_dir_path=`dirname $0`
55
script_dir_path=`(cd "$script_dir_path"; /bin/pwd)`
66

7-
@host_qt_bindir@/@tool_name@ -qtconf "$script_dir_path/target_qt.conf" $*
7+
@host_qt_bindir@/@tool_name@@tool_version@ -qtconf "$script_dir_path/target_qt.conf" $*

cmake/QtAppHelpers.cmake

+2-1
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,8 @@ function(qt_internal_add_app target)
8383

8484
# Install versioned link if requested.
8585
if(NOT arg_NO_INSTALL AND arg_INSTALL_VERSIONED_LINK)
86-
qt_internal_install_versioned_link("${arg_INSTALL_DIR}" ${target})
86+
qt_internal_install_versioned_link(WORKING_DIRECTORY "${arg_INSTALL_DIR}"
87+
TARGETS ${target})
8788
endif()
8889

8990
qt_add_list_file_finalizer(qt_internal_finalize_app ${target})

cmake/QtInstallHelpers.cmake

+49-6
Original file line numberDiff line numberDiff line change
@@ -95,12 +95,27 @@ function(qt_copy_or_install)
9595
qt_non_prefix_copy(COPY ${argv_copy} ${copy_arguments})
9696
endfunction()
9797

98-
# Create a versioned hard-link for the given target.
98+
# Create a versioned hard-link for the given target, or a program
9999
# E.g. "bin/qmake6" -> "bin/qmake".
100-
# If no hard link can be created, make a copy instead.
100+
#
101+
# One-value Arguments:
102+
# WORKING_DIRECTORY
103+
# The directory where the original file is already placed.
104+
# SUFFIX
105+
# The program file extension, only used for PROGRAMS
106+
# Multi-value Arguments:
107+
# TARGETS
108+
# List of targets for which the versioned link will be created.
109+
# If targets are given, BASE_NAME and SUFFIX will be derived from it.
110+
# PROGRAMS
111+
# List of program file names for which the versioned link will be created.
112+
#
113+
#
114+
# NOTE: This assumes that TARGETS, or PROGRAMS are already installed in the
115+
# WORKING_DIRECTORY.
101116
#
102117
# In a multi-config build, create the link for the main config only.
103-
function(qt_internal_install_versioned_link install_dir target)
118+
function(qt_internal_install_versioned_link)
104119
if(NOT QT_WILL_INSTALL)
105120
return()
106121
endif()
@@ -109,13 +124,41 @@ function(qt_internal_install_versioned_link install_dir target)
109124
return()
110125
endif()
111126

127+
set(options)
128+
set(oneValueArgs "WORKING_DIRECTORY;SUFFIX")
129+
set(multiValueArgs "TARGETS;PROGRAMS")
130+
cmake_parse_arguments(arg "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
131+
132+
if(arg_TARGETS)
133+
foreach(target "${arg_TARGETS}")
134+
_qt_internal_create_versioned_link_or_copy("${arg_WORKING_DIRECTORY}"
135+
$<TARGET_FILE_BASE_NAME:${target}>
136+
$<TARGET_FILE_SUFFIX:${target}>)
137+
endforeach()
138+
endif()
139+
140+
if(arg_PROGRAMS)
141+
foreach(program "${arg_PROGRAMS}")
142+
_qt_internal_create_versioned_link_or_copy("${arg_WORKING_DIRECTORY}"
143+
"${program}"
144+
"${arg_SUFFIX}")
145+
endforeach()
146+
endif()
147+
endfunction()
148+
149+
# Generate a script for creating a hard-link between the base_name, and
150+
# base_name${PROJECT_VERSION_MAJOR}.
151+
#
152+
# If no hard link can be created, make a copy instead.
153+
function(_qt_internal_create_versioned_link_or_copy install_dir base_name suffix)
112154
qt_path_join(install_base_file_path "$\{qt_full_install_prefix}"
113-
"${install_dir}" "$<TARGET_FILE_BASE_NAME:${target}>")
114-
set(original "${install_base_file_path}$<TARGET_FILE_SUFFIX:${target}>")
115-
set(linkname "${install_base_file_path}${PROJECT_VERSION_MAJOR}$<TARGET_FILE_SUFFIX:${target}>")
155+
"${install_dir}" "${base_name}")
156+
set(original "${install_base_file_path}${suffix}")
157+
set(linkname "${install_base_file_path}${PROJECT_VERSION_MAJOR}${suffix}")
116158
set(code "set(qt_full_install_prefix \"$\{CMAKE_INSTALL_PREFIX}\")"
117159
" if(NOT \"$ENV\{DESTDIR}\" STREQUAL \"\")"
118160
)
161+
119162
if(CMAKE_HOST_WIN32)
120163
list(APPEND code
121164
" if(qt_full_install_prefix MATCHES \"^[a-zA-Z]:\")"

cmake/QtQmakeHelpers.cmake

+12
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,10 @@ HostSpec=${QT_QMAKE_HOST_MKSPEC}
160160

161161
set(host_qt_bindir "${host_prefix}/${QT${PROJECT_VERSION_MAJOR}_HOST_INFO_BINDIR}")
162162

163+
if(QT_CREATE_VERSIONED_HARD_LINK)
164+
set(tool_version "${PROJECT_VERSION_MAJOR}")
165+
endif()
166+
163167
foreach(host_type ${hosts})
164168
foreach(tool_name qmake qtpaths)
165169
set(wrapper_extension)
@@ -177,6 +181,14 @@ HostSpec=${QT_QMAKE_HOST_MKSPEC}
177181
configure_file("${wrapper_in_file}" "${wrapper}" @ONLY NEWLINE_STYLE ${newline_style})
178182
qt_copy_or_install(PROGRAMS "${CMAKE_CURRENT_BINARY_DIR}/${wrapper}"
179183
DESTINATION "${INSTALL_BINDIR}")
184+
185+
# Configuring a new wrapper file, this type setting the tool_version
186+
if(QT_CREATE_VERSIONED_HARD_LINK)
187+
set(versioned_wrapper "preliminary/${wrapper_prefix}${tool_name}${tool_version}${wrapper_extension}")
188+
configure_file("${wrapper_in_file}" "${versioned_wrapper}" @ONLY NEWLINE_STYLE ${newline_style})
189+
qt_copy_or_install(PROGRAMS "${CMAKE_CURRENT_BINARY_DIR}/${versioned_wrapper}"
190+
DESTINATION "${INSTALL_BINDIR}")
191+
endif()
180192
endforeach()
181193
endforeach()
182194
endfunction()

cmake/QtToolHelpers.cmake

+2-1
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,8 @@ function(qt_internal_add_tool target_name)
194194
endforeach()
195195

196196
if(arg_INSTALL_VERSIONED_LINK)
197-
qt_internal_install_versioned_link("${install_dir}" "${target_name}")
197+
qt_internal_install_versioned_link(WORKING_DIRECTORY "${install_dir}"
198+
TARGETS "${target_name}")
198199
endif()
199200

200201
qt_apply_rpaths(TARGET "${target_name}" INSTALL_PATH "${install_dir}" RELATIVE_RPATH)

0 commit comments

Comments
 (0)