Archived
1
0

Adding support for ancient git (1.7.1) found on CentOS 6.8

- Recently added the BCD_VERSION which uses git rev-list --count HEAD command
- Unfortunately git 1.7.1 doesn't have this, so I've added a fallback to manually counting the commits using some CMake magic
This commit is contained in:
Jacob Alexander 2016-08-31 02:41:55 +00:00
parent 22a24e967b
commit b7b7fd1ee7

View File

@ -80,8 +80,28 @@ execute_process ( COMMAND ${GIT_EXECUTABLE} rev-list --count HEAD
OUTPUT_VARIABLE Git_Commit_Number OUTPUT_VARIABLE Git_Commit_Number
ERROR_QUIET ERROR_QUIET
OUTPUT_STRIP_TRAILING_WHITESPACE OUTPUT_STRIP_TRAILING_WHITESPACE
RESULT_VARIABLE res_var
) )
#| Older versions of git (e.g. 1.7.1) dont' like rev-list --count
#| If there's an error, try again with a less efficient version
if ( NOT "${res_var}" STREQUAL "0" )
execute_process ( COMMAND ${GIT_EXECUTABLE} log --pretty=oneline
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
OUTPUT_VARIABLE Git_Log_Lines
OUTPUT_STRIP_TRAILING_WHITESPACE
RESULT_VARIABLE res_var
)
# Now we do some CMake wizardry to split lines in the variable so we have a list called contents
string ( REGEX REPLACE ";" "\\\\;" contents "${Git_Log_Lines}" )
string ( REGEX REPLACE "\n" ";" contents "${contents}" )
# Now we just have to measure the length of the list
list ( LENGTH contents Git_Commit_Number )
endif ()
#| Origin URL #| Origin URL
execute_process ( COMMAND ${GIT_EXECUTABLE} config --get remote.origin.url execute_process ( COMMAND ${GIT_EXECUTABLE} config --get remote.origin.url
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}