diff options
-rw-r--r-- | bin/qmake-and-qtpaths-wrapper.bat.in | 2 | ||||
-rwxr-xr-x | bin/qmake-and-qtpaths-wrapper.in | 2 | ||||
-rw-r--r-- | cmake/QtAppHelpers.cmake | 3 | ||||
-rw-r--r-- | cmake/QtInstallHelpers.cmake | 55 | ||||
-rw-r--r-- | cmake/QtQmakeHelpers.cmake | 12 | ||||
-rw-r--r-- | cmake/QtToolHelpers.cmake | 3 |
6 files changed, 67 insertions, 10 deletions
diff --git a/bin/qmake-and-qtpaths-wrapper.bat.in b/bin/qmake-and-qtpaths-wrapper.bat.in index 8225170fc9..5c952b0196 100644 --- a/bin/qmake-and-qtpaths-wrapper.bat.in +++ b/bin/qmake-and-qtpaths-wrapper.bat.in @@ -1,2 +1,2 @@ @echo off -@host_qt_bindir@\@tool_name@.exe -qtconf "%~dp0\target_qt.conf" %* +@host_qt_bindir@\@tool_name@@tool_version@.exe -qtconf "%~dp0\target_qt.conf" %* diff --git a/bin/qmake-and-qtpaths-wrapper.in b/bin/qmake-and-qtpaths-wrapper.in index f26355af8d..bf3d50cc22 100755 --- a/bin/qmake-and-qtpaths-wrapper.in +++ b/bin/qmake-and-qtpaths-wrapper.in @@ -4,4 +4,4 @@ script_dir_path=`dirname $0` script_dir_path=`(cd "$script_dir_path"; /bin/pwd)` -@host_qt_bindir@/@tool_name@ -qtconf "$script_dir_path/target_qt.conf" $* +@host_qt_bindir@/@tool_name@@tool_version@ -qtconf "$script_dir_path/target_qt.conf" $* diff --git a/cmake/QtAppHelpers.cmake b/cmake/QtAppHelpers.cmake index 9048039c83..f7466ba441 100644 --- a/cmake/QtAppHelpers.cmake +++ b/cmake/QtAppHelpers.cmake @@ -83,7 +83,8 @@ function(qt_internal_add_app target) # Install versioned link if requested. if(NOT arg_NO_INSTALL AND arg_INSTALL_VERSIONED_LINK) - qt_internal_install_versioned_link("${arg_INSTALL_DIR}" ${target}) + qt_internal_install_versioned_link(WORKING_DIRECTORY "${arg_INSTALL_DIR}" + TARGETS ${target}) endif() qt_add_list_file_finalizer(qt_internal_finalize_app ${target}) diff --git a/cmake/QtInstallHelpers.cmake b/cmake/QtInstallHelpers.cmake index 218c1a385f..41888d3090 100644 --- a/cmake/QtInstallHelpers.cmake +++ b/cmake/QtInstallHelpers.cmake @@ -95,12 +95,27 @@ function(qt_copy_or_install) qt_non_prefix_copy(COPY ${argv_copy} ${copy_arguments}) endfunction() -# Create a versioned hard-link for the given target. +# Create a versioned hard-link for the given target, or a program # E.g. "bin/qmake6" -> "bin/qmake". -# If no hard link can be created, make a copy instead. +# +# One-value Arguments: +# WORKING_DIRECTORY +# The directory where the original file is already placed. +# SUFFIX +# The program file extension, only used for PROGRAMS +# Multi-value Arguments: +# TARGETS +# List of targets for which the versioned link will be created. +# If targets are given, BASE_NAME and SUFFIX will be derived from it. +# PROGRAMS +# List of program file names for which the versioned link will be created. +# +# +# NOTE: This assumes that TARGETS, or PROGRAMS are already installed in the +# WORKING_DIRECTORY. # # In a multi-config build, create the link for the main config only. -function(qt_internal_install_versioned_link install_dir target) +function(qt_internal_install_versioned_link) if(NOT QT_WILL_INSTALL) return() endif() @@ -109,13 +124,41 @@ function(qt_internal_install_versioned_link install_dir target) return() endif() + set(options) + set(oneValueArgs "WORKING_DIRECTORY;SUFFIX") + set(multiValueArgs "TARGETS;PROGRAMS") + cmake_parse_arguments(arg "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN}) + + if(arg_TARGETS) + foreach(target "${arg_TARGETS}") + _qt_internal_create_versioned_link_or_copy("${arg_WORKING_DIRECTORY}" + $<TARGET_FILE_BASE_NAME:${target}> + $<TARGET_FILE_SUFFIX:${target}>) + endforeach() + endif() + + if(arg_PROGRAMS) + foreach(program "${arg_PROGRAMS}") + _qt_internal_create_versioned_link_or_copy("${arg_WORKING_DIRECTORY}" + "${program}" + "${arg_SUFFIX}") + endforeach() + endif() +endfunction() + +# Generate a script for creating a hard-link between the base_name, and +# base_name${PROJECT_VERSION_MAJOR}. +# +# If no hard link can be created, make a copy instead. +function(_qt_internal_create_versioned_link_or_copy install_dir base_name suffix) 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}>") + "${install_dir}" "${base_name}") + set(original "${install_base_file_path}${suffix}") + set(linkname "${install_base_file_path}${PROJECT_VERSION_MAJOR}${suffix}") 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]:\")" diff --git a/cmake/QtQmakeHelpers.cmake b/cmake/QtQmakeHelpers.cmake index 2d26d27386..03369693db 100644 --- a/cmake/QtQmakeHelpers.cmake +++ b/cmake/QtQmakeHelpers.cmake @@ -160,6 +160,10 @@ HostSpec=${QT_QMAKE_HOST_MKSPEC} set(host_qt_bindir "${host_prefix}/${QT${PROJECT_VERSION_MAJOR}_HOST_INFO_BINDIR}") + if(QT_CREATE_VERSIONED_HARD_LINK) + set(tool_version "${PROJECT_VERSION_MAJOR}") + endif() + foreach(host_type ${hosts}) foreach(tool_name qmake qtpaths) set(wrapper_extension) @@ -177,6 +181,14 @@ HostSpec=${QT_QMAKE_HOST_MKSPEC} configure_file("${wrapper_in_file}" "${wrapper}" @ONLY NEWLINE_STYLE ${newline_style}) qt_copy_or_install(PROGRAMS "${CMAKE_CURRENT_BINARY_DIR}/${wrapper}" DESTINATION "${INSTALL_BINDIR}") + + # Configuring a new wrapper file, this type setting the tool_version + if(QT_CREATE_VERSIONED_HARD_LINK) + set(versioned_wrapper "preliminary/${wrapper_prefix}${tool_name}${tool_version}${wrapper_extension}") + configure_file("${wrapper_in_file}" "${versioned_wrapper}" @ONLY NEWLINE_STYLE ${newline_style}) + qt_copy_or_install(PROGRAMS "${CMAKE_CURRENT_BINARY_DIR}/${versioned_wrapper}" + DESTINATION "${INSTALL_BINDIR}") + endif() endforeach() endforeach() endfunction() diff --git a/cmake/QtToolHelpers.cmake b/cmake/QtToolHelpers.cmake index 8af9e50d68..68d054f282 100644 --- a/cmake/QtToolHelpers.cmake +++ b/cmake/QtToolHelpers.cmake @@ -194,7 +194,8 @@ function(qt_internal_add_tool target_name) endforeach() if(arg_INSTALL_VERSIONED_LINK) - qt_internal_install_versioned_link("${install_dir}" "${target_name}") + qt_internal_install_versioned_link(WORKING_DIRECTORY "${install_dir}" + TARGETS "${target_name}") endif() qt_apply_rpaths(TARGET "${target_name}" INSTALL_PATH "${install_dir}" RELATIVE_RPATH) |