for version info, read SCL_VERSION.txt if git fails

This commit is contained in:
Mark Pictor 2011-11-27 11:41:27 -05:00
parent dc30ee21fd
commit d190a1e042
2 changed files with 12 additions and 8 deletions

1
SCL_VERSION.txt Normal file
View file

@ -0,0 +1 @@
0.4

View file

@ -6,24 +6,27 @@
# http://www.cmake.org/pipermail/cmake/2009-February/027014.html # http://www.cmake.org/pipermail/cmake/2009-February/027014.html
#scl_version_string.h defines scl_version() which returns a pretty commit description and a build timestamp. #scl_version_string.h defines scl_version() which returns a pretty commit description and a build timestamp.
set(VERS_FILE ${SOURCE_DIR}/SCL_VERSION.txt )
if( EXISTS ${SOURCE_DIR}/.git ) if( EXISTS ${SOURCE_DIR}/.git )
find_package(Git QUIET) find_package(Git QUIET)
if(GIT_FOUND) if(GIT_FOUND)
execute_process(COMMAND ${GIT_EXECUTABLE} describe --tags RESULT_VARIABLE res_var OUTPUT_VARIABLE GIT_COM_ID ) execute_process(COMMAND ${GIT_EXECUTABLE} describe --tags RESULT_VARIABLE res_var OUTPUT_VARIABLE GIT_COMMIT_ID )
if( NOT ${res_var} EQUAL 0 ) if( NOT ${res_var} EQUAL 0 )
set( GIT_COMMIT_ID "unknown (no tags?)") file( READ ${VERS_FILE} GIT_COMMIT_ID LIMIT 255 )
message( WARNING "Git failed (invalid repo, or no tags). Build will not contain git revision info." ) message( WARNING "Git failed (probably no tags in repo). Build will contain revision info from ${VERS_FILE}." )
endif() endif()
string( REPLACE "\n" "" GIT_COMMIT_ID ${GIT_COM_ID} )
else(GIT_FOUND) else(GIT_FOUND)
set( GIT_COMMIT_ID "unknown (git not found!)") file( READ ${VERS_FILE} GIT_COMMIT_ID LIMIT 255 )
message( WARNING "Git not found. Build will not contain git revision info." ) message( WARNING "Git not found. Build will contain revision info from ${VERS_FILE}." )
endif(GIT_FOUND) endif(GIT_FOUND)
else() else()
set( GIT_COMMIT_ID "unknown (not a repository!)") file( READ ${VERS_FILE} GIT_COMMIT_ID LIMIT 255 )
message( WARNING "Git failed (.git not found). Build will not contain git revision info." ) message( WARNING "Git failed ('.git' not found). Build will contain revision info from ${VERS_FILE}." )
endif() endif()
string( REPLACE "\n" "" GIT_COMMIT_ID ${GIT_COMMIT_ID} )
set( res_var 1 ) set( res_var 1 )
IF (WIN32) IF (WIN32)
EXECUTE_PROCESS(COMMAND "date" "/T" RESULT_VARIABLE res_var OUTPUT_VARIABLE TIMESTAMP ) EXECUTE_PROCESS(COMMAND "date" "/T" RESULT_VARIABLE res_var OUTPUT_VARIABLE TIMESTAMP )