CMake: Add convenience custom targets to build Qt plugins
Add 3 new convenience custom targets: 'qt_plugins', 'qpa_plugins' and 'qpa_default_plugins'. Additionally, if we detect that an internal executable / test links against Gui, add a dependency on the 'qpa_default_plugins' custom target, so that if a developer configures Qt for the first time and then calls ninja 'tst_foo_check', we ensure the test will launch successfully because the default QPA plugin will also be built. Change-Id: If6dd70844b5effdf8a293f65f8785855cc85b132 Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
This commit is contained in:
parent
4fed50f4ab
commit
df9c7456d1
@ -235,6 +235,16 @@ macro(qt_build_repo_begin)
|
||||
add_custom_target(install_docs_docs)
|
||||
endif()
|
||||
|
||||
# Add global qt_plugins, qpa_plugins and qpa_default_plugins convenience custom targets.
|
||||
# Internal executables will add a dependency on the qpa_default_plugins target,
|
||||
# so that building and running a test ensures it won't fail at runtime due to a missing qpa
|
||||
# plugin.
|
||||
if(NOT TARGET qt_plugins)
|
||||
add_custom_target(qt_plugins)
|
||||
add_custom_target(qpa_plugins)
|
||||
add_custom_target(qpa_default_plugins)
|
||||
endif()
|
||||
|
||||
string(TOLOWER ${PROJECT_NAME} project_name_lower)
|
||||
|
||||
set(qt_docs_target_name docs_${project_name_lower})
|
||||
|
@ -147,4 +147,12 @@ function(qt_internal_add_executable name)
|
||||
${install_targets_default_args})
|
||||
endforeach()
|
||||
endif()
|
||||
|
||||
# If linking against Gui, make sure to also build the default QPA plugin.
|
||||
# This makes the experience of an initial Qt configuration to build and run one single
|
||||
# test / executable nicer.
|
||||
get_target_property(linked_libs "${name}" LINK_LIBRARIES)
|
||||
if("Qt::Gui" IN_LIST linked_libs AND TARGET qpa_default_plugins)
|
||||
add_dependencies("${name}" qpa_default_plugins)
|
||||
endif()
|
||||
endfunction()
|
||||
|
@ -140,6 +140,14 @@ function(qt_internal_add_plugin target)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
add_dependencies(qt_plugins "${target}")
|
||||
if(arg_TYPE STREQUAL "platforms")
|
||||
add_dependencies(qpa_plugins "${target}")
|
||||
endif()
|
||||
if(_default_plugin)
|
||||
add_dependencies(qpa_default_plugins "${target}")
|
||||
endif()
|
||||
|
||||
set_property(TARGET "${target}" PROPERTY QT_DEFAULT_PLUGIN "${_default_plugin}")
|
||||
set_property(TARGET "${target}" APPEND PROPERTY EXPORT_PROPERTIES "QT_PLUGIN_CLASS_NAME;QT_PLUGIN_TYPE;QT_MODULE;QT_DEFAULT_PLUGIN")
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user