Git version fixed

This commit is contained in:
Nekotekina 2015-10-04 20:07:19 +03:00
parent 55ca625371
commit cd71125277
5 changed files with 26 additions and 15 deletions

View file

@ -4,14 +4,24 @@ set(GIT_VERSION_UPDATE "1")
find_package(Git)
if(GIT_FOUND)
execute_process(COMMAND ${GIT_EXECUTABLE} describe --always
execute_process(COMMAND ${GIT_EXECUTABLE} rev-list HEAD --count
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.")
message(WARNING "git rev-list failed, unable to include version.")
endif()
execute_process(COMMAND ${GIT_EXECUTABLE} rev-parse --short HEAD
WORKING_DIRECTORY ${SOURCE_DIR}
RESULT_VARIABLE exit_code
OUTPUT_VARIABLE GIT_VERSION_)
if(NOT ${exit_code} EQUAL 0)
message(WARNING "git rev-parse failed, unable to include version.")
endif()
string(STRIP ${GIT_VERSION} GIT_VERSION)
string(STRIP ${GIT_VERSION_} GIT_VERSION_)
string(STRIP ${GIT_VERSION}-${GIT_VERSION_} GIT_VERSION)
message(STATUS "GIT_VERSION: " ${GIT_VERSION})
else()
message(WARNING "git not found, unable to include version.")
endif()