diff options
author | Alexey Edelev <alexey.edelev@qt.io> | 2021-06-03 13:51:48 +0200 |
---|---|---|
committer | Alexey Edelev <alexey.edelev@qt.io> | 2021-06-10 15:17:55 +0200 |
commit | 4e901a2f99cbfda3b479253ea54b16f02e1c3aa5 (patch) | |
tree | b4567bb4dfb970c038e56c5dc86496c266c2668b /cmake/QtBuildInternals | |
parent | 60e104aed84759f1e0cf324f47781eed5b055761 (diff) |
Add the check for linker capabilities to resolve circular dependencies
'ld' only capable to resolve circular dependencies by wrapping the
suspected static libraries and objects using --start/end-group
arguments. We want to detect if linker is 'ld' at configure time to
decide how to link the resource objects if finalizers are not enabled.
The qt_config_compile_test function is extended with an extra argument
since it's required to pass custom cmake flags to the ld-related test.
Pick-to: 6.2
Change-Id: I484fcc99e2886952d8b0232f37e4e6a35d072931
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Diffstat (limited to 'cmake/QtBuildInternals')
-rw-r--r-- | cmake/QtBuildInternals/QtBuildInternalsConfig.cmake | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/cmake/QtBuildInternals/QtBuildInternalsConfig.cmake b/cmake/QtBuildInternals/QtBuildInternalsConfig.cmake index 2ed51f5685..ad0025da7c 100644 --- a/cmake/QtBuildInternals/QtBuildInternalsConfig.cmake +++ b/cmake/QtBuildInternals/QtBuildInternalsConfig.cmake @@ -372,6 +372,11 @@ macro(qt_build_repo_begin) qt_build_internals_set_up_private_api() qt_enable_cmake_languages() + # QtBase has own call right after definition of internal platform-specific targets. + if(NOT PROJECT_NAME STREQUAL "QtBase") + qt_internal_run_common_config_tests() + endif() + # Add global docs targets that will work both for per-repo builds, and super builds. if(NOT TARGET docs) add_custom_target(docs) @@ -941,3 +946,36 @@ if ("STANDALONE_TEST" IN_LIST Qt6BuildInternals_FIND_COMPONENTS) list(GET _qt_core_version_list 2 PROJECT_VERSION_PATCH) endif() endif() + +function(qt_internal_static_link_order_test) + if(TARGET ${QT_CMAKE_EXPORT_NAMESPACE}::PlatformCommonInternal) + get_target_property(linker_options + ${QT_CMAKE_EXPORT_NAMESPACE}::PlatformCommonInternal INTERFACE_LINK_OPTIONS + ) + string(JOIN " " linker_options ${linker_options}) + endif() + + qt_config_compile_test(static_link_order + LABEL "Check if linker can resolve circular dependencies" + PROJECT_PATH "${QT_CMAKE_DIR}/config.tests/static_link_order" + CMAKE_FLAGS "-DCMAKE_EXE_LINKER_FLAGS:STRING=${linker_options}" + ) + + if(TEST_static_link_order) + set_property(GLOBAL PROPERTY QT_LINK_ORDER_MATTERS FALSE) + set(summary_message "no") + else() + set_property(GLOBAL PROPERTY QT_LINK_ORDER_MATTERS TRUE) + set(summary_message "yes") + endif() + qt_configure_add_summary_entry(TYPE "message" + ARGS "Linker can resolve circular dependencies" + MESSAGE "${summary_message}" + ) +endfunction() + +function(qt_internal_run_common_config_tests) + qt_configure_add_summary_section(NAME "Common build options") + qt_internal_static_link_order_test() + qt_configure_end_summary_section() +endfunction() |