File: VersionViaGit.cmake

package info (click to toggle)
mysql-8.0 8.0.43-2
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 1,273,904 kB
  • sloc: cpp: 4,684,605; ansic: 412,450; pascal: 108,398; java: 83,641; perl: 30,221; cs: 27,067; sql: 26,594; sh: 24,184; python: 21,816; yacc: 17,169; php: 11,522; xml: 7,388; javascript: 7,076; makefile: 2,196; lex: 1,075; awk: 670; asm: 520; objc: 183; ruby: 97; lisp: 86
file content (64 lines) | stat: -rw-r--r-- 2,009 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
# This module defines the following variables utilizing
# git to determine the parent tag. And if found the macro
# will attempt to parse them in the github tag fomat
#
# Useful for auto-versioning in our CMakeLists
#
#  EVENT_GIT___VERSION_MAJOR - Major version.
#  EVENT_GIT___VERSION_MINOR - Minor version
#  EVENT_GIT___VERSION_STAGE - Stage version
#
# Example usage:
#
# event_fuzzy_version_from_git()
#    message("Libvent major=${EVENT_GIT___VERSION_MAJOR}")
#    message("        minor=${EVENT_GIT___VERSION_MINOR}")
#    message("        patch=${EVENT_GIT___VERSION_PATCH}")
#    message("        stage=${EVENT_GIT___VERSION_STAGE}")
# endif()

include(FindGit)

macro(event_fuzzy_version_from_git)
	# set our defaults.
	set(EVENT_GIT___VERSION_MAJOR 2)
	set(EVENT_GIT___VERSION_MINOR 1)
	set(EVENT_GIT___VERSION_PATCH 11)
	set(EVENT_GIT___VERSION_STAGE "stable")

##	find_package(Git)
##
##	if (GIT_FOUND)
##		execute_process(
##			COMMAND
##				${GIT_EXECUTABLE} describe --abbrev=0
##			WORKING_DIRECTORY
##				${PROJECT_SOURCE_DIR}
##			RESULT_VARIABLE
##				GITRET
##			OUTPUT_VARIABLE
##				GITVERSION
##			OUTPUT_STRIP_TRAILING_WHITESPACE
##		)
##
##		string(REGEX REPLACE "[\\._-]" ";" VERSION_LIST "${GITVERSION}")
##		list(LENGTH VERSION_LIST VERSION_LIST_LENGTH)
##
##		if ((GITRET EQUAL 0) AND (VERSION_LIST_LENGTH EQUAL 5))
##			list(GET VERSION_LIST 1 _MAJOR)
##			list(GET VERSION_LIST 2 _MINOR)
##			list(GET VERSION_LIST 3 _PATCH)
##			list(GET VERSION_LIST 4 _STAGE)
##
##			set(_DEFAULT_VERSION "${EVENT_GIT___VERSION_MAJOR}.${EVENT_GIT___VERSION_MINOR}.${EVENT_GIT___VERSION_PATCH}-${EVENT_GIT___VERSION_STAGE}")
##			set(_GIT_VERSION     "${_MAJOR}.${_MINOR}.${_PATCH}-${_STAGE}")
##
##			if (${_DEFAULT_VERSION} VERSION_LESS ${_GIT_VERSION})
##				set(EVENT_GIT___VERSION_MAJOR ${_MAJOR})
##				set(EVENT_GIT___VERSION_MINOR ${_MINOR})
##				set(EVENT_GIT___VERSION_PATCH ${_PATCH})
##				set(EVENT_GIT___VERSION_STAGE ${_STAGE})
##			endif()
##		endif()
##	endif()
endmacro()