OSDN Git Service

[BUILD][CMAKE] Add __GIT_REPO_VERSION definition.
authorK.Ohta <whatisthis.sowhat@gmail.com>
Mon, 6 Aug 2018 03:30:45 +0000 (12:30 +0900)
committerK.Ohta <whatisthis.sowhat@gmail.com>
Mon, 6 Aug 2018 03:30:45 +0000 (12:30 +0900)
source/build-cmake/cmake/config_commonsource.cmake
source/build-cmake/cmake/config_sharedlibs.cmake

index 3d8098b..04f7998 100644 (file)
@@ -115,11 +115,11 @@ else()
   add_definitions(-D_GLIBCXX_USE_CXX11_ABI=1)
 endif()
 
+
 SET(CMAKE_AUTOMOC OFF)
 SET(CMAKE_AUTORCC ON)
 SET(CMAKE_INCLUDE_CURRENT_DIR ON)
 
-
 add_definitions(-D_USE_QT)
 add_definitions(-DUSE_QT)
 add_definitions(-DQT_MAJOR_VERSION=${Qt5Widgets_VERSION_MAJOR})
@@ -140,6 +140,18 @@ include_directories(${THREADS_INCLUDE_PATH})
 
 include(FindPkgConfig)
 
+find_package(Git)
+if(GIT_FOUND)
+       execute_process(COMMAND ${GIT_EXECUTABLE} rev-parse HEAD OUTPUT_VARIABLE __tstr)
+       string(FIND ${__tstr} "fatal" __notfound)
+       string(REPLACE "\n" "" __tstr2 ${__tstr})
+       if(${__notfound} EQUAL -1)
+                  add_definitions(-D__GIT_REPO_VERSION=${__tstr2})
+       else()
+                  add_definitions(-U__GIT_REPO_VERSION)
+       endif()
+endif()
+
 include(FindLibAV)
     if(LIBAV_FOUND)
       add_definitions(-DUSE_LIBAV)
index 1e3e311..15f5c9c 100644 (file)
@@ -97,6 +97,18 @@ include_directories(${THREADS_INCLUDE_PATH})
 
 include(FindPkgConfig)
 
+find_package(Git)
+if(GIT_FOUND)
+       execute_process(COMMAND ${GIT_EXECUTABLE} rev-parse HEAD OUTPUT_VARIABLE __tstr)
+       string(FIND ${__tstr} "fatal" __notfound)
+       string(REPLACE "\n" "" __tstr2 ${__tstr})
+       if(${__notfound} EQUAL -1)
+                  add_definitions(-D__GIT_REPO_VERSION=${__tstr2})
+       else()
+                  add_definitions(-U__GIT_REPO_VERSION)
+       endif()
+endif()
+
 include(FindLibAV)
 if(LIBAV_FOUND)
       add_definitions(-DUSE_LIBAV)