mirror of https://github.com/qt/qtbase.git
CMake: Move qt_internal_work_around_autogen_discarded_dependencies
Move it to a public Helpers file, so we can call it also from public
API, because there are cases when we need the workaround for public
API calls as well.
Amends fcb2058631
Pick-to: 6.5 6.8 6.9 6.10
Task-number: QTBUG-133725
Task-number: QTBUG-137587
Change-Id: I9aef59f5eadc78fd581b24790e6b69795c32c1bf
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
This commit is contained in:
parent
dd262d8e2d
commit
e5510913a1
|
@ -215,49 +215,3 @@ function(qt_make_output_file infile prefix suffix source_dir binary_dir result)
|
|||
set("${result}" "${outpath}/${prefix}${outfilename}${suffix}" PARENT_SCOPE)
|
||||
endfunction()
|
||||
|
||||
# Work around AUTOGEN issue when a library is added as a dependency more than once, and the autogen
|
||||
# library dependency results in being discarded. To mitigate that, add all autogen dependencies
|
||||
# manually, based on the passed in dependencies.
|
||||
# CMake 4.0+ has a fix, so we don't need the extra logic.
|
||||
# See https://gitlab.kitware.com/cmake/cmake/-/issues/26700
|
||||
function(qt_internal_work_around_autogen_discarded_dependencies target)
|
||||
if(CMAKE_VERSION VERSION_GREATER_EQUAL 4.0
|
||||
OR QT_NO_AUTOGEN_DISCARDED_DEPENDENCIES_WORKAROUND)
|
||||
return()
|
||||
endif()
|
||||
|
||||
set(libraries ${ARGN})
|
||||
set(final_libraries "")
|
||||
|
||||
foreach(lib IN LISTS libraries)
|
||||
# Skip non-target dependencies.
|
||||
if(NOT TARGET "${lib}")
|
||||
continue()
|
||||
endif()
|
||||
|
||||
# Resolve alias targets, because AUTOGEN_TARGET_DEPENDS doesn't seem to handle them.
|
||||
_qt_internal_dealias_target(lib)
|
||||
|
||||
# Skip imported targets, they don't have sync_headers targets.
|
||||
get_target_property(imported "${lib}" IMPORTED)
|
||||
if(imported)
|
||||
continue()
|
||||
endif()
|
||||
|
||||
# Resolve Qt private modules to their public counterparts.
|
||||
get_target_property(is_private_module "${lib}" _qt_is_private_module)
|
||||
get_target_property(public_module_target "${lib}" _qt_public_module_target_name)
|
||||
|
||||
if(is_private_module AND public_module_target)
|
||||
set(lib "${public_module_target}")
|
||||
endif()
|
||||
|
||||
# Another TARGET check, just in case.
|
||||
if(TARGET "${lib}")
|
||||
list(APPEND final_libraries "${lib}")
|
||||
endif()
|
||||
endforeach()
|
||||
if(final_libraries)
|
||||
set_property(TARGET ${target} APPEND PROPERTY AUTOGEN_TARGET_DEPENDS "${final_libraries}")
|
||||
endif()
|
||||
endfunction()
|
||||
|
|
|
@ -18,6 +18,53 @@ function(__qt_internal_strip_target_directory_scope_token target out_var)
|
|||
set("${out_var}" "${target}" PARENT_SCOPE)
|
||||
endfunction()
|
||||
|
||||
# Work around AUTOGEN issue when a library is added as a dependency more than once, and the autogen
|
||||
# library dependency results in being discarded. To mitigate that, add all autogen dependencies
|
||||
# manually, based on the passed in dependencies.
|
||||
# CMake 4.0+ has a fix, so we don't need the extra logic.
|
||||
# See https://gitlab.kitware.com/cmake/cmake/-/issues/26700
|
||||
function(_qt_internal_work_around_autogen_discarded_dependencies target)
|
||||
if(CMAKE_VERSION VERSION_GREATER_EQUAL 4.0
|
||||
OR QT_NO_AUTOGEN_DISCARDED_DEPENDENCIES_WORKAROUND)
|
||||
return()
|
||||
endif()
|
||||
|
||||
set(libraries ${ARGN})
|
||||
set(final_libraries "")
|
||||
|
||||
foreach(lib IN LISTS libraries)
|
||||
# Skip non-target dependencies.
|
||||
if(NOT TARGET "${lib}")
|
||||
continue()
|
||||
endif()
|
||||
|
||||
# Resolve alias targets, because AUTOGEN_TARGET_DEPENDS doesn't seem to handle them.
|
||||
_qt_internal_dealias_target(lib)
|
||||
|
||||
# Skip imported targets, they don't have sync_headers targets.
|
||||
get_target_property(imported "${lib}" IMPORTED)
|
||||
if(imported)
|
||||
continue()
|
||||
endif()
|
||||
|
||||
# Resolve Qt private modules to their public counterparts.
|
||||
get_target_property(is_private_module "${lib}" _qt_is_private_module)
|
||||
get_target_property(public_module_target "${lib}" _qt_public_module_target_name)
|
||||
|
||||
if(is_private_module AND public_module_target)
|
||||
set(lib "${public_module_target}")
|
||||
endif()
|
||||
|
||||
# Another TARGET check, just in case.
|
||||
if(TARGET "${lib}")
|
||||
list(APPEND final_libraries "${lib}")
|
||||
endif()
|
||||
endforeach()
|
||||
if(final_libraries)
|
||||
set_property(TARGET ${target} APPEND PROPERTY AUTOGEN_TARGET_DEPENDS "${final_libraries}")
|
||||
endif()
|
||||
endfunction()
|
||||
|
||||
# Tests if linker could resolve circular dependencies between object files and static libraries.
|
||||
function(__qt_internal_static_link_order_public_test result)
|
||||
# We could trust iOS linker
|
||||
|
|
|
@ -235,7 +235,7 @@ function(qt_internal_extend_target target)
|
|||
endif()
|
||||
|
||||
set(all_libraries ${arg_LIBRARIES} ${arg_PUBLIC_LIBRARIES})
|
||||
qt_internal_work_around_autogen_discarded_dependencies(${target} ${all_libraries})
|
||||
_qt_internal_work_around_autogen_discarded_dependencies(${target} ${all_libraries})
|
||||
|
||||
if(QT_GENERATE_SBOM)
|
||||
set(sbom_args "")
|
||||
|
|
Loading…
Reference in New Issue