cmake: fix default version if git describe
fails
If the `git describe` command fails we want to fall back to a default version. _OBS_DEFAULT_VERSION is not in the same format as the string returned by `git describe` though. In the event that the command fails just use _OBS_DEFAULT_VERSION directly rather than trying to parse it. Fixes: cmake fails if git is not installed but .git/ exists #6940
This commit is contained in:
parent
76e9c64f41
commit
39269a7ae9
@ -34,13 +34,15 @@ if(NOT DEFINED OBS_VERSION_OVERRIDE)
|
||||
RESULT_VARIABLE _OBS_VERSION_RESULT
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE)
|
||||
|
||||
if(NOT _OBS_VERSION_RESULT EQUAL 0)
|
||||
if(_OBS_VERSION_RESULT EQUAL 0)
|
||||
string(REPLACE "-" "." _CANONICAL_SPLIT ${_OBS_VERSION})
|
||||
string(REPLACE "." ";" _CANONICAL_SPLIT ${_CANONICAL_SPLIT})
|
||||
list(GET _CANONICAL_SPLIT 0 1 2 _OBS_VERSION_CANONICAL)
|
||||
string(REPLACE "." ";" _OBS_VERSION ${_OBS_VERSION})
|
||||
else()
|
||||
set(_OBS_VERSION "${_OBS_DEFAULT_VERSION}")
|
||||
set(_OBS_VERSION_CANONICAL ${_OBS_DEFAULT_VERSION})
|
||||
endif()
|
||||
string(REPLACE "-" "." _CANONICAL_SPLIT ${_OBS_VERSION})
|
||||
string(REPLACE "." ";" _CANONICAL_SPLIT ${_CANONICAL_SPLIT})
|
||||
list(GET _CANONICAL_SPLIT 0 1 2 _OBS_VERSION_CANONICAL)
|
||||
string(REPLACE "." ";" _OBS_VERSION ${_OBS_VERSION})
|
||||
else()
|
||||
set(_OBS_VERSION ${_OBS_DEFAULT_VERSION})
|
||||
set(_OBS_VERSION_CANONICAL ${_OBS_DEFAULT_VERSION})
|
||||
|
Loading…
x
Reference in New Issue
Block a user