root / cmake / Modules / GrVersion.cmake @ 152db0ca
History | View | Annotate | Download (2.6 kB)
| 1 | # Copyright 2011 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 | |
| 20 | IF(DEFINED __INCLUDED_GR_VERSION_CMAKE) |
| 21 | RETURN() |
| 22 | ENDIF() |
| 23 | SET(__INCLUDED_GR_VERSION_CMAKE TRUE) |
| 24 | |
| 25 | ######################################################################## |
| 26 | # Setup version variables. |
| 27 | # Parse the output of git describe |
| 28 | # sets VERSION and LIBVER |
| 29 | ######################################################################## |
| 30 | |
| 31 | UNSET(VERSION) |
| 32 | UNSET(LIBVER) |
| 33 | |
| 34 | ######################################################################## |
| 35 | # Extract the version string from git describe. |
| 36 | ######################################################################## |
| 37 | FIND_PACKAGE(Git) |
| 38 | IF(GIT_FOUND) |
| 39 | MESSAGE(STATUS "Extracting version information from git...") |
| 40 | EXECUTE_PROCESS(COMMAND ${GIT_EXECUTABLE} describe
|
| 41 | OUTPUT_VARIABLE VERSION OUTPUT_STRIP_TRAILING_WHITESPACE |
| 42 | WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
|
| 43 | ) |
| 44 | IF(NOT VERSION) |
| 45 | MESSAGE(WARNING "Tried to extract $VERSION from git describe but failed... using default") |
| 46 | ENDIF() |
| 47 | ENDIF(GIT_FOUND) |
| 48 | |
| 49 | ######################################################################## |
| 50 | # Extract the library version from the version string. |
| 51 | ######################################################################## |
| 52 | IF(VERSION) |
| 53 | INCLUDE(GrPython) |
| 54 | EXECUTE_PROCESS(COMMAND ${PYTHON_EXECUTABLE} -c "import re; print re.match('^v(\\d+\\.\\d+\\.\\d+)', '${VERSION}').groups()[0]"
|
| 55 | OUTPUT_VARIABLE LIBVER OUTPUT_STRIP_TRAILING_WHITESPACE |
| 56 | ) |
| 57 | IF(NOT LIBVER) |
| 58 | MESSAGE(WARNING "Tried to extract $LIBVER from $VERSION but failed... using default") |
| 59 | ENDIF() |
| 60 | ENDIF() |
| 61 | |
| 62 | ######################################################################## |
| 63 | # Ensure that the version strings are set no matter what. |
| 64 | ######################################################################## |
| 65 | IF(NOT VERSION) |
| 66 | SET(VERSION "v3.x.x-unknown") |
| 67 | ENDIF() |
| 68 | |
| 69 | IF(NOT LIBVER) |
| 70 | SET(LIBVER "3.x.x") |
| 71 | ENDIF() |
| 72 | |
| 73 | MESSAGE(STATUS "VERSION: ${VERSION}, LIBVER: ${LIBVER}")
|