diff options
author | Alexey Edelev <alexey.edelev@qt.io> | 2021-06-10 19:01:35 +0200 |
---|---|---|
committer | Alexey Edelev <alexey.edelev@qt.io> | 2021-06-16 16:58:45 +0200 |
commit | 5fb99e3860eb43f4bacacec7f4a4626cb0159b14 (patch) | |
tree | 5f521fbb62d9408d42b3325e831eff5489eb78a0 /tests/auto/cmake | |
parent | 1f4b237dade9d0d2ed5439e3834ac22985797561 (diff) |
Check the impact of static link order for user projects
For user projects we run the static link order check once
'find_package(Qt6 ...)' is called.
If linker can resolve circular dependencies between static libraries
and object files we set the _qt_link_order_matters property of the
Qt::Platform target. This indicates the use of finalizers is not
required and we may rely on CMake-base propagation of resource
libraries and resource object files.
If linker could not resolve circular dependencies depending on
the _qt_resource_objects_finalizer_mode value:
- Finalizer will be called and collected resource objects will be
linked to the target directly.
- Finalizer will be omitted and resource objects will be linked
using the target_sources function implicitly. This only
propagates resource one level up if consumer links the static
library PUBLICly, but all symbols will be resolved correctly
since object files are placed in the beginning of the linker line.
In the CMake version 3.21 we expect that CMake will take care about
the order of the resource object files in a linker line, it's
expected that all object files are located at the beginning of the
linker line.
TODO: Need to confirm that the CMake 3.21 meets the expectations.
Amends 4e901a2f99cbfda3b479253ea54b16f02e1c3aa5
Pick-to: 6.2
Task-number: QTBUG-93002
Task-number: QTBUG-94528
Change-Id: Ia68976df8182d3d3007b90c475c1e3928a305339
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Diffstat (limited to 'tests/auto/cmake')
-rw-r--r-- | tests/auto/cmake/test_static_resources/test_static_resources_propagation/CMakeLists.txt | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/tests/auto/cmake/test_static_resources/test_static_resources_propagation/CMakeLists.txt b/tests/auto/cmake/test_static_resources/test_static_resources_propagation/CMakeLists.txt index f8f46e14f4..58a7c4147a 100644 --- a/tests/auto/cmake/test_static_resources/test_static_resources_propagation/CMakeLists.txt +++ b/tests/auto/cmake/test_static_resources/test_static_resources_propagation/CMakeLists.txt @@ -58,9 +58,13 @@ add_test(NAME test_static_resources_propagation_non_qt COMMAND test_static_resources_propagation_non_qt ) -get_property(link_order_matters GLOBAL PROPERTY QT_LINK_ORDER_MATTERS) +get_target_property(link_order_matters + ${QT_CMAKE_EXPORT_NAMESPACE}::Platform + _qt_link_order_matters +) + if(NOT link_order_matters) - ## Add the executable using add_executable, expecting resources to be linked regardless of order. + # Add the executable using add_executable, expecting resources to be linked regardless of order. add_executable(test_static_resources_propagation_non_ld main.cpp) set_target_properties(test_static_resources_propagation_non_ld PROPERTIES AUTOMOC TRUE |