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.
See docs/CMake.html for instructions on how to build LLVM with CMake.