summaryrefslogtreecommitdiffstats
path: root/cmake/QtInstallHelpers.cmake
diff options
context:
space:
mode:
Diffstat (limited to 'cmake/QtInstallHelpers.cmake')
-rw-r--r--cmake/QtInstallHelpers.cmake30
1 files changed, 30 insertions, 0 deletions
diff --git a/cmake/QtInstallHelpers.cmake b/cmake/QtInstallHelpers.cmake
index 5832df144c..1f1fb84634 100644
--- a/cmake/QtInstallHelpers.cmake
+++ b/cmake/QtInstallHelpers.cmake
@@ -125,3 +125,33 @@ function(qt_set_up_nonprefix_build)
qt_remove_install_target()
endif()
endfunction()
+
+# Create a versioned hard-link for the given target.
+# E.g. "bin/qmake6" -> "bin/qmake".
+# If no hard link can be created, make a copy instead.
+#
+# In a multi-config build, create the link for the main config only.
+function(qt_internal_install_versioned_link install_dir target)
+ if(NOT QT_WILL_INSTALL)
+ return()
+ endif()
+
+ qt_path_join(install_base_file_path "$ENV\{DESTDIR}$\{CMAKE_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)")
+
+ if(QT_GENERATOR_IS_MULTI_CONFIG)
+ # Wrap the code in a configuration check,
+ # because install(CODE) does not support a CONFIGURATIONS argument.
+ qt_create_case_insensitive_regex(main_config_regex ${QT_MULTI_CONFIG_FIRST_CONFIG})
+ list(PREPEND code "if(\"\${CMAKE_INSTALL_CONFIG_NAME}\" MATCHES \"${main_config_regex}\")")
+ list(APPEND code "endif()")
+ endif()
+
+ list(JOIN code "\n" code)
+ install(CODE "${code}")
+endfunction()