CMake: Fix objcnamemangler build when zstd dependency is missing


The objcnamemangler tool depends on the LLVM Support library, which
can have a dependency on zstd::libzstd_shared. If the zstd CMake
package is not found, the Support library target will still be
created.
This causes a cmake generation time error:

CMake Error at
  /opt/homebrew/opt/llvm/lib/cmake/llvm/LLVMExports.cmake:64
    (set_target_properties):
  The link interface of target "LLVMSupport" contains:
    zstd::libzstd_shared
  but the target was not found.  Possible reasons include:
  Call Stack (most recent call first):
  /opt/homebrew/opt/llvm/lib/cmake/llvm/LLVMConfig.cmake:349 (include)

Make sure to explicitly check if the zstd target is a dependency of
the LLVM library and that it exists, before enabling the feature that
builds the tool.

In addition, to avoid errors like:
 CMake Error at
 /opt/homebrew/opt/zstd/lib/cmake/zstd/zstdTargets.cmake:42 (message):
  Some (but not all) targets in this export set were already defined.
  Targets Defined: zstd::libzstd_shared, zstd::libzstd_static
  Targets not yet defined: zstd::libzstd

we need to disable the zstd package lookup within llvm's
Findzstd.cmake regardless of the state of the QT_FEATURE_zstd
feature value. This needs to be done around each new LLVM lookup.

As a drive-by, make the package lookup happen only on MACOS where it
is needed.

Amends f0df12af992a8d7116e99ed85c62a9976c09d1a6
Amends b676278a24eb880eeeed35bbf203a76950a9ab4e

Task-number: QTBUG-139199
Change-Id: I4f28e3cde8f04a318f731eb06997fa701c017a0a
Reviewed-by: Paul Wicking <paul.wicking@qt.io>
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
commit5947cbc46b9c292263200c5d225c051f0682c159
parentdefa6472f020dcb06643b7b5037ae4d8a7ab1189
authorAlexandru Croitor <alexandru.croitor@qt.io>
committerAlexandru Croitor <alexandru.croitor@qt.io>
commit timeMon, 4 May 2026 12:11:51 +0000