I compared the files Qt5Network/Qt5NetworkConfig.cmake and Qt5Widgets/Qt5WidgetsConfig.cmake. Besides the trivial substitution “Network” -> “Widgets” and a few references to functions from the respective libraries, there is just one big difference: Qt5WidgetsConfig.cmake has the lines
Doubt it. Both of those files are the Qt framework asking each component “I’ve exported all of your targets in CMake. Do you have anything else to put into CMake?” It seems that for Qt5Widgets the answer is “yes”, but for Qt5Network the answer is “no”. But Qt5Network should still have the imported target.
Kyle, I’m still puzzled by your latest response. Sounds really close to the decisive point, but too arcane for me to follow. Could you possibly elaborate a bit?
Also, I am no longer sure whether the anomaly is the absence of Qt5Network, or rather the presence of the three other libraries. Would CMake by default copy any DLL dependence to CMAKE_RUNTIME_OUTPUT_DIRECTORY?
Some of the modules in Qt export extra CMake macros, configuration variables, etc. These have to be placed in Qt5<module>ConfigExtras.cmake and Qt5<module>Macros.cmake. However, not all of them do, and the ones that don’t, don’t get these files included in their Qt5<module>Config.cmake. That’s why you’re seeing that diff, and I don’t think it has anything to do with why Qt5Network isn’t getting copied in.
Here’s a shot in the dark: try moving Qt5::Network to the end of the list and see if you get the same result.
Indeed, the strange behavior is the copying of Qt5Widgets.dll etc.
By bisectioning my real application, I found out that it is caused not by the code communicated in my original post, but by an obscure PackIFW script that calls windeployqt.exe.