From 93df3de1f30b6f65b025b33e9cd73ad479295e59 Mon Sep 17 00:00:00 2001 From: Alexandru Croitor Date: Mon, 7 Oct 2024 16:11:52 +0200 Subject: [PATCH] CMake: Improve pri library handling for genexes and friends After 4dce218ac400afcb54aa2a85a0b27947fec583cb got merged, we started considering the INTERFACE_LINK_LIBRARIES property of UNKNOWN_LIBRARY targets in addition to INTERFACE_LIBRARY targets, when collecting dependencies for pri file generation. These can contain genexes like $ or $, which are not supported by file(GENERATE), or special directory scope tokens like ::@, which are not valid targets or library names. One such case was in the downstream vcpkg build of Qt which adds `$` to the INTERFACE_LINK_LIBRARIES of the Fontconfig::Fontconfig target. We strip or handle these cases for prl file generation as part of calling __qt_internal_walk_libs. Change the pri generation to handle them in a similar manner by copying over the same logic. Amends 4dce218ac400afcb54aa2a85a0b27947fec583cb Pick-to: 6.8 Fixes: QTBUG-129471 Change-Id: Id4a574ee2411f6d64179c419f352168fde1914d3 Reviewed-by: Joerg Bornemann --- cmake/QtPriHelpers.cmake | 28 ++++++++++++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) diff --git a/cmake/QtPriHelpers.cmake b/cmake/QtPriHelpers.cmake index 3b9d205c36d..7b023af6e3c 100644 --- a/cmake/QtPriHelpers.cmake +++ b/cmake/QtPriHelpers.cmake @@ -57,10 +57,34 @@ function(qt_generate_qmake_libraries_pri_content module_name output_root_dir out list(APPEND lib_incdir "${target_include_dir}") list(APPEND lib_defines "$") else() - if(lib_target MATCHES "/([^/]+).framework$") + # Strip any directory scope tokens. + __qt_internal_strip_target_directory_scope_token("${lib_target}" lib_target) + + # Skip CMAKE_DIRECTORY_ID_SEP. If a target_link_libraries is applied to a target + # that was defined in a different scope, CMake appends and prepends a special + # directory id separator. Filter those out. + if(lib_target MATCHES "^::@") + continue() + + elseif(lib_target MATCHES "^\\$$") + # Extract value of LINK_ONLY genex, because it can't be used in file(GENERATE) + set(lib_target "${CMAKE_MATCH_1}") + if(lib_target) + list(PREPEND lib_targets ${lib_target}) + endif() else() - list(APPEND lib_libs "${lib_target}") + # Regular library name, library path, or -lfoo-like flag. Check for emptiness. + if(lib_target) + list(APPEND lib_libs "${lib_target}") + endif() endif() endif() endwhile()