From 55eb94cdbdf1b1fbd6424aa06921bc79123f88cd Mon Sep 17 00:00:00 2001 From: Alexandru Croitor Date: Wed, 11 May 2022 13:15:20 +0200 Subject: [PATCH] CMake: Use the PRODUCT_NAME for the iOS display name like qmake MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This ensures that the Xcode 'Display name' input under ${target} -> General -> Identity -> Display name is not empty. Because adding ${PRODUCT_NAME} directly in the Info.plist.in template will cause CMake to evaluate it as variable expansion, work around the issue by putting the dollar sign into a separate cache variable that after evaluation will result in ${PRODUCT_NAME} being in the file verbatim, so that Xcode evaluate it at build time. Amends 4d838dae5a821e9e5f013ba1d5a494ece1b5180e Pick-to: 6.2 6.3 Task-number: QTBUG-95838 Change-Id: I2d1090cc8e84b32442f7daca2d4ce5e3ad413c68 Reviewed-by: Jörg Bornemann Reviewed-by: Alexey Edelev --- cmake/ios/MacOSXBundleInfo.plist.in | 7 +++++++ src/corelib/Qt6CoreMacros.cmake | 11 +++++++++++ 2 files changed, 18 insertions(+) diff --git a/cmake/ios/MacOSXBundleInfo.plist.in b/cmake/ios/MacOSXBundleInfo.plist.in index 5b15af1302c..0cecf4ba99b 100644 --- a/cmake/ios/MacOSXBundleInfo.plist.in +++ b/cmake/ios/MacOSXBundleInfo.plist.in @@ -4,18 +4,25 @@ CFBundleInfoDictionaryVersion 6.0 + CFBundlePackageType APPL CFBundleName ${MACOSX_BUNDLE_BUNDLE_NAME} + + CFBundleDisplayName + ${QT_INTERNAL_DOLLAR_VAR}{PRODUCT_NAME} + CFBundleIdentifier ${MACOSX_BUNDLE_GUI_IDENTIFIER} + CFBundleExecutable ${MACOSX_BUNDLE_EXECUTABLE_NAME} CFBundleVersion ${MACOSX_BUNDLE_BUNDLE_VERSION} + CFBundleShortVersionString ${MACOSX_BUNDLE_SHORT_VERSION_STRING} diff --git a/src/corelib/Qt6CoreMacros.cmake b/src/corelib/Qt6CoreMacros.cmake index 00704349459..718c8d683d4 100644 --- a/src/corelib/Qt6CoreMacros.cmake +++ b/src/corelib/Qt6CoreMacros.cmake @@ -1036,12 +1036,23 @@ function(_qt_internal_set_xcode_code_sign_style target) endif() endfunction() +function(_qt_internal_set_xcode_bundle_display_name target) + # We want the value of CFBundleDisplayName to be ${PRODUCT_NAME}, but we can't put that + # into the Info.plist.in template file directly, because the implicit configure_file(Info.plist) + # done by CMake is not using the @ONLY option, so CMake would treat the assignment as + # variable expansion. Escaping using backslashes does not help. + # Work around it by assigning the dollar char to a separate cache var, and expand it, so that + # the final value in the file will be ${PRODUCT_NAME}, to be evaluated at build time by Xcode. + set(QT_INTERNAL_DOLLAR_VAR "$" CACHE STRING "") +endfunction() + function(_qt_internal_finalize_ios_app target) _qt_internal_set_xcode_development_team_id("${target}") _qt_internal_set_xcode_bundle_identifier("${target}") _qt_internal_set_xcode_product_bundle_identifier("${target}") _qt_internal_set_xcode_targeted_device_family("${target}") _qt_internal_set_xcode_code_sign_style("${target}") + _qt_internal_set_xcode_bundle_display_name("${target}") _qt_internal_handle_ios_launch_screen("${target}") _qt_internal_set_placeholder_apple_bundle_version("${target}")