-FIND_PROGRAM(GIT_EXECUTABLE git DOC "git command line client")
+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)