CMake: Consider NO_UNSUPPORTED_PLATFORM_ERROR for non-bundle mac apps

Currently if qt6_generate_deploy_app_script is called on an executable
target that does not have the MACOSX_BUNDLE property set, it will
error out with a message about not supporting non-bundle apps.

This error is shown even if NO_UNSUPPORTED_PLATFORM_ERROR is passed
as an option which looks like an oversight.

Change the code not to show the error if NO_UNSUPPORTED_PLATFORM_ERROR
is passed. This means user projects can call
qt6_generate_deploy_app_script for non-bundle apps without having to
wrap the code in a if(NOT APPLE) check, and deployment will simply not
run for that target on macOS.

[ChangeLog][Build System] The qt6_generate_deploy_app_script
NO_UNSUPPORTED_PLATFORM_ERROR option will now have an effect when
calling the API on non-bundle macOS executable targets.

Change-Id: I932d6bfa2d3c7e2aaf8be967fea1f682eacf0112
Reviewed-by:  Alexey Edelev <alexey.edelev@qt.io>
(cherry picked from commit ecdbc40d4041590ae6d6ceef2e82ec25f522da01)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
Alexandru Croitor 2024-03-20 11:29:36 +01:00 committed by Qt Cherry-pick Bot
parent 3f1ddd1068
commit 0e75b141b8
2 changed files with 32 additions and 17 deletions

View File

@ -546,10 +546,19 @@ if(NOT __QT_NO_CREATE_VERSIONLESS_FUNCTIONS)
endif()
function(_qt_internal_show_skip_runtime_deploy_message qt_build_type_string)
set(no_value_options "")
set(single_value_options
EXTRA_MESSAGE
)
set(multi_value_options "")
cmake_parse_arguments(PARSE_ARGV 1 arg
"${no_value_options}" "${single_value_options}" "${multi_value_options}"
)
message(STATUS
"Skipping runtime deployment steps. "
"Support for installing runtime dependencies is not implemented for "
"this target platform (${__QT_DEPLOY_SYSTEM_NAME}, ${qt_build_type_string}). "
"${arg_EXTRA_MESSAGE}"
)
endfunction()

View File

@ -3589,6 +3589,9 @@ function(qt6_generate_deploy_app_script)
message(FATAL_ERROR "OUTPUT_SCRIPT must be specified")
endif()
get_target_property(is_bundle ${arg_TARGET} MACOSX_BUNDLE)
set(unsupported_platform_extra_message "")
if(QT6_IS_SHARED_LIBS_BUILD)
set(qt_build_type_string "shared Qt libs")
else()
@ -3599,6 +3602,12 @@ function(qt6_generate_deploy_app_script)
string(APPEND qt_build_type_string ", cross-compiled")
endif()
if(NOT is_bundle)
string(APPEND qt_build_type_string ", non-bundle app")
set(unsupported_platform_extra_message
"Executable targets have to be app bundles to use this command on Apple platforms.")
endif()
set(generate_args
TARGET ${arg_TARGET}
OUTPUT_SCRIPT deploy_script
@ -3626,15 +3635,9 @@ function(qt6_generate_deploy_app_script)
SKIP_REASON "${skip_reason}"
${generate_args}
)
elseif(APPLE AND NOT IOS AND QT6_IS_SHARED_LIBS_BUILD)
# TODO: Handle non-bundle applications if possible.
get_target_property(is_bundle ${arg_TARGET} MACOSX_BUNDLE)
if(NOT is_bundle)
message(FATAL_ERROR
"Executable targets have to be app bundles to use this command "
"on Apple platforms."
)
endif()
elseif(APPLE AND NOT IOS AND QT6_IS_SHARED_LIBS_BUILD AND is_bundle)
# TODO: Consider handling non-bundle applications in the future using the generic cmake
# runtime dependency feature.
qt6_generate_deploy_script(${generate_args}
CONTENT "
qt6_deploy_runtime_dependencies(
@ -3663,19 +3666,22 @@ ${common_deploy_args})
elseif(NOT arg_NO_UNSUPPORTED_PLATFORM_ERROR AND NOT QT_INTERNAL_NO_UNSUPPORTED_PLATFORM_ERROR)
# Currently we don't deploy runtime dependencies if cross-compiling or using a static Qt.
# We also don't do it if targeting Linux, but we could provide an option to do
# so if we had a deploy tool or purely CMake-based deploy implementation.
# Error out by default unless the project opted out of the error.
# This provides us a migration path in the future without breaking compatibility promises.
message(FATAL_ERROR
"Support for installing runtime dependencies is not implemented for "
"this target platform (${CMAKE_SYSTEM_NAME}, ${qt_build_type_string}). "
${unsupported_platform_extra_message}
)
else()
qt6_generate_deploy_script(${generate_args}
CONTENT "
_qt_internal_show_skip_runtime_deploy_message(\"${qt_build_type_string}\")
")
set(skip_message
"_qt_internal_show_skip_runtime_deploy_message(\"${qt_build_type_string}\"")
if(unsupported_platform_extra_message)
string(APPEND skip_message
"\n EXTRA_MESSAGE \"${unsupported_platform_extra_message}\"")
endif()
string(APPEND skip_message "\n)")
qt6_generate_deploy_script(${generate_args} CONTENT "${skip_message}")
endif()
set(${arg_OUTPUT_SCRIPT} "${deploy_script}" PARENT_SCOPE)