Skip to content

Commit

Permalink
Remove target specific flags from the linker capabilities check
Browse files Browse the repository at this point in the history
Remove target specific flags from static_link_order.
Move the check to the common config.tests folder.

Amends 5fb99e3

Pick-to: 6.2
Task-number: QTBUG-93002
Task-number: QTBUG-94528
Change-Id: I1368075ec6bd1e743b2b89fd93143df38a278ec2
Reviewed-by: Alexandru Croitor <[email protected]>
  • Loading branch information
semlanik committed Jun 16, 2021
1 parent 335123f commit 13a4de6
Show file tree
Hide file tree
Showing 9 changed files with 20 additions and 35 deletions.
4 changes: 2 additions & 2 deletions cmake/QtBaseGlobalTargets.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -240,8 +240,8 @@ qt_copy_or_install(FILES

# Install public config.tests files.
qt_copy_or_install(DIRECTORY
"cmake/config.tests"
DESTINATION "${__GlobalConfig_install_dir}"
"config.tests/static_link_order"
DESTINATION "${__GlobalConfig_install_dir}/config.tests"
)

# Install public CMake files.
Expand Down
2 changes: 1 addition & 1 deletion cmake/QtBuildInternals/QtBuildInternalsConfig.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -962,7 +962,7 @@ function(qt_internal_static_link_order_test)
# TODO: This check is added before the actual release of CMake 3.21. So need to check if the
# target version meets the expectations.
if(CMAKE_VERSION VERSION_LESS 3.21)
__qt_internal_check_link_order_matters(${QT_CMAKE_EXPORT_NAMESPACE}::Platform)
__qt_internal_check_link_order_matters(link_order_matters)
if(link_order_matters)
set(summary_message "no")
else()
Expand Down
2 changes: 1 addition & 1 deletion cmake/QtConfig.cmake.in
Original file line number Diff line number Diff line change
Expand Up @@ -111,4 +111,4 @@ if (_Qt_NOTFOUND_MESSAGE)
endif()

__qt_internal_defer_promote_targets_in_dir_scope_to_global()
__qt_internal_check_link_order_matters(@INSTALL_CMAKE_NAMESPACE@::Platform)
__qt_internal_check_link_order_matters()
47 changes: 16 additions & 31 deletions cmake/QtPublicTargetHelpers.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -16,49 +16,30 @@ function(__qt_internal_strip_target_directory_scope_token target out_var)
endfunction()

# Tests if linker could resolve circular dependencies between object files and static libraries.
function(__qt_internal_static_link_order_public_test target result)
function(__qt_internal_static_link_order_public_test result)
# We could trust iOS linker
if(IOS)
set(QT_HAVE_LINK_ORDER_MATTERS_${target} "FALSE" CACHE BOOL "Link order matters")
set(QT_HAVE_LINK_ORDER_MATTERS "FALSE" CACHE BOOL "Link order matters")
endif()

if(DEFINED QT_HAVE_LINK_ORDER_MATTERS_${target})
set(${result} "${QT_HAVE_LINK_ORDER_MATTERS_${target}}" PARENT_SCOPE)
if(DEFINED QT_HAVE_LINK_ORDER_MATTERS)
set(${result} "${QT_HAVE_LINK_ORDER_MATTERS}" PARENT_SCOPE)
return()
endif()

set(link_options_property LINK_OPTIONS)
set(compile_definitions_property COMPILE_DEFINITIONS)
get_target_property(type ${target} TYPE)
if(type STREQUAL "INTERFACE_LIBRARY")
set(link_options_property INTERFACE_LINK_OPTIONS)
set(compile_definitions_property INTERFACE_COMPILE_DEFINITIONS)
endif()

get_target_property(linker_options ${target} ${link_options_property})
get_target_property(compile_definitions ${target} ${compile_definitions_property})
set(linker_options "${CMAKE_EXE_LINKER_FLAGS} ${linker_options}")
set(compile_definitions "${CMAKE_CXX_FLAGS} ${compile_definitions}")

if(EXISTS "${QT_CMAKE_DIR}")
set(test_source_basedir "${QT_CMAKE_DIR}")
set(test_source_basedir "${QT_CMAKE_DIR}/..")
else()
set(test_source_basedir "${_qt_cmake_dir}/${QT_CMAKE_EXPORT_NAMESPACE}")
endif()

set(test_subdir "${target}")
string(TOLOWER "${test_subdir}" test_subdir)
string(MAKE_C_IDENTIFIER "${test_subdir}" test_subdir)
try_compile(${result}
"${CMAKE_CURRENT_BINARY_DIR}/${test_subdir}/config.tests/static_link_order"
"${CMAKE_CURRENT_BINARY_DIR}/config.tests/static_link_order"
"${test_source_basedir}/config.tests/static_link_order"
static_link_order_test
static_link_order_test
CMAKE_FLAGS "-DCMAKE_EXE_LINKER_FLAGS:STRING=${linker_options}"
"-DCMAKE_CXX_FLAGS:STRING=${compile_definitions}"
)
message(STATUS "Check if linker can resolve circular dependencies for target ${target} \
- ${${result}}")
message(STATUS "Check if linker can resolve circular dependencies - ${${result}}")

# Invert the result
if(${result})
Expand All @@ -67,7 +48,7 @@ function(__qt_internal_static_link_order_public_test target result)
set(${result} TRUE)
endif()

set(QT_HAVE_LINK_ORDER_MATTERS_${target} "${${result}}" CACHE BOOL "Link order matters")
set(QT_HAVE_LINK_ORDER_MATTERS "${${result}}" CACHE BOOL "Link order matters")

set(${result} "${${result}}" PARENT_SCOPE)
endfunction()
Expand All @@ -92,14 +73,18 @@ function(__qt_internal_set_link_order_matters target link_order_matters)
endfunction()

# Function combines __qt_internal_static_link_order_public_test and
# __qt_internal_set_link_order_matters calls for the target.
function(__qt_internal_check_link_order_matters target)
# __qt_internal_set_link_order_matters calls on Qt::Platform target.
function(__qt_internal_check_link_order_matters)
__qt_internal_static_link_order_public_test(
${target} link_order_matters
link_order_matters
)
__qt_internal_set_link_order_matters(
${target} "${link_order_matters}"
${QT_CMAKE_EXPORT_NAMESPACE}::Platform "${link_order_matters}"
)

if("${ARGC}" GREATER "0" AND NOT ARGV0 STREQUAL "")
set(${ARGV0} ${link_order_matters} PARENT_SCOPE)
endif()
endfunction()

function(__qt_internal_process_dependency_resource_objects target)
Expand Down
File renamed without changes.
File renamed without changes.

0 comments on commit 13a4de6

Please sign in to comment.