1
0
Fork 0
mirror of https://github.com/TerryCavanagh/VVVVVV.git synced 2024-11-09 20:49:42 +01:00
VVVVVV/desktop_version/version.cmake
Dav999 1d3173f5c1 Fix %cs showing instead of commit date on Windows (or older git?)
Whenever I'd compile on Windows, I'd see the literal text "%cs" in the
main menu instead of the commit date. I never thought much of it (at
least it runs, and the date only shows up in development builds). Now
that I've also seen a screenshot from Terry with it, I decided to look
into it further. Looks like it's a format string that our gits on
Windows aren't recognizing for whatever reason - probably because
they're too old. I have git version 2.23.0.windows.1, and checking its
help page for `git log`, under PRETTY FORMATS, %cs is missing as an
option, while some other options are still there. So the option was
probably added sometime between that version and 2.34.1, which is the
one I have on Linux, where %cs does work.

Luckily, %cd with --date=short seems equivalent, and better supported,
so we can just use that instead.
2023-11-13 14:42:48 -08:00

25 lines
755 B
CMake

# Expects INPUT_FILE and OUTPUT_FILE to be defined
# Get interim commit and date of commit
EXECUTE_PROCESS(
COMMAND "${GIT_EXECUTABLE}" log -1 --format=%h
OUTPUT_VARIABLE INTERIM_COMMIT
OUTPUT_STRIP_TRAILING_WHITESPACE
)
EXECUTE_PROCESS(
COMMAND "${GIT_EXECUTABLE}" log -1 --format=%cd --date=short
OUTPUT_VARIABLE COMMIT_DATE
OUTPUT_STRIP_TRAILING_WHITESPACE
)
EXECUTE_PROCESS(
COMMAND "${GIT_EXECUTABLE}" branch --show-current
OUTPUT_VARIABLE BRANCH_NAME
OUTPUT_STRIP_TRAILING_WHITESPACE
)
MESSAGE(STATUS "This is interim commit ${INTERIM_COMMIT} (committed ${COMMIT_DATE}) on branch ${BRANCH_NAME}")
# Take the template file and replace the macros with what we have
CONFIGURE_FILE(${INPUT_FILE} ${OUTPUT_FILE})