qtgrpc/examples/grpc
Joerg Bornemann 363998806d CMake: Don't force CONFIG mode for finding the OpenSSL dependency
When CMAKE_FIND_PACKAGE_PREFER_CONFIG is TRUE, find_package(OpenSSL)
prefers CONFIG mode and may bypass package manager wrappers that only
work in MODULE mode (e.g., vcpkg's wrapper).

This can lead to finding the wrong OpenSSL installation, such as
single-architecture system installations instead of the intended
universal binaries from the package manager, causing linker errors when
building for multiple architectures.

Fix this by finding OpenSSL before setting
CMAKE_FIND_PACKAGE_PREFER_CONFIG to TRUE. This ensures OpenSSL is found
via MODULE mode where package manager wrappers can properly control the
search. When gRPC's config file is loaded, it skips its own OpenSSL
search, using the already-found targets instead.

For test files, backup and restore the original
CMAKE_FIND_PACKAGE_PREFER_CONFIG value to limit the scope of the change.
For example files, keep the change simple without the backup/restore
pattern.

Change-Id: I985560fd5d57fa8036cc2ccb93c01a55e2efe1bc
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
2025-11-07 16:00:42 +01:00
..
chat CMake: Don't force CONFIG mode for finding the OpenSSL dependency 2025-11-07 16:00:42 +01:00
clientguide CMake: Don't force CONFIG mode for finding the OpenSSL dependency 2025-11-07 16:00:42 +01:00
magic8ball CMake: Don't force CONFIG mode for finding the OpenSSL dependency 2025-11-07 16:00:42 +01:00
vehicle CMake: Don't force CONFIG mode for finding the OpenSSL dependency 2025-11-07 16:00:42 +01:00
CMakeLists.txt Rewrite the qtgrpc chat example 2025-02-24 10:41:22 +01:00