diff options
author | Josh Blum | 2011-10-20 18:58:05 -0700 |
---|---|---|
committer | Josh Blum | 2011-10-20 18:58:05 -0700 |
commit | 1c95e89b0eafe063770ff98ee09f566843d1a68c (patch) | |
tree | e1a96dfb918c4bbfa3d798d3f546a99d3bfb0d9b /cmake | |
parent | dd41a603b923092fb08595f88b036d0677e5e6d4 (diff) | |
download | gnuradio-1c95e89b0eafe063770ff98ee09f566843d1a68c.tar.gz gnuradio-1c95e89b0eafe063770ff98ee09f566843d1a68c.tar.bz2 gnuradio-1c95e89b0eafe063770ff98ee09f566843d1a68c.zip |
cmake: parse the version.sh and git describe to model the m4 files
Diffstat (limited to 'cmake')
-rw-r--r-- | cmake/Modules/GrVersion.cmake | 88 |
1 files changed, 59 insertions, 29 deletions
diff --git a/cmake/Modules/GrVersion.cmake b/cmake/Modules/GrVersion.cmake index 842537f18..79aa3e4b0 100644 --- a/cmake/Modules/GrVersion.cmake +++ b/cmake/Modules/GrVersion.cmake @@ -23,51 +23,81 @@ endif() set(__INCLUDED_GR_VERSION_CMAKE TRUE) ######################################################################## -# Setup version variables. -# Parse the output of git describe -# sets VERSION and LIBVER +# Extract variables from version.sh ######################################################################## +message(STATUS "Extracting version information from version.sh...") +execute_process(COMMAND ${PYTHON_EXECUTABLE} -c "print open('${CMAKE_SOURCE_DIR}/version.sh').read().replace('=', ';').replace('\\n', ';')" + OUTPUT_VARIABLE VERSION_INFO OUTPUT_STRIP_TRAILING_WHITESPACE +) +include(CMakeParseArgumentsCopy) +CMAKE_PARSE_ARGUMENTS(VERSION_INFO "" "MAJOR_VERSION;API_COMPAT;MINOR_VERSION;MAINT_VERSION" "" ${VERSION_INFO}) -unset(VERSION) -unset(LIBVER) +#eventually, replace version.sh and fill in the variables below +set(MAJOR_VERSION ${VERSION_INFO_MAJOR_VERSION}) +set(API_COMPAT ${VERSION_INFO_API_COMPAT}) +set(MINOR_VERSION ${VERSION_INFO_MINOR_VERSION}) +set(MAINT_VERSION ${VERSION_INFO_MAINT_VERSION}) ######################################################################## # Extract the version string from git describe. ######################################################################## find_package(Git) + +unset(GIT_DESCRIBE) + if(GIT_FOUND) - message(STATUS "Extracting version information from git...") - execute_process(COMMAND ${GIT_EXECUTABLE} describe - OUTPUT_VARIABLE VERSION OUTPUT_STRIP_TRAILING_WHITESPACE + message(STATUS "Extracting version information from git describe...") + execute_process( + COMMAND ${GIT_EXECUTABLE} describe --always --abbrev=8 + OUTPUT_VARIABLE GIT_DESCRIBE OUTPUT_STRIP_TRAILING_WHITESPACE WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} ) - if(NOT VERSION) - message(WARNING "Tried to extract $VERSION from git describe but failed... using default") - endif() endif(GIT_FOUND) ######################################################################## -# Extract the library version from the version string. +# Parse the git describe string (currently unused) ######################################################################## -if(VERSION) - include(GrPython) - execute_process(COMMAND ${PYTHON_EXECUTABLE} -c "import re; print re.match('^v(\\d+\\.\\d+\\.\\d+)', '${VERSION}').groups()[0]" - OUTPUT_VARIABLE LIBVER OUTPUT_STRIP_TRAILING_WHITESPACE +unset(GIT_TAG) +unset(GIT_SEQNO) +unset(GIT_COMMIT) + +if(GIT_DESCRIBE) + execute_process( + COMMAND ${PYTHON_EXECUTABLE} -c + "import re; print ';'.join(re.match('^v(.*)-(.*)-g(.*)$', '${GIT_DESCRIBE}').groups())" + OUTPUT_VARIABLE GIT_DESCRIBES OUTPUT_STRIP_TRAILING_WHITESPACE ) - if(NOT LIBVER) - message(WARNING "Tried to extract $LIBVER from $VERSION but failed... using default") - endif() -endif() + list(GET GIT_DESCRIBES 0 GIT_TAG) + list(GET GIT_DESCRIBES 1 GIT_SEQNO) + list(GET GIT_DESCRIBES 2 GIT_COMMIT) +endif(GIT_DESCRIBE) ######################################################################## -# Ensure that the version strings are set no matter what. +# Use the logic below to set the version constants ######################################################################## -if(NOT VERSION) - set(VERSION "v3.x.x-unknown") -endif() - -if(NOT LIBVER) - set(LIBVER "3.x.x") +if("${MINOR_VERSION}" STREQUAL "git") + # VERSION: 3.3git-xxx-gxxxxxxxx + # DOCVER: 3.3git + # LIBVER: 3.3git + set(VERSION "${GIT_DESCRIBE}") + set(DOCVER "${MAJOR_VERSION}.${API_COMPAT}${MINOR_VERSION}") + set(LIBVER "${MAJOR_VERSION}.${API_COMPAT}${MINOR_VERSION}") +elseif("${MAINT_VERSION}" STREQUAL "git") + # VERSION: 3.3.1git-xxx-gxxxxxxxx + # DOCVER: 3.3.1git + # LIBVER: 3.3.1git + set(VERSION "${GIT_DESCRIBE}") + set(DOCVER "${MAJOR_VERSION}.${API_COMPAT}.${MINOR_VERSION}${MAINT_VERSION}") + set(LIBVER "${MAJOR_VERSION}.${API_COMPAT}.${MINOR_VERSION}${MAINT_VERSION}") +else() + # This is a numbered release. + # VERSION: 3.3.1{.x} + # DOCVER: 3.3.1{.x} + # LIBVER: 3.3.1{.x} + set(VERSION "${MAJOR_VERSION}.${API_COMPAT}.${MINOR_VERSION}") + if("${MAINT_VERSION}" NOT STREQUAL "0") + set(VERSION "${VERSION}.${MAINT_VERSION}") + endif() + set(DOCVER "${VERSION}") + set(LIBVER "${VERSION}") endif() - -message(STATUS "VERSION: ${VERSION}, LIBVER: ${LIBVER}") |