diff --git a/Code/Mantid/Build/CMake/CommonSetup.cmake b/Code/Mantid/Build/CMake/CommonSetup.cmake index 579b1eaf60fc163d4e619ad294775ba7830a6ad3..0e27c0544edbeb493620a442ac7a060011c5fe58 100644 --- a/Code/Mantid/Build/CMake/CommonSetup.cmake +++ b/Code/Mantid/Build/CMake/CommonSetup.cmake @@ -66,13 +66,24 @@ find_package ( ZLIB REQUIRED ) set ( CMAKE_INCLUDE_PATH ${MAIN_CMAKE_INCLUDE_PATH} ) ########################################################################### -# Previously looked for subversion. Used for version headers - faked if not found. -########################################################################### - -# Just use a dummy version number and print a warning -message ( STATUS "Until we do something following move to Git - using dummy revision number and date" ) -set ( MtdVersion_WC_LAST_CHANGED_REV 0 ) -set ( MtdVersion_WC_LAST_CHANGED_DATE Unknown ) +# Look for Git. Used for version headers - faked if not found. +########################################################################### + +find_package ( Git ) +if ( GIT_FOUND ) + execute_process ( COMMAND ${GIT_EXECUTABLE} describe --tags --long OUTPUT_VARIABLE MtdVersion_WC_LAST_CHANGED_REV + WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} + ) + string ( REGEX MATCH "[-](.*)[-]" MtdVersion_WC_LAST_CHANGED_REV ${MtdVersion_WC_LAST_CHANGED_REV} ) + string ( REGEX MATCH "[^-](.*)[^-]" MtdVersion_WC_LAST_CHANGED_REV ${MtdVersion_WC_LAST_CHANGED_REV} ) + # Will do the date later... + set ( MtdVersion_WC_LAST_CHANGED_DATE Unknown ) +else() + # Just use a dummy version number and print a warning + message ( STATUS "Git not found - using dummy revision number and date" ) + set ( MtdVersion_WC_LAST_CHANGED_REV 0 ) + set ( MtdVersion_WC_LAST_CHANGED_DATE Unknown ) +endif() mark_as_advanced( MtdVersion_WC_LAST_CHANGED_REV MtdVersion_WC_LAST_CHANGED_DATE )