From 32b67c0c553ab3726b18eb702145e7375673a4e2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Mon, 2 Nov 2026 09:24:03 +0100 Subject: [PATCH] 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 --- Core/CMakeLists.txt | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Core/CMakeLists.txt b/Core/CMakeLists.txt index 0877137a46..cec3d2b2b2 100644 --- a/Core/CMakeLists.txt +++ b/Core/CMakeLists.txt @@ -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