cmake: Fix ZLIB::ZLIB global-promotion error during configure


Client-side request compression made QtGrpc link zlib directly. In the
system-zlib configuration that means finding WrapZLIB; qt_find_package()
then promotes that target's transitive deps, including ZLIB::ZLIB, to
GLOBAL scope.

If Protobuf was configured first, its find_package(ZLIB) already created
ZLIB::ZLIB in another directory scope. CMake forbids promoting an
imported target to GLOBAL from outside its creating scope, so configure
aborts. The meta-qt6 (Yocto) log shows this:

  -- Found ZLIB: .../recipe-sysroot-native/usr/lib/libz.so
  CMake Error (QtPublicTargetHelpers.cmake, set_property): Attempt to
  promote imported target "ZLIB::ZLIB" to global scope (by setting
  IMPORTED_GLOBAL) which is not built in this directory.
  src/grpc/CMakeLists.txt:8 (qt_find_package)

Only system-zlib builds reach this branch; bundled-zlib builds link
Qt::ZlibPrivate instead and are unaffected.

Disable global promotion for a pre-existing ZLIB::ZLIB before the
WrapZLIB lookup, mirroring the existing WrapProtoc handling in
Protobuf's configure.cmake.

Amends bdea8cf706d947951bfaaeaf20e1f742ad1b588a.

Pick-to: 6.12
Fixes: QTBUG-147222
Change-Id: I91ff2028001b5727d97b52e0109b5233918a17a6
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
commitba9de459c2347bc88ec8ad14d8e7c08692e330a0
parente64cedfc3377b558f200702bdedb72817a4d1634
authorDennis Oberst <dennis.oberst@qt.io>
committerDennis Oberst <dennis.oberst@qt.io>
commit timeWed, 3 Jun 2026 14:59:43 +0000