summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--CMakeLists.txt4
-rw-r--r--cmake/Modules/GrVersion.cmake88
2 files changed, 61 insertions, 31 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 3b40f81e1..8b21f2e37 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -90,7 +90,7 @@ set(GR_INCLUDE_DIR include)
set(GR_DATA_DIR share)
set(GR_PKG_DATA_DIR ${GR_DATA_DIR}/${CMAKE_PROJECT_NAME})
set(GR_DOC_DIR ${GR_DATA_DIR}/doc)
-set(GR_PKG_DOC_DIR ${GR_DOC_DIR}/${CMAKE_PROJECT_NAME}-${LIBVER})
+set(GR_PKG_DOC_DIR ${GR_DOC_DIR}/${CMAKE_PROJECT_NAME}-${DOCVER})
set(GR_CONF_DIR etc)
set(GR_PKG_CONF_DIR ${GR_CONF_DIR}/${CMAKE_PROJECT_NAME}/conf.d)
set(GR_LIBEXEC_DIR libexec)
@@ -217,4 +217,4 @@ CPACK_FINALIZE()
########################################################################
GR_PRINT_COMPONENT_SUMMARY()
message(STATUS "Using install prefix: ${CMAKE_INSTALL_PREFIX}")
-message(STATUS "Building for version: ${VERSION}")
+message(STATUS "Building for version: ${VERSION} / ${LIBVER}")
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}")