[x265] [PATCH 2/2] Set version and latest tag if using a git repository

Rafaël Carré funman at videolan.org
Wed Dec 18 11:28:15 CET 2013


---
 source/cmake/version.cmake | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)

diff --git a/source/cmake/version.cmake b/source/cmake/version.cmake
index 0d2346f..5aa5935 100644
--- a/source/cmake/version.cmake
+++ b/source/cmake/version.cmake
@@ -1,4 +1,5 @@
 find_program(HG_EXECUTABLE hg)
+find_program(GIT_EXECUTABLE git)
 
 if(EXISTS ${CMAKE_SOURCE_DIR}/../.hg_archival.txt)
     # read the lines of the archive summary file to extract the version
@@ -71,6 +72,24 @@ elseif(HG_EXECUTABLE AND EXISTS ${CMAKE_SOURCE_DIR}/../.hg)
     endif()
 
     set(X265_VERSION ${HG_REVISION})
+elseif(GIT_EXECUTABLE AND EXISTS ${CMAKE_SOURCE_DIR}/../.git)
+    execute_process(
+        COMMAND
+        ${GIT_EXECUTABLE} describe --tags --abbrev=0
+        WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
+        OUTPUT_VARIABLE X265_LATEST_TAG
+        ERROR_QUIET
+        OUTPUT_STRIP_TRAILING_WHITESPACE
+        )
+
+    execute_process(
+        COMMAND
+        ${GIT_EXECUTABLE} describe --tags
+        WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
+        OUTPUT_VARIABLE X265_VERSION
+        ERROR_QUIET
+        OUTPUT_STRIP_TRAILING_WHITESPACE
+        )
 else()
     set(X265_VERSION "unknown")
 endif()
-- 
1.8.5.2



More information about the x265-devel mailing list