blob: bafd0a7326d44cf31669226fe614c326b0c5258c [file] [log] [blame]
Piotr Krysikbb961c12017-08-24 15:35:42 +02001# Copyright 2011,2013 Free Software Foundation, Inc.
2#
3# This file is part of GNU Radio
4#
5# GNU Radio is free software; you can redistribute it and/or modify
6# it under the terms of the GNU General Public License as published by
7# the Free Software Foundation; either version 3, or (at your option)
8# any later version.
9#
10# GNU Radio is distributed in the hope that it will be useful,
11# but WITHOUT ANY WARRANTY; without even the implied warranty of
12# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13# GNU General Public License for more details.
14#
15# You should have received a copy of the GNU General Public License
16# along with GNU Radio; see the file COPYING. If not, write to
17# the Free Software Foundation, Inc., 51 Franklin Street,
18# Boston, MA 02110-1301, USA.
19
20if(DEFINED __INCLUDED_GR_VERSION_CMAKE)
21 return()
22endif()
23set(__INCLUDED_GR_VERSION_CMAKE TRUE)
24
25#eventually, replace version.sh and fill in the variables below
26set(MAJOR_VERSION ${VERSION_INFO_MAJOR_VERSION})
27set(API_COMPAT ${VERSION_INFO_API_COMPAT})
28set(MINOR_VERSION ${VERSION_INFO_MINOR_VERSION})
29set(MAINT_VERSION ${VERSION_INFO_MAINT_VERSION})
30
31########################################################################
32# Extract the version string from git describe.
33########################################################################
34find_package(Git)
35
36if(GIT_FOUND AND EXISTS ${CMAKE_SOURCE_DIR}/.git)
37 message(STATUS "Extracting version information from git describe...")
38 execute_process(
39 COMMAND ${GIT_EXECUTABLE} describe --always --abbrev=8 --long
40 OUTPUT_VARIABLE GIT_DESCRIBE OUTPUT_STRIP_TRAILING_WHITESPACE
41 WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
42 )
43else()
44 set(GIT_DESCRIBE "v${MAJOR_VERSION}.${API_COMPAT}.x-xxx-xunknown")
45endif()
46
47########################################################################
48# Use the logic below to set the version constants
49########################################################################
50if("${MINOR_VERSION}" STREQUAL "git")
51 # VERSION: 3.3git-xxx-gxxxxxxxx
52 # DOCVER: 3.3git
53 # LIBVER: 3.3git
54 set(VERSION "${GIT_DESCRIBE}")
55 set(DOCVER "${MAJOR_VERSION}.${API_COMPAT}${MINOR_VERSION}")
56 set(LIBVER "${MAJOR_VERSION}.${API_COMPAT}${MINOR_VERSION}")
57 set(RC_MINOR_VERSION "0")
58 set(RC_MAINT_VERSION "0")
59elseif("${MAINT_VERSION}" STREQUAL "git")
60 # VERSION: 3.3.1git-xxx-gxxxxxxxx
61 # DOCVER: 3.3.1git
62 # LIBVER: 3.3.1git
63 set(VERSION "${GIT_DESCRIBE}")
64 set(DOCVER "${MAJOR_VERSION}.${API_COMPAT}.${MINOR_VERSION}${MAINT_VERSION}")
65 set(LIBVER "${MAJOR_VERSION}.${API_COMPAT}.${MINOR_VERSION}${MAINT_VERSION}")
66 math(EXPR RC_MINOR_VERSION "${MINOR_VERSION} - 1")
67 set(RC_MAINT_VERSION "0")
68else()
69 # This is a numbered release.
70 # VERSION: 3.3.1{.x}
71 # DOCVER: 3.3.1{.x}
72 # LIBVER: 3.3.1{.x}
73 if("${MAINT_VERSION}" STREQUAL "0")
74 set(VERSION "${MAJOR_VERSION}.${API_COMPAT}.${MINOR_VERSION}")
75 else()
76 set(VERSION "${MAJOR_VERSION}.${API_COMPAT}.${MINOR_VERSION}.${MAINT_VERSION}")
77 endif()
78 set(DOCVER "${VERSION}")
79 set(LIBVER "${VERSION}")
80 set(RC_MINOR_VERSION ${MINOR_VERSION})
81 set(RC_MAINT_VERSION ${MAINT_VERSION})
82endif()