Skip to content
Browse files

Include Git commit hash in config.h

  • Loading branch information...
1 parent faddeb2 commit 96e4f73a94e0697ce7200e09983d447220ea5a0b @Forkk committed Feb 21, 2013
Showing with 20 additions and 1 deletion.
  1. +18 −1 CMakeLists.txt
  2. +2 −0 config.h.in
View
19 CMakeLists.txt
@@ -93,10 +93,27 @@ SET(MultiMC_VERSION_MAJOR 5)
SET(MultiMC_VERSION_MINOR 0)
SET(MultiMC_VERSION_REV 0)
-# Jenkins build number.
+# Jenkins build number
SET(MultiMC_VERSION_BUILD 0 CACHE STRING "Build number.")
MESSAGE(STATUS "MultiMC build #${MultiMC_VERSION_BUILD}")
+# Check the current Git commit
+execute_process(COMMAND git rev-parse HEAD
+ WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
+ RESULT_VARIABLE GIT_COMMIT_CHECK_RESULTVAR
+ OUTPUT_VARIABLE GIT_COMMIT_CHECK_OUTVAR
+ OUTPUT_STRIP_TRAILING_WHITESPACE
+)
+
+# If Git executed successfully
+IF(GIT_COMMIT_CHECK_RESULTVAR EQUAL 0)
+ SET(MultiMC_GIT_COMMIT "${GIT_COMMIT_CHECK_OUTVAR}")
+ MESSAGE(STATUS "Git commit: ${MultiMC_GIT_COMMIT}")
+ELSE()
+ SET(MultiMC_GIT_COMMIT "Unknown")
+ MESSAGE(STATUS "Failed to check Git commit. ${GIT_COMMIT_CHECK_RESULTVAR}")
+ENDIF()
+
######## Set Jenkins info ########
# Jenkins build tag
View
2 config.h.in
@@ -3,6 +3,8 @@
#define VERSION_REVISION @MultiMC_VERSION_REV@
#define VERSION_BUILD @MultiMC_VERSION_BUILD@
+#define GIT_COMMIT "@MultiMC_GIT_COMMIT@"
+
#define VERSION_STR "@MultiMC_VERSION_MAJOR@.@MultiMC_VERSION_MINOR@.@MultiMC_VERSION_REV@.@MultiMC_VERSION_BUILD@"
#define x86 1

0 comments on commit 96e4f73

Please sign in to comment.
Something went wrong with that request. Please try again.