2020-02-16 16:24:33 +01:00
|
|
|
function(SetVersionNumber PREFIX VERSION_STRING)
|
|
|
|
|
2021-07-14 20:21:29 +02:00
|
|
|
STRING(REGEX MATCHALL "[0-9]+|-([A-Za-z0-9_.]+)" VERSION_PARTS ${VERSION_STRING} )
|
|
|
|
LIST( LENGTH VERSION_PARTS VERSION_LEN)
|
|
|
|
if(${VERSION_LEN} GREATER 0)
|
|
|
|
LIST( GET VERSION_PARTS 0 VERSION_MAJOR )
|
|
|
|
endif()
|
|
|
|
|
|
|
|
if(${VERSION_LEN} GREATER 1)
|
|
|
|
LIST( GET VERSION_PARTS 1 VERSION_MINOR )
|
|
|
|
endif()
|
|
|
|
|
2021-10-17 13:29:20 +02:00
|
|
|
if(${VERSION_LEN} GREATER 2)
|
2021-07-14 20:21:29 +02:00
|
|
|
LIST( GET VERSION_PARTS 2 VERSION_PATCH )
|
|
|
|
endif()
|
|
|
|
|
|
|
|
if(${VERSION_LEN} GREATER 3)
|
|
|
|
LIST( GET VERSION_PARTS 3 VERSION_PRE )
|
|
|
|
endif()
|
2020-02-16 16:24:33 +01:00
|
|
|
|
|
|
|
set(${PREFIX}_VERSION_MAJOR ${VERSION_MAJOR} PARENT_SCOPE)
|
|
|
|
set(${PREFIX}_VERSION_MINOR ${VERSION_MINOR} PARENT_SCOPE)
|
|
|
|
set(${PREFIX}_VERSION_PATCH ${VERSION_PATCH} PARENT_SCOPE)
|
2021-07-14 20:21:29 +02:00
|
|
|
set(${PREFIX}_VERSION_PRE ${VERSION_PRE} PARENT_SCOPE)
|
2020-02-16 16:24:33 +01:00
|
|
|
|
|
|
|
#if(NOT VERSION_PRE MATCHES "stable")
|
|
|
|
# set(${PREFIX}_VERSION_PRE ${VERSION_PRE} PARENT_SCOPE)
|
|
|
|
# set( VERSION_PRE_FULL "-${VERSION_PRE}")
|
|
|
|
#endif()
|
2021-07-14 20:21:29 +02:00
|
|
|
endfunction()
|