mirror of
https://github.com/hrydgard/ppsspp.git
synced 2024-12-03 19:21:13 +00:00
460ef63f5d
steps to reproduce : git checkout v1.10.1~3 git describe --always --> v1.10-19-g9aab3d986 [build now] PPSSPPSDL --version --> v1.10-19-g9aab3d986 git checkout v1.10.1 git describe --always --> v1.10.1 [build now] PPSSPPSDL --version --> v1.10-19-g9aab3d986 Indeed, the "v1.10.1" regex matches the "v1.10-19-g9aab3d986" string. How unfortunate! So I just deleted that check, building the same commit twice should not happen that often :)
36 lines
1.1 KiB
CMake
36 lines
1.1 KiB
CMake
set(GIT_VERSION_FILE "${SOURCE_DIR}/git-version.cpp")
|
|
set(GIT_VERSION "unknown")
|
|
set(GIT_VERSION_UPDATE "1")
|
|
|
|
find_package(Git)
|
|
if(GIT_FOUND AND EXISTS "${SOURCE_DIR}/.git/")
|
|
execute_process(COMMAND ${GIT_EXECUTABLE} describe --always
|
|
WORKING_DIRECTORY ${SOURCE_DIR}
|
|
RESULT_VARIABLE exit_code
|
|
OUTPUT_VARIABLE GIT_VERSION)
|
|
if(NOT ${exit_code} EQUAL 0)
|
|
message(WARNING "git describe failed, unable to include version.")
|
|
endif()
|
|
string(STRIP ${GIT_VERSION} GIT_VERSION)
|
|
else()
|
|
message(WARNING "git not found, unable to include version.")
|
|
endif()
|
|
|
|
if(EXISTS ${GIT_VERSION_FILE})
|
|
# Don't update if marked not to update.
|
|
file(STRINGS ${GIT_VERSION_FILE} match
|
|
REGEX "PPSSPP_GIT_VERSION_NO_UPDATE 1")
|
|
if(NOT ${match} EQUAL "")
|
|
set(GIT_VERSION_UPDATE "0")
|
|
endif()
|
|
endif()
|
|
|
|
set(code_string "// This is a generated file.\n\n"
|
|
"const char *PPSSPP_GIT_VERSION = \"${GIT_VERSION}\"\;\n\n"
|
|
"// If you don't want this file to update/recompile, change to 1.\n"
|
|
"#define PPSSPP_GIT_VERSION_NO_UPDATE 0\n")
|
|
|
|
if ("${GIT_VERSION_UPDATE}" EQUAL "1")
|
|
file(WRITE ${GIT_VERSION_FILE} ${code_string})
|
|
endif()
|