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.

Pick-to: 6.4
Change-Id: I23acc7c6506f1818ef4a90f6f595bc449f83c57b
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
This commit is contained in:
Tor Arne Vestbø 2022-07-14 13:00:02 +02:00
parent 38114b8325
commit 25d27de126

View File

@ -1001,10 +1001,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}"