mirror of
https://github.com/RPCSX/rpcsx.git
synced 2026-04-04 14:08:37 +00:00
don't distinguish between windows and unix for no reason
This commit is contained in:
parent
d3c9aff2f4
commit
71225da135
4 changed files with 50 additions and 11 deletions
42
rpcs3/git-version.cmake
Normal file
42
rpcs3/git-version.cmake
Normal file
|
|
@ -0,0 +1,42 @@
|
|||
set(GIT_VERSION_FILE "${SOURCE_DIR}/git-version.h")
|
||||
set(GIT_VERSION "unknown")
|
||||
set(GIT_VERSION_UPDATE "1")
|
||||
|
||||
find_package(Git)
|
||||
if(GIT_FOUND)
|
||||
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 "RPCS3_GIT_VERSION_NO_UPDATE 1")
|
||||
if(NOT ${match} EQUAL "")
|
||||
set(GIT_VERSION_UPDATE "0")
|
||||
endif()
|
||||
|
||||
# Don't update if it's already the same.
|
||||
file(STRINGS ${GIT_VERSION_FILE} match
|
||||
REGEX "${GIT_VERSION}")
|
||||
if(NOT ${match} EQUAL "")
|
||||
set(GIT_VERSION_UPDATE "0")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
set(code_string "// This is a generated file.\n\n"
|
||||
"#define RPCS3_GIT_VERSION \"${GIT_VERSION}\"\;\n\n"
|
||||
"// If you don't want this file to update/recompile, change to 1.\n"
|
||||
"#define RPCS3_GIT_VERSION_NO_UPDATE 0\n")
|
||||
|
||||
if ("${GIT_VERSION_UPDATE}" EQUAL "1")
|
||||
file(WRITE ${GIT_VERSION_FILE} ${code_string})
|
||||
endif()
|
||||
Loading…
Add table
Add a link
Reference in a new issue