summaryrefslogtreecommitdiff
path: root/cmake/Modules
diff options
context:
space:
mode:
authorJosh Blum <josh@joshknows.com>2011-07-28 09:55:06 -0700
committerJosh Blum <josh@joshknows.com>2011-07-28 09:55:06 -0700
commit152db0ca6a8771ab4c95a6d4410ca749085ec157 (patch)
tree3b0f4ec961b073c6755883aeefe1ca208355d024 /cmake/Modules
parent250f4ac60afdc5e502c8ab69ced8267f0e14e590 (diff)
cmake: be a little more robust when checking source code version
Diffstat (limited to 'cmake/Modules')
-rw-r--r--cmake/Modules/GrVersion.cmake17
1 files changed, 15 insertions, 2 deletions
diff --git a/cmake/Modules/GrVersion.cmake b/cmake/Modules/GrVersion.cmake
index 05a4250f46..ab2959c0d9 100644
--- a/cmake/Modules/GrVersion.cmake
+++ b/cmake/Modules/GrVersion.cmake
@@ -28,6 +28,12 @@ SET(__INCLUDED_GR_VERSION_CMAKE TRUE)
# sets VERSION and LIBVER
########################################################################
+UNSET(VERSION)
+UNSET(LIBVER)
+
+########################################################################
+# Extract the version string from git describe.
+########################################################################
FIND_PACKAGE(Git)
IF(GIT_FOUND)
MESSAGE(STATUS "Extracting version information from git...")
@@ -38,7 +44,12 @@ IF(GIT_FOUND)
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.
+########################################################################
+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
@@ -46,9 +57,11 @@ IF(GIT_FOUND)
IF(NOT LIBVER)
MESSAGE(WARNING "Tried to extract $LIBVER from $VERSION but failed... using default")
ENDIF()
-ENDIF(GIT_FOUND)
+ENDIF()
-#ensure that the version strings are set no matter what
+########################################################################
+# Ensure that the version strings are set no matter what.
+########################################################################
IF(NOT VERSION)
SET(VERSION "v3.x.x-unknown")
ENDIF()