cmake: Copy template Info.plist for macOS manually, like we do for iOS

Unifies the approach between iOS and macOS. By copying the Info.plist
to the build directory, we also open up the possibility to modify it,
which we can't do when CMake does the copy during its generator step.

Change-Id: I59f9f69ac368166bb26d8a5c57bf4ea3f503d51b
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
This commit is contained in:
Tor Arne Vestbø 2023-04-20 12:13:09 +02:00
parent d6ed400037
commit 2f273f5dfd
4 changed files with 36 additions and 22 deletions

View File

@ -387,17 +387,30 @@ if(QT_WILL_INSTALL)
)
endif()
if(MACOS)
qt_copy_or_install(FILES
cmake/macos/MacOSXBundleInfo.plist.in
DESTINATION "${__GlobalConfig_install_dir}/macos"
if(APPLE)
if(MACOS)
set(platform_shortname "macos")
elseif(IOS)
set(platform_shortname "ios")
endif()
qt_copy_or_install(FILES "cmake/${platform_shortname}/Info.plist.app.in"
DESTINATION "${__GlobalConfig_install_dir}/${platform_shortname}"
)
elseif(IOS)
qt_copy_or_install(FILES
cmake/ios/Info.plist.app.in
cmake/ios/LaunchScreen.storyboard
DESTINATION "${__GlobalConfig_install_dir}/ios"
# For examples built as part of prefix build before install
file(COPY "cmake/${platform_shortname}/Info.plist.app.in"
DESTINATION "${__GlobalConfig_build_dir}/${platform_shortname}"
)
if(IOS)
qt_copy_or_install(FILES "cmake/ios/LaunchScreen.storyboard"
DESTINATION "${__GlobalConfig_install_dir}/ios"
)
# For examples built as part of prefix build before install
file(COPY "cmake/ios/LaunchScreen.storyboard"
DESTINATION "${__GlobalConfig_build_dir}/ios"
)
endif()
elseif(WASM)
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/util/wasm/wasmtestrunner/qt-wasmtestrunner.py"
"${QT_BUILD_DIR}/${INSTALL_LIBEXECDIR}/qt-wasmtestrunner.py" @ONLY)

View File

@ -29,13 +29,12 @@ list(APPEND CMAKE_MODULE_PATH "${_qt_import_prefix}")
list(APPEND CMAKE_MODULE_PATH "${_qt_import_prefix}/3rdparty/extra-cmake-modules/find-modules")
list(APPEND CMAKE_MODULE_PATH "${_qt_import_prefix}/3rdparty/kwin")
if(APPLE AND (NOT CMAKE_SYSTEM_NAME OR CMAKE_SYSTEM_NAME STREQUAL "Darwin"))
# Add module directory to pick up custom Info.plist template for macOS
list(APPEND CMAKE_MODULE_PATH "${_qt_import_prefix}/macos")
elseif(APPLE AND CMAKE_SYSTEM_NAME STREQUAL "iOS")
# Add module directory to pick up custom Info.plist template for iOS
set(__qt_internal_cmake_ios_support_files_path "${_qt_import_prefix}/ios")
list(APPEND CMAKE_MODULE_PATH "${__qt_internal_cmake_ios_support_files_path}")
if(APPLE)
if(NOT CMAKE_SYSTEM_NAME OR CMAKE_SYSTEM_NAME STREQUAL "Darwin")
set(__qt_internal_cmake_apple_support_files_path "${_qt_import_prefix}/macos")
elseif(CMAKE_SYSTEM_NAME STREQUAL "iOS")
set(__qt_internal_cmake_apple_support_files_path "${_qt_import_prefix}/ios")
endif()
endif()
# Public helpers available to all Qt packages.

View File

@ -27,7 +27,7 @@ function(_qt_internal_handle_ios_launch_screen target)
if(NOT launch_screen AND NOT QT_NO_SET_DEFAULT_IOS_LAUNCH_SCREEN)
set(is_default_launch_screen TRUE)
set(launch_screen
"${__qt_internal_cmake_ios_support_files_path}/LaunchScreen.storyboard")
"${__qt_internal_cmake_apple_support_files_path}/LaunchScreen.storyboard")
endif()
# Check that the launch screen exists.
@ -531,14 +531,14 @@ function(_qt_internal_set_xcode_bitcode_enablement target)
"NO")
endfunction()
function(_qt_internal_generate_ios_info_plist target)
function(_qt_internal_generate_info_plist target)
# If the project already specifies a custom file, we don't override it.
get_target_property(existing_plist "${target}" MACOSX_BUNDLE_INFO_PLIST)
if(existing_plist)
return()
endif()
set(info_plist_in "${__qt_internal_cmake_ios_support_files_path}/Info.plist.app.in")
set(info_plist_in "${__qt_internal_cmake_apple_support_files_path}/Info.plist.app.in")
string(MAKE_C_IDENTIFIER "${target}" target_identifier)
set(info_plist_out_dir
@ -598,6 +598,8 @@ endfunction()
function(_qt_internal_finalize_apple_app target)
# Shared between macOS and iOS apps
_qt_internal_generate_info_plist("${target}")
# 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.
@ -613,12 +615,12 @@ function(_qt_internal_finalize_apple_app target)
endfunction()
function(_qt_internal_finalize_ios_app target)
_qt_internal_finalize_apple_app("${target}")
# Must be called before we generate the Info.plist
_qt_internal_handle_ios_launch_screen("${target}")
_qt_internal_finalize_apple_app("${target}")
_qt_internal_set_xcode_targeted_device_family("${target}")
_qt_internal_set_xcode_bitcode_enablement("${target}")
_qt_internal_handle_ios_launch_screen("${target}")
_qt_internal_generate_ios_info_plist("${target}")
_qt_internal_set_ios_simulator_arch("${target}")
endfunction()