1
0
Fork 1
mirror of https://github.com/TES3MP/openmw-tes3mp.git synced 2025-01-16 18:19:55 +00:00

Made the git version retrieval more reliable

This commit is contained in:
pvdk 2014-02-19 13:43:14 +01:00
parent d25b3ad9cb
commit 85b7240948
2 changed files with 44 additions and 21 deletions

View file

@ -13,27 +13,39 @@ set(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake/)
include(OpenMWMacros) include(OpenMWMacros)
# Version # Version
set(OPENMW_VERSION_MAJOR 0)
set(OPENMW_VERSION_MINOR 29)
set(OPENMW_VERSION_RELEASE 0)
include(GetGitRevisionDescription) set(OPENMW_VERSION "${OPENMW_VERSION_MAJOR}.${OPENMW_VERSION_MINOR}.${OPENMW_VERSION_RELEASE}")
get_git_tag_revision(TAGHASH --tags --max-count=1 "HEAD...") if(EXISTS ${PROJECT_SOURCE_DIR}/.git)
get_git_head_revision(REFSPEC COMMITHASH) find_package(Git)
git_describe(VERSION --tags ${TAGHASH})
string(REGEX MATCH "^openmw-[^0-9]*[0-9]+\\.[0-9]+\\.[0-9]+.*" MATCH "${VERSION}") if(GIT_FOUND)
if (MATCH) include(GetGitRevisionDescription)
string(REGEX REPLACE "^openmw-([0-9]+)\\..*" "\\1" OPENMW_VERSION_MAJOR "${VERSION}") get_git_tag_revision(TAGHASH --tags --max-count=1)
string(REGEX REPLACE "^openmw-[0-9]+\\.([0-9]+).*" "\\1" OPENMW_VERSION_MINOR "${VERSION}") get_git_head_revision(REFSPEC COMMITHASH)
string(REGEX REPLACE "^openmw-[0-9]+\\.[0-9]+\\.([0-9]+).*" "\\1" OPENMW_VERSION_RELEASE "${VERSION}") git_describe(VERSION --tags ${TAGHASH})
set(OPENMW_VERSION "${OPENMW_VERSION_MAJOR}.${OPENMW_VERSION_MINOR}.${OPENMW_VERSION_RELEASE}") string(REGEX MATCH "^openmw-[^0-9]*[0-9]+\\.[0-9]+\\.[0-9]+.*" MATCH "${VERSION}")
set(OPENMW_VERSION_COMMITHASH "${COMMITHASH}") if(MATCH)
set(OPENMW_VERSION_TAGHASH "${TAGHASH}") string(REGEX REPLACE "^openmw-([0-9]+)\\..*" "\\1" OPENMW_VERSION_MAJOR "${VERSION}")
string(REGEX REPLACE "^openmw-[0-9]+\\.([0-9]+).*" "\\1" OPENMW_VERSION_MINOR "${VERSION}")
string(REGEX REPLACE "^openmw-[0-9]+\\.[0-9]+\\.([0-9]+).*" "\\1" OPENMW_VERSION_RELEASE "${VERSION}")
message(STATUS "Configuring OpenMW ${OPENMW_VERSION}...") set(OPENMW_VERSION "${OPENMW_VERSION_MAJOR}.${OPENMW_VERSION_MINOR}.${OPENMW_VERSION_RELEASE}")
else (MATCH) set(OPENMW_VERSION_COMMITHASH "${COMMITHASH}")
message(FATAL_ERROR "Failed to get valid version information from Git") set(OPENMW_VERSION_TAGHASH "${TAGHASH}")
endif (MATCH)
message(STATUS "Configuring OpenMW ${OPENMW_VERSION}...")
else(MATCH)
message(WARNING "Failed to get valid version information from Git")
endif(MATCH)
else(GIT_FOUND)
message(WARNING "Git executable not found")
endif(GIT_FOUND)
endif(EXISTS ${PROJECT_SOURCE_DIR}/.git)
# doxygen main page # doxygen main page

View file

@ -85,10 +85,6 @@ function(get_git_head_revision _refspecvar _hashvar)
endfunction() endfunction()
function(git_describe _var) function(git_describe _var)
if(NOT GIT_FOUND)
find_package(Git QUIET)
endif()
#get_git_head_revision(refspec hash) #get_git_head_revision(refspec hash)
if(NOT GIT_FOUND) if(NOT GIT_FOUND)
@ -124,6 +120,20 @@ function(git_describe _var)
out out
OUTPUT_STRIP_TRAILING_WHITESPACE) OUTPUT_STRIP_TRAILING_WHITESPACE)
if(NOT res EQUAL 0)
execute_process(COMMAND
"${GIT_EXECUTABLE}"
describe
"--always"
WORKING_DIRECTORY
"${CMAKE_SOURCE_DIR}"
RESULT_VARIABLE
res
OUTPUT_VARIABLE
out
OUTPUT_STRIP_TRAILING_WHITESPACE)
endif()
if(NOT res EQUAL 0) if(NOT res EQUAL 0)
set(out "${out}-${res}-NOTFOUND") set(out "${out}-${res}-NOTFOUND")
endif() endif()
@ -133,7 +143,8 @@ endfunction()
function(get_git_tag_revision _var) function(get_git_tag_revision _var)
if(NOT GIT_FOUND) if(NOT GIT_FOUND)
find_package(Git QUIET) set(${_var} "GIT-NOTFOUND" PARENT_SCOPE)
return()
endif() endif()
execute_process(COMMAND execute_process(COMMAND