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>