1 # WRF Macro to identify the commit where the compiled code came from
2 macro( wrf_git_commit )
5 set( oneValueArgs WORKING_DIRECTORY RESULT_VAR )
10 "${options}" "${oneValueArgs}" "${multiValueArgs}"
15 message( STATUS "Retrieving git information..." )
17 OUTPUT_VARIABLE WRF_GIT_COMMIT_SHA
18 COMMAND git describe --dirty --long --always --abbrev=40
19 WORKING_DIRECTORY ${WRF_GIT_COMMIT_WORKING_DIRECTORY}
20 RESULT_VARIABLE WRF_GIT_COMMIT_NO_GIT_REPO
21 # ECHO_OUTPUT_VARIABLE
22 OUTPUT_STRIP_TRAILING_WHITESPACE
25 OUTPUT_VARIABLE WRF_GIT_COMMIT_DIFF
26 COMMAND git diff --shortstat
27 WORKING_DIRECTORY ${WRF_GIT_COMMIT_WORKING_DIRECTORY}
28 # ECHO_OUTPUT_VARIABLE
29 OUTPUT_STRIP_TRAILING_WHITESPACE
32 if ( ${WRF_GIT_COMMIT_NO_GIT_REPO} GREATER 0 )
33 set( ${WRF_GIT_COMMIT_RESULT_VAR} "No git found or not a git repository, git commit version not available.")
34 message( STATUS "git info : Unable to get info" )
36 set( ${WRF_GIT_COMMIT_RESULT_VAR} "git info : ${WRF_GIT_COMMIT_SHA} ${WRF_GIT_COMMIT_DIFF}" )
37 message( STATUS "git SHA : ${WRF_GIT_COMMIT_SHA}" )
38 message( STATUS "git diff : ${WRF_GIT_COMMIT_DIFF}" )