diff options
author | Alexandru Croitor <alexandru.croitor@qt.io> | 2021-08-06 15:51:52 +0200 |
---|---|---|
committer | Alexandru Croitor <alexandru.croitor@qt.io> | 2021-08-10 16:51:53 +0200 |
commit | dfabb5b6775b21b98ba86cb93cb0d41173878f1b (patch) | |
tree | cf719efff7af8ff448fe9cb7aa275f119c81da51 /cmake | |
parent | 5161d8d525650ac74a3571b13bb8b35dbf413e59 (diff) |
CMake: Use __qt_internal_propagate_object_library for static plugins
Address TODO and use the new helper
__qt_internal_propagate_object_library function instead of
target_sources when linking static plugin initializers via usage
requirements.
Note that to work correctly this depends on using the
target_link_options object library linking approach, which means a
minimum CMake version of 3.17, which is already the case for static
Qt usage.
With CMake 3.21, it will use target_link_libraries approach instead.
With CMake version 3.16 or lower, currently, this won't work correctly
on Linux if there are dependencies wrapped in genexes because the
__qt_internal_propagate_object_library call will try to use
the still-by-default-enabled 'object_libraries' finalizer mode via
__qt_internal_collect_dependency_object_libraries and that stops
the usage of the target_sources approach to link the object files
directly.
This isn't a big deal though, because we already require CMake 3.20
as the minimum.
It might be a bigger deal if we will need any of this functionality
to work with 3.16 in shared Qt builds where the user project tries
to create and link against custom static plugins. But that's already
likely to be a can of worms even without this specific edge case.
Amends a37957df5c1d3d8624fae2222734a127ec340a72
Amends 91c65dd80cdd2de666448c14202c0c63718152b6
Uses 3329212815777e33dfb4697b748d10927d73f44c
Pick-to: 6.2
Task-number: QTBUG-92933
Change-Id: I8710e79eee265d820f65c8ccc3d0bd0c0ee6eccd
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
Diffstat (limited to 'cmake')
-rw-r--r-- | cmake/QtPublicPluginHelpers.cmake | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/cmake/QtPublicPluginHelpers.cmake b/cmake/QtPublicPluginHelpers.cmake index 913dede6bf..fed9e4264b 100644 --- a/cmake/QtPublicPluginHelpers.cmake +++ b/cmake/QtPublicPluginHelpers.cmake @@ -193,13 +193,12 @@ function(__qt_internal_add_static_plugin_import_macro qt_module_unprefixed) __qt_internal_get_static_plugin_init_target_name("${plugin_target}" plugin_init_target) - set(objs_genex "$<TARGET_OBJECTS:${QT_CMAKE_EXPORT_NAMESPACE}::${plugin_init_target}>") + set(plugin_init_target_namespaced "${QT_CMAKE_EXPORT_NAMESPACE}::${plugin_init_target}") - # TODO: Replace the target_sources call here with the more generalized approach that will be - # added to __qt_propagate_generated_resource (the one that determines whether to use - # target_sources or target_link_libraries depending on the CMake version). - target_sources(${QT_CMAKE_EXPORT_NAMESPACE}::${plugin_target} INTERFACE - "${objs_genex}") + __qt_internal_propagate_object_library( + "${QT_CMAKE_EXPORT_NAMESPACE}::${plugin_target}" + "${plugin_init_target_namespaced}" + ) endfunction() # Get target name of object library which is used to initialize a qt plugin. |