# Stamps GitInfo.cpp with the SHA of HEAD as it is NOW. Run with `cmake -P` on every build (see the # JFJochGitInfo target in CMakeLists.txt here), so the hash a binary reports is the commit it was # built from, not the one the tree held when it was last configured - a configure-time stamp once # reported a hash seventeen commits stale. configure_file leaves the output untouched when nothing # changed, so this costs a recompile only when HEAD moves. Also included at configure time, so the # file exists for the generator and the SHA prints with the configure output. if (GIT_EXECUTABLE) # --dirty: a build from uncommitted changes says so in the hash itself EXECUTE_PROCESS(COMMAND "${GIT_EXECUTABLE}" describe --match=NeVeRmAtCh --always --abbrev=8 --dirty WORKING_DIRECTORY "${GITINFO_SOURCE_DIR}" OUTPUT_VARIABLE GIT_SHA1 ERROR_QUIET OUTPUT_STRIP_TRAILING_WHITESPACE) EXECUTE_PROCESS(COMMAND "${GIT_EXECUTABLE}" log -1 --format=%ad --date=local WORKING_DIRECTORY "${GITINFO_SOURCE_DIR}" OUTPUT_VARIABLE GIT_DATE ERROR_QUIET OUTPUT_STRIP_TRAILING_WHITESPACE) endif () CONFIGURE_FILE("${GITINFO_TEMPLATE}" "${GITINFO_OUTPUT}" @ONLY)