CMake: Fix building of examples as external projects


Building the qtgrpc examples as external projects failed for various
reason. For the examples to build successfully as external projects,
we need to:

1) pass the various _ROOT / _DIR env vars to the external project
CMake, so that the project can successfully find the dependencies
from the custom locations.

The code already attempted to do the variable passing, but it didn't
work because the $ENV{Protobuf_ROOT} evaluated to FALSE in conditions,
because CMake treated the path as a variable name, and no such
variable name existed.

The fix is to use the 'NOT $ENV{VAR} STREQUAL ""' approach to check
if an environment variable has a value.

This is wrapped into a new helper function, that also takes care of
converting Windows paths to cmake paths.

2) pass QT_USE_VCPKG and other vcpkg related vars, so that if vcpkg is
used in the main build, it's also used in the external project. But
don't do it for MinGW, where we don't build the vckpg packages.
Also make sure that VCPKG_MANIFEST_INSTALL is OFF, so we don't spend
time downloading and building vcpkg packages in the external project.

3) Make sure to check both the lower-cased protobuf_ROOT and uppercase
Protobuf_ROOT env vars, which vary depending on the host platform.

4) Account for the various openssl env vars that Qt CI sets depending
on platform.

5) Don't pass grpc_ROOT for MinGW, because we don't have provisioning
for it, it's an unsupported platform for the upstream grpc library.

Pick-to: 6.12
Task-number: QTBUG-90820
Task-number: QTBUG-96232
Change-Id: I0cf65fb218a90783c70f2359924bd8359775ab89
Reviewed-by: Orkun Tokdemir <orkun.tokdemir@qt.io>
commita0fe53b7132587e950fa39905cbb036dc5d1a2b3
parent17f02c0e88e196fd81938f98f6015b1ca4833fd7
authorAlexandru Croitor <alexandru.croitor@qt.io>
committerAlexandru Croitor <alexandru.croitor@qt.io>
commit timeThu, 30 Jul 2026 14:56:53 +0000