mirror of
https://github.com/Xaymar/obs-StreamFX
synced 2024-11-27 22:03:01 +00:00
cmake: Add proper version override support
This commit is contained in:
parent
49eff4a1cf
commit
851e1e8939
1 changed files with 28 additions and 8 deletions
|
@ -89,6 +89,8 @@ if(EXISTS "${CMAKE_CURRENT_LIST_DIR}/.git")
|
||||||
set(VERSION_PATCH "${CMAKE_MATCH_1}")
|
set(VERSION_PATCH "${CMAKE_MATCH_1}")
|
||||||
if(CMAKE_MATCH_2)
|
if(CMAKE_MATCH_2)
|
||||||
set(VERSION_SUFFIX "${CMAKE_MATCH_2}")
|
set(VERSION_SUFFIX "${CMAKE_MATCH_2}")
|
||||||
|
else()
|
||||||
|
set(VERSION_SUFFIX "")
|
||||||
endif()
|
endif()
|
||||||
else()
|
else()
|
||||||
message(WARNING "${LOGPREFIX} Failed to detect version, using default instead.")
|
message(WARNING "${LOGPREFIX} Failed to detect version, using default instead.")
|
||||||
|
@ -97,17 +99,35 @@ if(EXISTS "${CMAKE_CURRENT_LIST_DIR}/.git")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# Allow manual overrides of the detected version.
|
# Allow manual overrides of the detected version.
|
||||||
set(${PREFIX}VERSION "" CACHE STRING "Override StreamFX version with this string. Format: /[0-9]{1,9}.[0-9]{1,9}.[0-9]{1,9}(|[a-z]{1,1}[0-9]{1,9})-[0-9]{1,9}-[0-9a-fA-F]{8,8}")
|
set(${PREFIX}VERSION "" CACHE STRING "Override StreamFX version with this string. Format: Major.Minor.Patch[Suffix][-Tweak[-Commit8c]]")
|
||||||
if(${PREFIX}VERSION)
|
if(${PREFIX}VERSION)
|
||||||
string(REPLACE "-" "." T_VERSION "${${PREFIX}VERSION}")
|
string(REPLACE "-" "." T_VERSION "${${PREFIX}VERSION}")
|
||||||
string(REPLACE "." ";" T_VERSION "${T_VERSION}")
|
string(REPLACE "." ";" T_VERSION "${${PREFIX}VERSION}")
|
||||||
|
|
||||||
# Parse Version
|
list(LENGTH T_VERSION T_VERSIONLEN)
|
||||||
list(GET GIT_OUTPUT 0 VERSION_MAJOR)
|
list(GET T_VERSION 0 VERSION_MAJOR)
|
||||||
list(GET GIT_OUTPUT 1 VERSION_MINOR)
|
list(GET T_VERSION 1 VERSION_MINOR)
|
||||||
list(GET GIT_OUTPUT 2 VERSION_PATCH)
|
list(GET T_VERSION 2 VERSION_PATCH)
|
||||||
list(GET GIT_OUTPUT 3 VERSION_BUILD)
|
if (T_VERSIONLEN GREATER_EQUAL 3)
|
||||||
list(GET GIT_OUTPUT 4 VERSION_COMMIT)
|
list(GET T_VERSION 3 VERSION_BUILD)
|
||||||
|
else()
|
||||||
|
set(VERSION_BUILD 0)
|
||||||
|
endif()
|
||||||
|
if (T_VERSIONLEN GREATER_EQUAL 4)
|
||||||
|
list(GET T_VERSION 4 VERSION_COMMIT)
|
||||||
|
else()
|
||||||
|
# set(VERSION_COMMIT "00000000")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
# Patch needs additional parsing.
|
||||||
|
# This may be a [0-9]*[a-z]*[0-9]+ string.
|
||||||
|
string(REGEX MATCHALL "([0-9]+)([a-z0-9]+)" T_MATCHES "${VERSION_PATCH}")
|
||||||
|
set(VERSION_PATCH "${CMAKE_MATCH_1}")
|
||||||
|
if(CMAKE_MATCH_2)
|
||||||
|
set(VERSION_SUFFIX "${CMAKE_MATCH_2}")
|
||||||
|
else()
|
||||||
|
set(VERSION_SUFFIX "")
|
||||||
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# Generate Version String
|
# Generate Version String
|
||||||
|
|
Loading…
Reference in a new issue