From 0bb503cd277e32895a74ad058f03a4c51a865b4a Mon Sep 17 00:00:00 2001 From: Alexandru Croitor Date: Wed, 16 Jun 2021 18:00:26 +0200 Subject: CMake: Assign output targets to appropriate export sets Plugin initializer targets should go to the plugin export set. The rest of the output targets (resources and qmlcache object libraries for now) should go the main backing target export set. Also generate the missing additional target info files for each export set. Pick-to: 6.2 Task-number: QTBUG-93257 Task-number: QTBUG-92933 Change-Id: I0b13a15459f3c6379bf87de1819fda97ade8c416 Reviewed-by: Alexandru Croitor Reviewed-by: Ulf Hermann Reviewed-by: Alexey Edelev --- src/qml/Qt6QmlBuildInternals.cmake | 55 +++++++++++++++++++++++++++++++------- 1 file changed, 46 insertions(+), 9 deletions(-) (limited to 'src/qml/Qt6QmlBuildInternals.cmake') diff --git a/src/qml/Qt6QmlBuildInternals.cmake b/src/qml/Qt6QmlBuildInternals.cmake index 5dd451554d..8cae67905b 100644 --- a/src/qml/Qt6QmlBuildInternals.cmake +++ b/src/qml/Qt6QmlBuildInternals.cmake @@ -259,17 +259,54 @@ function(qt_internal_add_qml_module target) ${add_qml_module_args} OUTPUT_DIRECTORY ${arg_OUTPUT_DIRECTORY} RESOURCE_PREFIX "/qt-project.org/imports" - OUTPUT_TARGETS resource_targets + OUTPUT_TARGETS output_targets ) - if(resource_targets) - qt_install(TARGETS ${resource_targets} - EXPORT "${INSTALL_CMAKE_NAMESPACE}${target}Targets" - DESTINATION "${arg_INSTALL_DIRECTORY}" - ) - qt_internal_record_rcc_object_files(${target} "${resource_targets}" - INSTALL_DIRECTORY "${arg_INSTALL_DIRECTORY}" - ) + if(output_targets) + set(plugin_export_targets) + set(backing_lib_export_targets) + + # Separate which output target should go to which export set. + # The plugin initializer library should go to the plugin export set, the rest should go to + # the backing lib export set. + # In the case when the plugin target is the same as the backing lib target, all of the + # output targets will go to the plugin export set. + + foreach(output_target IN LISTS output_targets) + get_target_property(is_plugin_init ${output_target} _is_qt_plugin_init_target) + if(is_plugin_init) + list(APPEND plugin_export_targets ${output_target}) + else() + list(APPEND backing_lib_export_targets ${output_target}) + endif() + endforeach() + + if(backing_lib_export_targets) + qt_install(TARGETS ${backing_lib_export_targets} + EXPORT "${INSTALL_CMAKE_NAMESPACE}${target}Targets" + DESTINATION "${arg_INSTALL_DIRECTORY}" + ) + qt_internal_record_rcc_object_files(${target} "${backing_lib_export_targets}" + INSTALL_DIRECTORY "${arg_INSTALL_DIRECTORY}" + ) + + qt_internal_add_targets_to_additional_targets_export_file( + TARGETS ${backing_lib_export_targets} + EXPORT_NAME_PREFIX "${INSTALL_CMAKE_NAMESPACE}${target}" + ) + endif() + + if(arg_PLUGIN_TARGET AND plugin_export_targets) + qt_install(TARGETS ${plugin_export_targets} + EXPORT "${INSTALL_CMAKE_NAMESPACE}${arg_PLUGIN_TARGET}Targets" + DESTINATION "${arg_INSTALL_DIRECTORY}" + ) + + qt_internal_add_targets_to_additional_targets_export_file( + TARGETS ${plugin_export_targets} + EXPORT_NAME_PREFIX "${INSTALL_CMAKE_NAMESPACE}${arg_PLUGIN_TARGET}" + ) + endif() endif() if(DEFINED arg_QML_FILES OR DEFINED arg_RESOURCES) -- cgit v1.2.3