2021-10-14 20:50:41 +02:00
|
|
|
set(STRAWBERRY_VERSION_MAJOR 1)
|
2024-09-21 23:16:37 +02:00
|
|
|
set(STRAWBERRY_VERSION_MINOR 2)
|
2024-11-16 06:08:33 +01:00
|
|
|
set(STRAWBERRY_VERSION_PATCH 1)
|
2024-11-21 16:05:21 +01:00
|
|
|
#set(STRAWBERRY_VERSION_PRERELEASE rc1)
|
2018-02-27 18:06:05 +01:00
|
|
|
|
2024-11-21 16:05:21 +01:00
|
|
|
set(INCLUDE_GIT_REVISION OFF)
|
2018-02-27 18:06:05 +01:00
|
|
|
|
|
|
|
set(majorminorpatch "${STRAWBERRY_VERSION_MAJOR}.${STRAWBERRY_VERSION_MINOR}.${STRAWBERRY_VERSION_PATCH}")
|
|
|
|
|
2024-07-09 02:37:51 +02:00
|
|
|
if(FORCE_GIT_REVISION)
|
|
|
|
set(GIT_REVISION ${FORCE_GIT_REVISION})
|
|
|
|
elseif(INCLUDE_GIT_REVISION AND EXISTS "${CMAKE_SOURCE_DIR}/.git")
|
2018-07-01 15:29:35 +02:00
|
|
|
|
|
|
|
find_program(GIT_EXECUTABLE git)
|
2018-07-16 07:23:37 +02:00
|
|
|
if(NOT GIT_EXECUTABLE OR GIT_EXECUTABLE-NOTFOUND)
|
2023-10-02 17:04:15 +02:00
|
|
|
message(FATAL_ERROR "Missing Git executable." )
|
2018-07-01 15:29:35 +02:00
|
|
|
endif()
|
2018-04-01 18:32:31 +02:00
|
|
|
|
|
|
|
# Get the current working branch
|
|
|
|
execute_process(
|
|
|
|
COMMAND ${GIT_EXECUTABLE} rev-parse --abbrev-ref HEAD
|
|
|
|
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
|
2018-07-01 15:29:35 +02:00
|
|
|
RESULT_VARIABLE GIT_CMD_RESULT_BRANCH
|
2018-04-01 18:32:31 +02:00
|
|
|
OUTPUT_VARIABLE GIT_BRANCH
|
|
|
|
OUTPUT_STRIP_TRAILING_WHITESPACE
|
|
|
|
ERROR_QUIET
|
|
|
|
)
|
|
|
|
# Get the latest abbreviated commit hash of the working branch
|
|
|
|
execute_process(
|
2018-05-16 23:31:45 +02:00
|
|
|
COMMAND ${GIT_EXECUTABLE} describe --long --tags --always
|
2018-04-01 18:32:31 +02:00
|
|
|
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
|
2018-07-01 15:29:35 +02:00
|
|
|
RESULT_VARIABLE GIT_CMD_RESULT_REVISION
|
2018-05-08 19:55:53 +02:00
|
|
|
OUTPUT_VARIABLE GIT_REVISION
|
2018-04-01 18:32:31 +02:00
|
|
|
OUTPUT_STRIP_TRAILING_WHITESPACE
|
|
|
|
ERROR_QUIET
|
|
|
|
)
|
2018-02-27 18:06:05 +01:00
|
|
|
|
2018-07-12 17:17:20 +02:00
|
|
|
if(NOT ${GIT_CMD_RESULT_REVISION} EQUAL 0)
|
2023-10-02 17:04:15 +02:00
|
|
|
message(FATAL_ERROR "Git command failed to get revision string '${GIT_REVISION}'")
|
2018-07-12 17:17:20 +02:00
|
|
|
endif()
|
|
|
|
|
2018-07-12 17:10:38 +02:00
|
|
|
endif()
|
|
|
|
|
|
|
|
if(GIT_REVISION)
|
|
|
|
|
2018-05-08 19:55:53 +02:00
|
|
|
string(REGEX REPLACE "^(.+)-([0-9]+)-(g[a-f0-9]+)$" "\\1;\\2;\\3" GIT_PARTS ${GIT_REVISION})
|
|
|
|
|
|
|
|
if(NOT GIT_PARTS)
|
|
|
|
message(FATAL_ERROR "Failed to parse git revision string '${GIT_REVISION}'")
|
2018-07-01 15:29:35 +02:00
|
|
|
endif()
|
2018-05-08 19:55:53 +02:00
|
|
|
|
|
|
|
list(LENGTH GIT_PARTS GIT_PARTS_LENGTH)
|
2018-07-01 15:29:35 +02:00
|
|
|
if(NOT GIT_PARTS_LENGTH EQUAL 3)
|
2023-10-02 17:04:15 +02:00
|
|
|
set(GIT_PARTS "${majorminorpatch};0;${GIT_REVISION}")
|
2018-07-01 15:29:35 +02:00
|
|
|
endif()
|
|
|
|
|
|
|
|
list(GET GIT_PARTS 0 GIT_TAGNAME)
|
|
|
|
list(GET GIT_PARTS 1 GIT_COMMITCOUNT)
|
|
|
|
list(GET GIT_PARTS 2 GIT_SHA1)
|
|
|
|
|
|
|
|
set(HAS_GIT_REVISION ON)
|
|
|
|
|
2018-05-08 19:55:53 +02:00
|
|
|
set(STRAWBERRY_VERSION_DISPLAY "${GIT_REVISION}")
|
2018-07-01 15:29:35 +02:00
|
|
|
set(STRAWBERRY_VERSION_PACKAGE "${GIT_TAGNAME}.${GIT_COMMITCOUNT}.${GIT_SHA1}")
|
2024-07-09 02:37:51 +02:00
|
|
|
string(REPLACE "-" "~" STRAWBERRY_VERSION_RPM_V "${GIT_TAGNAME}")
|
2018-05-08 19:55:53 +02:00
|
|
|
set(STRAWBERRY_VERSION_RPM_R "2.${GIT_COMMITCOUNT}.${GIT_SHA1}")
|
2018-07-01 15:29:35 +02:00
|
|
|
|
2024-07-09 02:37:51 +02:00
|
|
|
else()
|
|
|
|
if(STRAWBERRY_VERSION_PRERELEASE)
|
|
|
|
set(STRAWBERRY_VERSION_DISPLAY "${majorminorpatch}-${STRAWBERRY_VERSION_PRERELEASE}")
|
|
|
|
set(STRAWBERRY_VERSION_RPM_V "${majorminorpatch}~${STRAWBERRY_VERSION_PRERELEASE}")
|
|
|
|
set(STRAWBERRY_VERSION_PACKAGE "${majorminorpatch}${STRAWBERRY_VERSION_PRERELEASE}")
|
|
|
|
else()
|
|
|
|
set(STRAWBERRY_VERSION_DISPLAY "${majorminorpatch}")
|
|
|
|
set(STRAWBERRY_VERSION_PACKAGE "${majorminorpatch}")
|
|
|
|
set(STRAWBERRY_VERSION_RPM_V "${majorminorpatch}")
|
|
|
|
endif()
|
|
|
|
set(STRAWBERRY_VERSION_RPM_R "1")
|
2018-07-01 15:29:35 +02:00
|
|
|
endif()
|
2018-02-27 18:06:05 +01:00
|
|
|
|
2018-04-01 18:32:31 +02:00
|
|
|
message(STATUS "Strawberry Version:")
|
|
|
|
message(STATUS "Display: ${STRAWBERRY_VERSION_DISPLAY}")
|
|
|
|
message(STATUS "Package: ${STRAWBERRY_VERSION_PACKAGE}")
|
2018-11-11 03:37:14 +01:00
|
|
|
message(STATUS "RPM: ${STRAWBERRY_VERSION_RPM_V}-${STRAWBERRY_VERSION_RPM_R}")
|