diff --git a/cmake/QtBuild.cmake b/cmake/QtBuild.cmake index 25756c89d90..08bc66b358c 100644 --- a/cmake/QtBuild.cmake +++ b/cmake/QtBuild.cmake @@ -1024,7 +1024,14 @@ function(qt_register_target_dependencies target public_libs private_libs) set(target_deps "") endif() - foreach(lib IN LISTS public_libs private_libs) + # Only process private dependencies if target is a static library + get_target_property(target_type ${target} TYPE) + set(lib_list ${public_libs}) + if (target_type STREQUAL "STATIC_LIBRARY") + list(APPEND lib_list ${private_libs}) + endif() + + foreach(lib IN LISTS lib_list) if ("${lib}" MATCHES "^Qt::(.*)") set(lib "${CMAKE_MATCH_1}") if (lib STREQUAL Platform diff --git a/cmake/QtPostProcess.cmake b/cmake/QtPostProcess.cmake index afd1cfd1dd2..19cd4b699b7 100644 --- a/cmake/QtPostProcess.cmake +++ b/cmake/QtPostProcess.cmake @@ -68,9 +68,11 @@ function(qt_internal_create_module_depends_file target) set(arg_HEADER_MODULE OFF) endif() - if(NOT arg_HEADER_MODULE) + set(depends "") + if(target_type STREQUAL "STATIC_LIBRARY" AND NOT arg_HEADER_MODULE) get_target_property(depends "${target}" LINK_LIBRARIES) endif() + get_target_property(public_depends "${target}" INTERFACE_LINK_LIBRARIES) # Used for collecting Qt module dependencies that should be find_package()'d in