CMake: Fix return value of applicationName() on macOS

QCore::applicationName() is influenced by what values we insert into
the Info.plist file of an application bundle.

We accidentally inserted tokens like ${PRODUCT_NAME} that are meant to
be expanded by xcodebuild, even when using a generator like Ninja.

This caused the applicationName() to report "${PRODUCT_NAME}".

Make sure to only call relevant finalizers for macOS applications
when using a generator other than Xcode.

Amends d5580aa719

Pick-to: 6.4 6.4.0
Fixes: QTBUG-106652
Change-Id: Idbc9c84557a8f17b1302e6969f6eb317e3ef225d
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
This commit is contained in:
Alexandru Croitor 2022-09-15 18:21:00 +02:00
parent 62c681a599
commit 865b1721bd

View File

@ -346,7 +346,8 @@ function(_qt_internal_set_placeholder_apple_bundle_version target)
if(NOT CMAKE_XCODE_ATTRIBUTE_MARKETING_VERSION if(NOT CMAKE_XCODE_ATTRIBUTE_MARKETING_VERSION
AND NOT QT_NO_SET_XCODE_ATTRIBUTE_MARKETING_VERSION AND NOT QT_NO_SET_XCODE_ATTRIBUTE_MARKETING_VERSION
AND NOT CMAKE_XCODE_ATTRIBUTE_CURRENT_PROJECT_VERSION AND NOT CMAKE_XCODE_ATTRIBUTE_CURRENT_PROJECT_VERSION
AND NOT QT_NO_SET_XCODE_ATTRIBUTE_CURRENT_PROJECT_VERSION) AND NOT QT_NO_SET_XCODE_ATTRIBUTE_CURRENT_PROJECT_VERSION
AND CMAKE_GENERATOR STREQUAL "Xcode")
get_target_property(marketing_version "${target}" get_target_property(marketing_version "${target}"
XCODE_ATTRIBUTE_MARKETING_VERSION) XCODE_ATTRIBUTE_MARKETING_VERSION)
get_target_property(current_project_version "${target}" get_target_property(current_project_version "${target}"
@ -499,9 +500,15 @@ function(_qt_internal_set_xcode_bundle_name target)
get_target_property(existing_bundle_name "${target}" MACOSX_BUNDLE_BUNDLE_NAME) get_target_property(existing_bundle_name "${target}" MACOSX_BUNDLE_BUNDLE_NAME)
if(NOT MACOSX_BUNDLE_BUNDLE_NAME AND NOT existing_bundle_name) if(NOT MACOSX_BUNDLE_BUNDLE_NAME AND NOT existing_bundle_name)
if(CMAKE_GENERATOR STREQUAL Xcode)
set_target_properties("${target}" set_target_properties("${target}"
PROPERTIES PROPERTIES
MACOSX_BUNDLE_BUNDLE_NAME "\${PRODUCT_NAME}") MACOSX_BUNDLE_BUNDLE_NAME "\${PRODUCT_NAME}")
else()
set_target_properties("${target}"
PROPERTIES
MACOSX_BUNDLE_BUNDLE_NAME "${target}")
endif()
endif() endif()
endfunction() endfunction()
@ -590,12 +597,18 @@ endfunction()
function(_qt_internal_finalize_apple_app target) function(_qt_internal_finalize_apple_app target)
# Shared between macOS and iOS apps # Shared between macOS and iOS apps
# Only set the various properties if targeting the Xcode generator, otherwise the various
# Xcode tokens are embedded as-is instead of being dynamically evaluated.
# This affects things like the version number or application name as reported by Qt API.
if(CMAKE_GENERATOR STREQUAL "Xcode")
_qt_internal_set_xcode_development_team_id("${target}") _qt_internal_set_xcode_development_team_id("${target}")
_qt_internal_set_xcode_bundle_identifier("${target}") _qt_internal_set_xcode_bundle_identifier("${target}")
_qt_internal_set_xcode_code_sign_style("${target}") _qt_internal_set_xcode_code_sign_style("${target}")
_qt_internal_set_xcode_bundle_name("${target}")
_qt_internal_set_xcode_bundle_display_name("${target}") _qt_internal_set_xcode_bundle_display_name("${target}")
_qt_internal_set_xcode_install_path("${target}") _qt_internal_set_xcode_install_path("${target}")
endif()
_qt_internal_set_xcode_bundle_name("${target}")
_qt_internal_set_placeholder_apple_bundle_version("${target}") _qt_internal_set_placeholder_apple_bundle_version("${target}")
endfunction() endfunction()