CMake: Prevent infinite loop when generating module .pri files

CMake find modules of third-party libraries may create dependency cycles
in their imported library targets. For example, Conan's Vulkan::Vulkan
is such a candidate.

Prevent an infinite loop when generating .pri files for Qt modules that
link against such targets.

Pick-to: 6.5 6.6
Fixes: QTBUG-95569
Change-Id: I09b4a281930f7c6ce5e8c716fe0ab91e2453a24a
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
This commit is contained in:
Joerg Bornemann 2023-07-10 10:17:55 +02:00
parent 00bdf56b83
commit f7b7262f11

View File

@ -26,9 +26,14 @@ function(qt_generate_qmake_libraries_pri_content module_name output_root_dir out
set(lib_incdir "") set(lib_incdir "")
set(lib_libdir "") set(lib_libdir "")
set(lib_libs "") set(lib_libs "")
set(seen_targets "")
while(lib_targets) while(lib_targets)
list(POP_BACK lib_targets lib_target) list(POP_BACK lib_targets lib_target)
if(TARGET ${lib_target}) if(TARGET ${lib_target})
if(${lib_target} IN_LIST seen_targets)
continue()
endif()
list(APPEND seen_targets ${lib_target})
get_target_property(lib_target_type ${lib_target} TYPE) get_target_property(lib_target_type ${lib_target} TYPE)
if(lib_target_type STREQUAL "INTERFACE_LIBRARY") if(lib_target_type STREQUAL "INTERFACE_LIBRARY")
get_target_property(iface_libs ${lib_target} INTERFACE_LINK_LIBRARIES) get_target_property(iface_libs ${lib_target} INTERFACE_LINK_LIBRARIES)