diff --git a/cmake/QtPublicWalkLibsHelpers.cmake b/cmake/QtPublicWalkLibsHelpers.cmake index 7aa26c1af00..d0826e08a27 100644 --- a/cmake/QtPublicWalkLibsHelpers.cmake +++ b/cmake/QtPublicWalkLibsHelpers.cmake @@ -186,9 +186,19 @@ function(__qt_internal_walk_libs # Unwrap targets like $> while(lib_target MATCHES "^\\$<(LINK_ONLY|BUILD_INTERFACE|BUILD_LOCAL_INTERFACE):(.*)>$") - set(lib_target ${CMAKE_MATCH_2}) + set(lib_target "${CMAKE_MATCH_2}") endwhile() + # If one of the values is "$>", this will be + # exported by cmake as "$", which will become an empty value after the + # unwrapping above. + # In that case, skip the processing. Otherwise in some weird unknown conditions, + # CMake might consider the empty name to be a valid target, and cause errors further + # down. + if("${lib_target}" STREQUAL "") + continue() + endif() + # 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.