summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlexandru Croitor <alexandru.croitor@qt.io>2024-03-20 11:29:36 +0100
committerAlexandru Croitor <alexandru.croitor@qt.io>2024-03-22 00:04:20 +0100
commitecdbc40d4041590ae6d6ceef2e82ec25f522da01 (patch)
treea524e1b5eb4b5dc152c952cc24af0bddd0f2cd6b
parent07e7340c0d82a33b7b112cb7c3a2a719ad2ec9c3 (diff)
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. Pick-to: 6.7 Change-Id: I932d6bfa2d3c7e2aaf8be967fea1f682eacf0112 Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
-rw-r--r--src/corelib/Qt6CoreDeploySupport.cmake11
-rw-r--r--src/corelib/Qt6CoreMacros.cmake38
2 files changed, 32 insertions, 17 deletions
diff --git a/src/corelib/Qt6CoreDeploySupport.cmake b/src/corelib/Qt6CoreDeploySupport.cmake
index 915f94b0e0..2615eca4ea 100644
--- a/src/corelib/Qt6CoreDeploySupport.cmake
+++ b/src/corelib/Qt6CoreDeploySupport.cmake
@@ -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})."
+ "this target platform (${__QT_DEPLOY_SYSTEM_NAME}, ${qt_build_type_string}). "
+ "${arg_EXTRA_MESSAGE}"
)
endfunction()
diff --git a/src/corelib/Qt6CoreMacros.cmake b/src/corelib/Qt6CoreMacros.cmake
index 4dce7d49a9..dcd27ad611 100644
--- a/src/corelib/Qt6CoreMacros.cmake
+++ b/src/corelib/Qt6CoreMacros.cmake
@@ -3655,6 +3655,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()
@@ -3665,6 +3668,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
@@ -3692,15 +3701,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(
@@ -3729,19 +3732,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})."
+ "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)