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 <alexandru.croitor@qt.io>
(cherry picked from commit 25d27de126a3dfa4cd53b9ecc061c131ab29abce)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
Tor Arne Vestbø 2022-07-14 13:00:02 +02:00 committed by Qt Cherry-pick Bot
parent 649b1774a1
commit e59b9ea4db

View File

@ -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}"