[CMAKE] Only change obj/build.h if the content has changed
Summary:
This diff creates a temporary build.h.tmp file, then copies it to
obj/build.h only if it differs from it.
This avoid rebuilding due to the obj/build.h being touched while the
content remains unchanged.
In order to generate the intermediate file every time git HEAD is
updated, the .git/log/HEAD file is set as a dependency for the custom
command.
Test Plan:
mkdir buildcmake && cd buildcmake cmake -GNinja .. ninja util
Check the buildcmake/obj/build.h file is generated and the
buildcmake/obj/build.h.tmp is removed.
ninja util
Should return no work to do.
Amend the commit summary, then
ninja util
Check the buildcmake/obj/build.h file is generated again and the
buildcmake/obj/build.h.tmp is still not there.
Reviewers: #bitcoin_abc, deadalnix
Reviewed By: #bitcoin_abc, deadalnix
Differential Revision: https://reviews.bitcoinabc.org/D4116