Update cmake version script to use git describe instead of svn info.

This commit is contained in:
John Maguire 2011-07-19 16:55:47 +02:00
parent f5b8bbec9e
commit a2e4f8e6b3
1 changed files with 22 additions and 23 deletions

View File

@ -6,8 +6,8 @@ set(CLEMENTINE_VERSION_MINOR 7)
set(CLEMENTINE_VERSION_PATCH 1) set(CLEMENTINE_VERSION_PATCH 1)
#set(CLEMENTINE_VERSION_PRERELEASE rc1) #set(CLEMENTINE_VERSION_PRERELEASE rc1)
# This should be set to OFF in an svn tag # This should be set to OFF in a tag
set(INCLUDE_SVN_REVISION ON) set(INCLUDE_GIT_REVISION ON)
# The format for version numbers is: # The format for version numbers is:
# Display: $major.$minor[.$patch] [$prerelease] [r$svn] # Display: $major.$minor[.$patch] [$prerelease] [r$svn]
@ -35,26 +35,25 @@ if(CLEMENTINE_VERSION_PRERELEASE)
endif(CLEMENTINE_VERSION_PRERELEASE) endif(CLEMENTINE_VERSION_PRERELEASE)
# Add svn revision # Add svn revision
if(FORCE_SVN_REVISION) if(FORCE_GIT_REVISION)
set(SVN_REVISION ${FORCE_SVN_REVISION}) set(GIT_REVISION ${FORCE_GIT_REVISION})
else(FORCE_SVN_REVISION) else(FORCE_GIT_REVISION)
include(FindSubversion) find_program(GIT_EXECUTABLE git)
find_package(Subversion)
if(Subversion_FOUND) if(NOT GIT_EXECUTABLE-NOTFOUND)
execute_process(COMMAND ${Subversion_SVN_EXECUTABLE} info ${PROJECT_SOURCE_DIR} execute_process(COMMAND ${GIT_EXECUTABLE} describe
RESULT_VARIABLE SVN_INFO_RESULT RESULT_VARIABLE GIT_INFO_RESULT
OUTPUT_QUIET OUTPUT_VARIABLE GIT_REV
ERROR_QUIET) ERROR_QUIET
if(${SVN_INFO_RESULT} EQUAL 0) OUTPUT_STRIP_TRAILING_WHITESPACE)
Subversion_WC_INFO(${PROJECT_SOURCE_DIR} clementine) if(${GIT_INFO_RESULT} EQUAL 0)
set(SVN_REVISION ${clementine_WC_REVISION}) set(GIT_REVISION ${GIT_REV})
endif(${SVN_INFO_RESULT} EQUAL 0) endif(${GIT_INFO_RESULT} EQUAL 0)
endif(Subversion_FOUND) endif(NOT GIT_EXECUTABLE-NOTFOUND)
endif(FORCE_SVN_REVISION) endif(FORCE_GIT_REVISION)
if(INCLUDE_SVN_REVISION AND SVN_REVISION) if(INCLUDE_GIT_REVISION AND GIT_REVISION)
set(CLEMENTINE_VERSION_DISPLAY "${CLEMENTINE_VERSION_DISPLAY} r${SVN_REVISION}") set(CLEMENTINE_VERSION_DISPLAY "${GIT_REVISION}")
set(CLEMENTINE_VERSION_DEB "${CLEMENTINE_VERSION_DEB}.r${SVN_REVISION}") set(CLEMENTINE_VERSION_DEB "${GIT_REVISION}")
set(CLEMENTINE_VERSION_RPM "${CLEMENTINE_VERSION_RPM}.r${SVN_REVISION}") set(CLEMENTINE_VERSION_RPM "${GIT_REVISION}")
endif(INCLUDE_SVN_REVISION AND SVN_REVISION) endif(INCLUDE_GIT_REVISION AND GIT_REVISION)