summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlexandru Croitor <alexandru.croitor@qt.io>2024-03-13 13:54:20 +0100
committerAlexandru Croitor <alexandru.croitor@qt.io>2024-03-19 17:20:23 +0100
commitc90964788cb1d6ffbfde6e9dc930bbb3e915fb98 (patch)
tree1537fefe7ef68a15b788fe5eb8ee09f41576dce8
parenta6965441d72a1e453d80d0083c1a3fd6803d96bb (diff)
CMake: Add option to allow skipping app deployment when building in CI
We would like to add deployment api calls to all our examples. Doing that in the CI, where we build all examples, would mean running the deployment tools for each example. This takes time and space. Add the option to skip running deployment code by setting the QT_INTERNAL_SKIP_DEPLOYMENT variable. This can be set per-directory or at the root directory. In that case we will generate an install script that does nothing. With this option, we can ensure we run deployment for a few examples, but skip it for the rest. Also skip running the deployment api for non-prefix builds, because it only partially works. In such a case, show a warning. The warning can be hidden by setting the QT_INTERNAL_HIDE_NO_OP_DEPLOYMENT_WARNING variable. This might be revisited in the future. The newly introduced helper functions are also meant to be used in qtdeclarative. qtbase only uses one of them, because currently it does not contain POST_BUILD deployment logic. Pick-to: 6.7 Task-number: QTBUG-90820 Task-number: QTBUG-96232 Task-number: QTBUG-102057 Change-Id: If5a4102137e9dfc4a8bfde7b26d511ed1700340e Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
-rw-r--r--src/corelib/Qt6CoreMacros.cmake124
1 files changed, 123 insertions, 1 deletions
diff --git a/src/corelib/Qt6CoreMacros.cmake b/src/corelib/Qt6CoreMacros.cmake
index 949d10d671..4dce7d49a9 100644
--- a/src/corelib/Qt6CoreMacros.cmake
+++ b/src/corelib/Qt6CoreMacros.cmake
@@ -3154,6 +3154,121 @@ function(_qt_internal_write_target_deploy_info out_file)
file(GENERATE OUTPUT "${out_file}" CONTENT "${content}")
endfunction()
+function(_qt_internal_is_examples_deployment_supported_in_current_config out_var out_var_reason)
+ # Deployment API doesn't work when examples / tests are built in-tree of a prefix qt build.
+ if(QT_BUILDING_QT AND QT_WILL_INSTALL AND NOT QT_INTERNAL_BUILD_STANDALONE_PARTS)
+ set(deployment_supported FALSE)
+ set(not_supported_reason "PREFIX_BUILD")
+ else()
+ set(deployment_supported TRUE)
+ set(not_supported_reason "")
+ endif()
+
+ set(${out_var} "${deployment_supported}" PARENT_SCOPE)
+ set(${out_var_reason} "${not_supported_reason}" PARENT_SCOPE)
+endfunction()
+
+function(_qt_internal_should_skip_deployment_api out_var out_var_reason)
+ set(skip_deployment FALSE)
+ _qt_internal_is_examples_deployment_supported_in_current_config(
+ deployment_supported
+ not_supported_reason
+ )
+
+ # Allow opting out of deployment, so that we can add deployment api to all our examples,
+ # but only run it in the CI for a select few, to avoid the overhead of deploying all examples.
+ if(QT_INTERNAL_SKIP_DEPLOYMENT OR (NOT deployment_supported))
+ set(skip_deployment TRUE)
+ endif()
+
+ set(reason "")
+ if(NOT deployment_supported)
+ set(reason "${not_supported_reason}")
+ elseif(QT_INTERNAL_SKIP_DEPLOYMENT)
+ set(reason "SKIP_REQUESTED")
+ endif()
+
+ set(${out_var} "${skip_deployment}" PARENT_SCOPE)
+ set(${out_var_reason} "${reason}" PARENT_SCOPE)
+endfunction()
+
+function(_qt_internal_should_skip_post_build_deployment_api out_var out_var_reason)
+ set(skip_deployment FALSE)
+ set(deployment_supported TRUE)
+
+ # Allow opting out of deployment, so that we can add deployment api to all our examples,
+ # but only run it in the CI for a select few, to avoid the overhead of deploying all examples.
+ if(QT_INTERNAL_SKIP_DEPLOYMENT OR (NOT deployment_supported))
+ set(skip_deployment TRUE)
+ endif()
+
+ set(reason "")
+ if(NOT deployment_supported)
+ set(reason "REASON_UNSPECIFIED")
+ elseif(QT_INTERNAL_SKIP_DEPLOYMENT)
+ set(reason "SKIP_REQUESTED")
+ endif()
+
+ set(${out_var} "${skip_deployment}" PARENT_SCOPE)
+ set(${out_var_reason} "${reason}" PARENT_SCOPE)
+endfunction()
+
+# Generate a deploy script that does nothing aside from showing a warning message.
+# The warning can be hidden by setting the QT_INTERNAL_HIDE_NO_OP_DEPLOYMENT_WARNING variable.
+function(_qt_internal_generate_no_op_deploy_script)
+ set(no_value_options
+ )
+ set(single_value_options
+ FUNCTION_NAME
+ NAME
+ OUTPUT_SCRIPT
+ SKIP_REASON
+ TARGET
+ )
+ set(multi_value_options
+ )
+
+ cmake_parse_arguments(PARSE_ARGV 0 arg
+ "${no_value_options}" "${single_value_options}" "${multi_value_options}"
+ )
+
+ if(NOT arg_OUTPUT_SCRIPT)
+ message(FATAL_ERROR "No OUTPUT_SCRIPT option specified")
+ endif()
+ if(NOT arg_FUNCTION_NAME)
+ message(FATAL_ERROR "No FUNCTION_NAME option specified")
+ endif()
+
+ set(generate_args "")
+ if(arg_NAME)
+ list(APPEND generate_args NAME "${arg_NAME}")
+ endif()
+ if(arg_TARGET)
+ list(APPEND generate_args TARGET "${arg_TARGET}")
+ endif()
+
+ set(function_name "${arg_FUNCTION_NAME}")
+
+ # The empty space is required, otherwise
+ set(content "
+message(DEBUG \"Running no-op deployment script because QT_INTERNAL_SKIP_DEPLOYMENT was ON.\")
+")
+ if(NOT QT_INTERNAL_HIDE_NO_OP_DEPLOYMENT_WARNING AND arg_SKIP_REASON STREQUAL "PREFIX_BUILD")
+ set(content "
+message(STATUS \"${function_name}(TARGET ${arg_TARGET}) is a no-op for prefix \"
+\"non-standalone builds due to various issues. Consider using a -no-prefix build \"
+\"or qt-internal-configure-tests or qt-internal-configure-examples if you want deployment to run.\")
+")
+ endif()
+
+ qt6_generate_deploy_script(
+ ${generate_args}
+ OUTPUT_SCRIPT deploy_script
+ CONTENT "${content}")
+
+ set("${arg_OUTPUT_SCRIPT}" "${deploy_script}" PARENT_SCOPE)
+endfunction()
+
# We basically mirror CMake's policy setup
# A policy can be set to OLD, set to NEW or unset
# unset is the default state
@@ -3570,7 +3685,14 @@ function(qt6_generate_deploy_app_script)
endif()
endforeach()
- if(APPLE AND NOT IOS AND QT6_IS_SHARED_LIBS_BUILD)
+ _qt_internal_should_skip_deployment_api(skip_deployment skip_reason)
+ if(skip_deployment)
+ _qt_internal_generate_no_op_deploy_script(
+ FUNCTION_NAME "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)