CMake: Allow configuring a minimal subset of examples to deploy

When building examples as part of Qt in the CI, it's best to skip
running deployment for all examples to save resources
(space and time).

Add a QT_DEPLOY_MINIMAL_EXAMPLES option similar to our
QT_BUILD_MINIMAL_STATIC_TESTS option, which will set
QT_INTERNAL_SKIP_DEPLOYMENT at the root examples directory scope, to
skip deployment for all examples.
Each example can then opt into the minimal subset by unsetting the
QT_INTERNAL_SKIP_DEPLOYMENT variable before its
qt_internal_add_example call.

Add Coin instructions to enable this option when building our examples
in the CI.

Task-number: QTBUG-90820
Task-number: QTBUG-96232
Task-number: QTBUG-102057
Change-Id: I2efcda455b400c27fe1efd1bcf81b133137fa2d1
Reviewed-by:  Alexey Edelev <alexey.edelev@qt.io>
(cherry picked from commit 224b7c6b6a2a425487df19643709d105e8f3cdd5)
Reviewed-by:  Alexey Edelev <alexey.edelev@qt.io>
This commit is contained in:
Alexandru Croitor 2024-03-13 19:03:19 +01:00
parent bc227037b8
commit 665fd3848f
3 changed files with 20 additions and 0 deletions

View File

@ -323,6 +323,9 @@ macro(qt_internal_setup_build_examples)
"Should examples be built as part of the default 'all' target." FORCE)
endif()
option(QT_DEPLOY_MINIMAL_EXAMPLES
"Deploy minimal subset of examples to save time and space" OFF)
# FIXME: Support prefix builds as well QTBUG-96232
# We don't want to enable EP examples with -debug-and-release because starting with CMake 3.24
# ExternalProject_Add ends up creating build rules twice, once for each configuration, in the

View File

@ -11,6 +11,14 @@ macro(qt_examples_build_begin)
# Examples are not unity-ready.
set(CMAKE_UNITY_BUILD OFF)
# Skip running deployment steps when the developer asked to deploy a minimal subset of examples.
# Each example can then decide whether it wants to be deployed as part of the minimal subset
# by unsetting the QT_INTERNAL_SKIP_DEPLOYMENT variable before its qt_internal_add_example call.
# This will be used by our CI.
if(NOT DEFINED QT_INTERNAL_SKIP_DEPLOYMENT AND QT_DEPLOY_MINIMAL_EXAMPLES)
set(QT_INTERNAL_SKIP_DEPLOYMENT TRUE)
endif()
# Use by qt_internal_add_example.
set(QT_EXAMPLE_BASE_DIR "${CMAKE_CURRENT_SOURCE_DIR}")
@ -407,6 +415,7 @@ function(qt_internal_add_example_external_project subdir)
QT_BUILD_CMAKE_PREFIX_PATH:STRING
QT_ADDITIONAL_PACKAGES_PREFIX_PATH:STRING
QT_ADDITIONAL_QML_PLUGIN_GLOB_PREFIXES:STRING
QT_INTERNAL_SKIP_DEPLOYMENT:BOOL
CMAKE_FIND_ROOT_PATH:STRING
CMAKE_MODULE_PATH:STRING
BUILD_SHARED_LIBS:BOOL

View File

@ -536,6 +536,8 @@ instructions:
# Specify a custom examples installation directory, so that the built example binaries are not
# packaged into the artifact archive together with the Qt libraries.
# Also specify that during examples deployment, only a subset of examples should be deployed, to
# save time and space.
- type: Group
instructions:
- type: AppendToEnvironmentVariable
@ -544,6 +546,12 @@ instructions:
- type: AppendToEnvironmentVariable
variableName: COMMON_TARGET_CMAKE_ARGS
variableValue: " -DQT_INTERNAL_EXAMPLES_INSTALL_PREFIX={{unixPathSeparators .BuildDir}}/installed_examples"
- type: AppendToEnvironmentVariable
variableName: COMMON_CMAKE_ARGS
variableValue: " -DQT_DEPLOY_MINIMAL_EXAMPLES=ON"
- type: AppendToEnvironmentVariable
variableName: COMMON_TARGET_CMAKE_ARGS
variableValue: " -DQT_DEPLOY_MINIMAL_EXAMPLES=ON"
- type: Group
instructions:
- type: AppendToEnvironmentVariable