Skip to content

Commit

Permalink
Added GIT_VERSION option to get a git versioned package from git if
Browse files Browse the repository at this point in the history
needed
  • Loading branch information
anaselli committed Jul 21, 2012
1 parent 5069d0d commit 72acbfc
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
22 changes: 22 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,28 @@ ENDIF( PLUGINNAME )
SET( CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake/Modules" "${BUILDTOOLS_DIR}" "${CMAKE_MODULE_PATH}" )

INCLUDE( LibyuiCommon )

#if you need to get a git versioned package you can use cmake -DGIT_VERSION=on
if (GIT_VERSION)
FIND_PACKAGE(Git)
if(GIT_FOUND)
exec_program(
"${GIT_EXECUTABLE}"
${CMAKE_CURRENT_SOURCE_DIR}
ARGS "describe"
OUTPUT_VARIABLE GIT_VERSION )

string( REGEX MATCH "-g[0-9|a-f]+$" VERSION_SHA1 ${GIT_VERSION} )
string( REGEX REPLACE "[g]" "" VERSION_SHA1 ${VERSION_SHA1} )
set (GIT_SHA1_VERSION "${VERSION_SHA1}")
else()
message (STATUS "GIT_VERSION option needs git installed")
set (GIT_SHA1_VERSION "")
endif()
else()
set (GIT_SHA1_VERSION "")
endif()

INCLUDE( "${CMAKE_CURRENT_SOURCE_DIR}/VERSION.cmake" )

INITIALIZE()
Expand Down
2 changes: 1 addition & 1 deletion VERSION.cmake
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
SET( VERSION_MAJOR "2" )
SET( VERSION_MINOR "42" )
SET( VERSION_PATCH "1" )
SET( VERSION "${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}" )
SET( VERSION "${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}${VERSION_SHA1}" )

0 comments on commit 72acbfc

Please sign in to comment.