cmake: Mark `.git/HEAD` as a configure dependency
This ensures that the Zig version will be re-computed when jumping through the source tree. This can be important if bisecting across, e.g. AstGen, changes that must not use the old cache.
The basic outcome is that a CMake reconfigure is triggered if the HEAD changed:
$ ninja install
[1/2] Install the project...
-- Install configuration: "Debug"
$ git checkout HEAD^
...
$ ninja install
[0/1] Re-running CMake...
-- Configuring zig version 0.11.0-dev.1+841235b3f
-- Configuring done
-- Generating done
-- Build files have been written to: /home/topolarity/repos/zig/build
[4/5] Install the project...
-- Install configuration: "Debug"
-DZIG_VERSION behavior should not be affected by this change.
Does it work properly outside of a git tree (e.g. when building from a source tarball)?
Does it work properly outside of a git tree (e.g. when building from a source tarball)?
Yes - I tested it out by deleting .git, and I saw the expected -- Configuring zig version 0.11.0
CMake silently ignores any dependent files that are not present at configure time, and anyway this dependency is only marked if git describe succeeds (meaning we're in a git repo).