From e59b9ea4db7ad5abc0d2c48ffba3943cbc6e1d7f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= Date: Thu, 14 Jul 2022 13:00:02 +0200 Subject: [PATCH] cmake: Set CURRENT_PROJECT_VERSION and MARKETING_VERSION for Xcode projects This provides a better user-experience, as the two settings have dedicated fields in the project UI, and matches how new projects are generated by Xcode itself. Change-Id: I23acc7c6506f1818ef4a90f6f595bc449f83c57b Reviewed-by: Alexandru Croitor (cherry picked from commit 25d27de126a3dfa4cd53b9ecc061c131ab29abce) Reviewed-by: Qt Cherry-pick Bot --- src/corelib/Qt6CoreMacros.cmake | 28 ++++++++++++++++++++++++---- 1 file changed, 24 insertions(+), 4 deletions(-) diff --git a/src/corelib/Qt6CoreMacros.cmake b/src/corelib/Qt6CoreMacros.cmake index ad82f518771..786dd0c3b3f 100644 --- a/src/corelib/Qt6CoreMacros.cmake +++ b/src/corelib/Qt6CoreMacros.cmake @@ -1020,10 +1020,30 @@ function(_qt_internal_set_placeholder_apple_bundle_version target) NOT bundle_version AND NOT bundle_short_version AND NOT QT_NO_SET_XCODE_BUNDLE_VERSION - ) - set(bundle_version "0.0.1") - set(bundle_short_version "0.0.1") - set_target_properties("${target}" + ) + set(bundle_version "0.0.1") + set(bundle_short_version "0.0.1") + + if(NOT CMAKE_XCODE_ATTRIBUTE_MARKETING_VERSION + AND NOT QT_NO_SET_XCODE_ATTRIBUTE_MARKETING_VERSION + AND NOT CMAKE_XCODE_ATTRIBUTE_CURRENT_PROJECT_VERSION + AND NOT QT_NO_SET_XCODE_ATTRIBUTE_CURRENT_PROJECT_VERSION) + get_target_property(marketing_version "${target}" + XCODE_ATTRIBUTE_MARKETING_VERSION) + get_target_property(current_project_version "${target}" + XCODE_ATTRIBUTE_CURRENT_PROJECT_VERSION) + if(NOT marketing_version AND NOT current_project_version) + set_target_properties("${target}" + PROPERTIES + XCODE_ATTRIBUTE_CURRENT_PROJECT_VERSION "${bundle_version}" + XCODE_ATTRIBUTE_MARKETING_VERSION "${bundle_short_version}" + ) + set(bundle_version "$(CURRENT_PROJECT_VERSION)") + set(bundle_short_version "$(MARKETING_VERSION)") + endif() + endif() + + set_target_properties("${target}" PROPERTIES MACOSX_BUNDLE_BUNDLE_VERSION "${bundle_version}" MACOSX_BUNDLE_SHORT_VERSION_STRING "${bundle_short_version}"