-#FIND_PACKAGE(Subversion)
-
-#if (Subversion_FOUND)
-# Subversion_WC_INFO("${PROJECT_SOURCE_DIR}" Project)
-# MESSAGE("Current revision is ${Project_WC_REVISION}")
-# set (VERSION ${Project_WC_REVISION})
-# Subversion_WC_LOG(${PROJECT_SOURCE_DIR} Project)
-# MESSAGE("Last changed log is ${Project_LAST_CHANGED_LOG}")
-#endif(Subversion_FOUND)
-
-
-#FIND_PROGRAM(Subversion_SVN_EXECUTABLE svn DOC "subversion command line client")
-#EXECUTE_PROCESS(
-# COMMAND ${Subversion_SVN_EXECUTABLE} --version
-# OUTPUT_VARIABLE VERSION
-# OUTPUT_STRIP_TRAILING_WHITESPACE
-#)
-FIND_PROGRAM(GIT_EXECUTABLE git DOC "git command line client")
-
-#set (VERSION "")
+FIND_PROGRAM(GIT_EXECUTABLE NAMES git git.exe DOC "git command line client")
+
+get_filename_component(SOURCE_DIR ${SRC} PATH)
+
EXECUTE_PROCESS(
COMMAND ${GIT_EXECUTABLE} svn info
COMMAND grep "Revision"
- WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
+ WORKING_DIRECTORY "${SOURCE_DIR}"
OUTPUT_VARIABLE VERSION
OUTPUT_STRIP_TRAILING_WHITESPACE
)
-set( ${NAME} "unknown" )
+if (NOT DEFINED ${NAME})
+ set( ${NAME} "unknown" )
+endif()
if (NOT VERSION)
FIND_PACKAGE(Subversion)
EXECUTE_PROCESS(
COMMAND svnversion
- WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
+ WORKING_DIRECTORY "${SOURCE_DIR}"
OUTPUT_VARIABLE VERSION
OUTPUT_STRIP_TRAILING_WHITESPACE
)
endif(Subversion_FOUND)
- if (VERSION)
+ if (VERSION AND (NOT ${VERSION} MATCHES "^exported"))
+ if (STRIP_M)
+ string(REGEX REPLACE "M$" "" VERSION ${VERSION})
+ endif()
set( ${NAME} ${VERSION} )
- endif(VERSION)
+ endif()
else()
string(REGEX REPLACE "Revision: " "" ${NAME} ${VERSION})
endif(NOT VERSION)