mirror of https://github.com/AxioDL/metaforce.git
Add git revision
This commit is contained in:
parent
c997b7d3c4
commit
18c4b1aa6d
|
@ -1 +1,2 @@
|
|||
version.h
|
||||
*.user
|
|
@ -44,3 +44,16 @@ add_subdirectory(DataSpec)
|
|||
if(NOT ${CMAKE_SYSTEM_NAME} MATCHES "FreeBSD")
|
||||
add_subdirectory(Runtime)
|
||||
endif()
|
||||
|
||||
find_package(Git)
|
||||
if(GIT_FOUND)
|
||||
message("git found: ${GIT_EXECUTABLE}")
|
||||
# Get the current working branch
|
||||
execute_process(COMMAND ${GIT_EXECUTABLE} rev-parse --abbrev-ref HEAD WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} OUTPUT_VARIABLE GIT_BRANCH OUTPUT_STRIP_TRAILING_WHITESPACE )
|
||||
|
||||
# Get the latest abbreviated commit hash of the working branch
|
||||
execute_process(COMMAND ${GIT_EXECUTABLE} log -1 --format=%h WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} OUTPUT_VARIABLE GIT_COMMIT_HASH OUTPUT_STRIP_TRAILING_WHITESPACE)
|
||||
execute_process(COMMAND ${GIT_EXECUTABLE} rev-parse HEAD WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} OUTPUT_VARIABLE GIT_COMMIT_HASH_FULL OUTPUT_STRIP_TRAILING_WHITESPACE)
|
||||
|
||||
configure_file(${CMAKE_SOURCE_DIR}/version.h.in ${CMAKE_SOURCE_DIR}/version.h)
|
||||
endif()
|
||||
|
|
|
@ -0,0 +1,7 @@
|
|||
#ifndef VERSION_H
|
||||
#define VERSION_H
|
||||
|
||||
#define GIT_BRANCH "@GIT_BRANCH@"
|
||||
#define GIT_COMMIT_HASH "@GIT_COMMIT_HASH@"
|
||||
#define GIT_COMMIT_HASH_FULL "@GIT_COMMIT_HASH_FULL@"
|
||||
#endif
|
Loading…
Reference in New Issue