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>
This commit is contained in:
parent
2e6de6f8b2
commit
a804ac3d88
@ -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)
|
||||
|
@ -296,6 +296,12 @@ function(qt_internal_add_plugin target)
|
||||
if(TARGET qt_plugins)
|
||||
add_dependencies(qt_plugins "${target}")
|
||||
endif()
|
||||
|
||||
# Record plugin for current repo.
|
||||
if(qt_repo_plugins AND TARGET ${qt_repo_plugins})
|
||||
add_dependencies(${qt_repo_plugins} "${target}")
|
||||
endif()
|
||||
|
||||
if(plugin_type STREQUAL "platforms")
|
||||
if(TARGET qpa_plugins)
|
||||
add_dependencies(qpa_plugins "${target}")
|
||||
|
Loading…
x
Reference in New Issue
Block a user