CMake: Don't make example external projects depend on tests

Only depend on the ${project}_src and ${project}_tools targets.

This might exclude some non-obivous target dependencies, but we can
adjust that if needed.

This reduces the build.ninja file of qtbase + qtsvg form 341MB
to 41MB when configuring with tests and examples, as well as reduces
the processing time of calling ninja.

Amends d97fd7af2b

Pick-to: 6.2
Change-Id: I2860d8ae89728f33f6b73fede1335cd6d6290f78
Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
This commit is contained in:
Alexandru Croitor 2021-06-16 14:56:13 +02:00
parent 906c84a9a3
commit 335123f240

View File

@ -667,11 +667,21 @@ macro(qt_examples_build_begin)
# Examples will be built using ExternalProject. # Examples will be built using ExternalProject.
# We always depend on all plugins so as to prevent opportunities for # We always depend on all plugins so as to prevent opportunities for
# weird errors associated with loading out-of-date plugins from # weird errors associated with loading out-of-date plugins from
# unrelated Qt modules. We also depend on all targets from this repo # unrelated Qt modules.
# We also depend on all targets from this repo's src and tools subdirectories
# to ensure that we've built anything that a find_package() call within # to ensure that we've built anything that a find_package() call within
# an example might use. Projects can add further dependencies if needed, # an example might use. Projects can add further dependencies if needed,
# but that should rarely be necessary. # but that should rarely be necessary.
set(QT_EXAMPLE_DEPENDENCIES qt_plugins ${qt_repo_targets_name} ${arg_DEPENDS}) set(QT_EXAMPLE_DEPENDENCIES qt_plugins ${arg_DEPENDS})
if(TARGET ${qt_repo_targets_name}_src)
list(APPEND QT_EXAMPLE_DEPENDENCIES ${qt_repo_targets_name}_src)
endif()
if(TARGET ${qt_repo_targets_name}_tools)
list(APPEND QT_EXAMPLE_DEPENDENCIES ${qt_repo_targets_name}_tools)
endif()
set(QT_EXAMPLE_BASE_DIR ${CMAKE_CURRENT_SOURCE_DIR}) set(QT_EXAMPLE_BASE_DIR ${CMAKE_CURRENT_SOURCE_DIR})
set(QT_IS_EXTERNAL_EXAMPLES_BUILD TRUE) set(QT_IS_EXTERNAL_EXAMPLES_BUILD TRUE)