CMake: Declare git-version.cpp as a byproduct of the GitVersion step

Ninja only knew git-version.cpp from its timestamp at the start of the
build, so when the GitVersion step rewrote it, the object wasn't rebuilt
until some later build happened to notice. An Android APK built right
after a commit could carry the previous commit's version string.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Henrik RydgårdandClaude Opus 5.5 committed 2026-11-02 09:24:03 +01:00
1 parent 9add5a78f3
commit 32b67c0c55
1 file changed
+4
+4
View File
@@ -805,7 +805,11 @@ if (WIN32)
set(WIN_VERSION_CMD COMMAND ${CMAKE_SOURCE_DIR}/Windows/git-version-gen.cmd PPSSPPWindows)
endif()
# BYPRODUCTS tells Ninja that this writes git-version.cpp, so it checks the file again after the
# command has run. Otherwise it only sees the timestamp from before the build, and the object is
# recompiled a build late, if at all. The file is only rewritten when the version changes.
add_custom_command(OUTPUT something_that_never_exists
BYPRODUCTS ${CMAKE_BINARY_DIR}/git-version.cpp
COMMAND ${CMAKE_COMMAND} -DSOURCE_DIR=${CMAKE_SOURCE_DIR}
-DOUTPUT_DIR=${CMAKE_BINARY_DIR}
-P ${CMAKE_SOURCE_DIR}/git-version.cmake