[vlmc-devel] cmake: Split out git versionning code
Hugo Beauzée-Luyssen
git at videolan.org
Fri Apr 1 23:56:20 CEST 2016
vlmc | branch: master | Hugo Beauzée-Luyssen <hugo at beauzee.fr> | Fri Apr 1 23:48:16 2016 +0200| [1a4e69007af0d8f7044ee93436f1a8b0276a6411] | committer: Hugo Beauzée-Luyssen
cmake: Split out git versionning code
> https://code.videolan.org/videolan/vlmc/commit/1a4e69007af0d8f7044ee93436f1a8b0276a6411
---
CMakeLists.txt | 21 +++++++--------------
cmake/git-version.cmake | 11 +++++++++++
2 files changed, 18 insertions(+), 14 deletions(-)
diff --git a/CMakeLists.txt b/CMakeLists.txt
index fc65716..7e6c19d 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -2,8 +2,14 @@
# VLMC build system
# Authors: Rohit Yadav <rohityadav89 at gmail.com>
# Ludovic Fauvet <etix at vlmc.org>
+# Hugo Beauzée-Luyssen <hugo at beauzee.fr>
#
+# Set path to additional CMake modules
+SET(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake ${CMAKE_MODULE_PATH})
+
+include(git-version)
+
# Project Info
SET(PROJECT_NAME_SHORT "VLMC")
SET(PROJECT_NAME_LONG "VideoLAN Movie Creator")
@@ -32,21 +38,11 @@ IF(WIN32)
ADD_DEFINITIONS( -D__USE_MINGW_ANSI_STDIO=1 )
ENDIF(WIN32)
-# Find Git Version Patch
-FIND_PROGRAM(GIT git)
-IF(GIT)
- EXECUTE_PROCESS(
- WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
- COMMAND ${GIT} rev-parse --short HEAD
- OUTPUT_VARIABLE GIT_OUT OUTPUT_STRIP_TRAILING_WHITESPACE
- )
- SET(GIT_PATCH "git${GIT_OUT}")
-ENDIF(GIT)
-
# version: 0.2.x
cmake_policy(SET CMP0048 NEW)
STRING(TOLOWER ${PROJECT_NAME_SHORT} PROJECT_NAME_SHORT_LOWER)
PROJECT(${PROJECT_NAME_SHORT_LOWER} VERSION 0.2.0)
+append_git_version()
MESSAGE(STATUS "VLMC Version: ${CPACK_PACKAGE_VERSION}")
@@ -71,9 +67,6 @@ SET(CMAKE_INCLUDE_CURRENT_DIR ON)
# Instruct CMake to run moc automatically when needed.
SET(CMAKE_AUTOMOC ON)
-# Set path to additional CMake modules
-SET(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake ${CMAKE_MODULE_PATH})
-
# Path to contribs
SET(CONTRIBS_PATH ${CMAKE_CURRENT_SOURCE_DIR}/contribs)
diff --git a/cmake/git-version.cmake b/cmake/git-version.cmake
new file mode 100644
index 0000000..199548a
--- /dev/null
+++ b/cmake/git-version.cmake
@@ -0,0 +1,11 @@
+function (append_git_version)
+ find_program(GIT git)
+ if(GIT)
+ execute_process(
+ WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
+ COMMAND ${GIT} rev-parse --short HEAD
+ OUTPUT_VARIABLE GIT_OUT OUTPUT_STRIP_TRAILING_WHITESPACE
+ )
+ set(PROJECT_VERSION "${PROJECT_VERSION}-git-${GIT_OUT}" PARENT_SCOPE)
+ endif()
+endfunction()
More information about the Vlmc-devel
mailing list