This is an alternative to #19751 that fixes the build without requiring splitting out libpng. This patch can be dropped once we are building qt 5.12.0 or later.