From 335123f240c0b59cc62ad151dcf185160ef33696 Mon Sep 17 00:00:00 2001 From: Alexandru Croitor Date: Wed, 16 Jun 2021 14:56:13 +0200 Subject: [PATCH] CMake: Don't make example external projects depend on tests MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 d97fd7af2bc5c89a0ad9e5fac080041b78d01179 Pick-to: 6.2 Change-Id: I2860d8ae89728f33f6b73fede1335cd6d6290f78 Reviewed-by: Morten Johan Sørvig Reviewed-by: Tor Arne Vestbø --- .../QtBuildInternals/QtBuildInternalsConfig.cmake | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/cmake/QtBuildInternals/QtBuildInternalsConfig.cmake b/cmake/QtBuildInternals/QtBuildInternalsConfig.cmake index 8cbd0b566f..b4acfde3ac 100644 --- a/cmake/QtBuildInternals/QtBuildInternalsConfig.cmake +++ b/cmake/QtBuildInternals/QtBuildInternalsConfig.cmake @@ -667,11 +667,21 @@ macro(qt_examples_build_begin) # Examples will be built using ExternalProject. # We always depend on all plugins so as to prevent opportunities for # 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 # an example might use. Projects can add further dependencies if needed, # 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_IS_EXTERNAL_EXAMPLES_BUILD TRUE)