Eric Christopher 2a0b935461
[CMake][TableGen] Fix Ninja depslog error with implicit outputs on Ninja <1.10 (#179842)
Ninja versions prior to 1.10 cannot handle depfile mode when CMake
generates build rules with implicit outputs (the `| ${cmake_ninja_workdir}`
syntax used for IDE support). Ninja's depslog interprets these as
multiple outputs and rejects them with the error:

ninja: error: build.ninja:XXXX: multiple outputs aren't (yet?) supported
  by depslog; bring this up on the mailing list if it affects you

This primarily affected builds where CMake generates NATIVE subdirectory
builds for host tools.

This patch modifies TableGen.cmake to:
1. Detect the Ninja version at configure time
2. Disable depfile mode (fall back to globbing .td files) when:
   - Ninja version is < 1.10, OR
   - The tablegen invocation produces multiple outputs (e.g. -gen-register-info)

The fallback mode maintains correct dependency tracking by explicitly
globbing all .td files in include directories, ensuring tablegen reruns
when dependencies change.

Tested with:
- Ninja 1.8.2 (now works - previously failed with depslog error)
- Ninja 1.13.2
- CMake 4.2.3
- build scenarios with NATIVE tool builds

This commit used a significant amount of tooling to construct.
2026-02-05 18:35:32 -08:00
..