summaryrefslogtreecommitdiffstats
path: root/cmake/QtBuildInternals/QtBuildInternalsConfig.cmake
diff options
context:
space:
mode:
authorAlexandru Croitor <alexandru.croitor@qt.io>2023-02-06 16:51:40 +0100
committerAlexandru Croitor <alexandru.croitor@qt.io>2023-03-06 18:54:00 +0100
commita804ac3d881fb036619f323f64e778a9e00b181d (patch)
tree4b6d861e0a21620fbe15bdb74e1608d659857883 /cmake/QtBuildInternals/QtBuildInternalsConfig.cmake
parent2e6de6f8b27f4a3ed2fbaf2e393614ee8f09a043 (diff)
CMake: Relax example dependencies to be per-repo
When doing a top-level build with ExternalProject examples, it doesn't make sense to make qtbase examples depend on e.g. qtdeclarative plugins. Instead the qtbase example should only depend on plugins built in qtbase. Create per-repo custom targets that depend on all plugins built within that particular repo. Create an additional per-repo target which depends on all plugins built in that repo, as well as plugins from dependent repos. Use the latter as a dependency for examples built as part of the current repo. Repo dependencies are parsed from dependencies.yaml. Pick-to: 6.5 Fixes: QTBUG-110913 Change-Id: I149860cc549caf53271c9ea296eb7bac2a663715 Reviewed-by: Alexey Edelev <alexey.edelev@qt.io> Reviewed-by: Amir Masoud Abdol <amir.abdol@qt.io> Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
Diffstat (limited to 'cmake/QtBuildInternals/QtBuildInternalsConfig.cmake')
-rw-r--r--cmake/QtBuildInternals/QtBuildInternalsConfig.cmake30
1 files changed, 28 insertions, 2 deletions
diff --git a/cmake/QtBuildInternals/QtBuildInternalsConfig.cmake b/cmake/QtBuildInternals/QtBuildInternalsConfig.cmake
index 7d9fbcc392..bb067c3e92 100644
--- a/cmake/QtBuildInternals/QtBuildInternalsConfig.cmake
+++ b/cmake/QtBuildInternals/QtBuildInternalsConfig.cmake
@@ -457,6 +457,31 @@ macro(qt_build_repo_begin)
string(TOLOWER ${PROJECT_NAME} project_name_lower)
+ # Target to build all plugins that are part of the current repo.
+ set(qt_repo_plugins "qt_plugins_${project_name_lower}")
+ if(NOT TARGET ${qt_repo_plugins})
+ add_custom_target(${qt_repo_plugins})
+ endif()
+
+ # Target to build all plugins that are part of the current repo and the current repo's
+ # dependencies plugins. Used for external project example dependencies.
+ set(qt_repo_plugins_recursive "${qt_repo_plugins}_recursive")
+ if(NOT TARGET ${qt_repo_plugins_recursive})
+ add_custom_target(${qt_repo_plugins_recursive})
+ add_dependencies(${qt_repo_plugins_recursive} "${qt_repo_plugins}")
+ endif()
+
+ qt_internal_read_repo_dependencies(qt_repo_deps "${PROJECT_SOURCE_DIR}")
+ if(qt_repo_deps)
+ foreach(qt_repo_dep IN LISTS qt_repo_deps)
+ if(TARGET qt_plugins_${qt_repo_dep})
+ message(DEBUG
+ "${qt_repo_plugins_recursive} depends on qt_plugins_${qt_repo_dep}")
+ add_dependencies(${qt_repo_plugins_recursive} "qt_plugins_${qt_repo_dep}")
+ endif()
+ endforeach()
+ endif()
+
set(qt_repo_targets_name ${project_name_lower})
set(qt_docs_target_name docs_${project_name_lower})
set(qt_docs_prepare_target_name prepare_docs_${project_name_lower})
@@ -824,14 +849,15 @@ macro(qt_examples_build_begin)
if(arg_EXTERNAL_BUILD AND QT_BUILD_EXAMPLES_AS_EXTERNAL)
# Examples will be built using ExternalProject.
- # We always depend on all plugins so as to prevent opportunities for
+ # We depend on all plugins built as part of the current repo as well as current repo's
+ # dependencies plugins, 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'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 ${arg_DEPENDS})
+ set(QT_EXAMPLE_DEPENDENCIES ${qt_repo_plugins_recursive} ${arg_DEPENDS})
if(TARGET ${qt_repo_targets_name}_src)
list(APPEND QT_EXAMPLE_DEPENDENCIES ${qt_repo_targets_name}_src_for_examples)