OSDN Git Service

[BUILD][CMAKE] Add __GIT_REPO_VERSION definition.
[csp-qt/common_source_project-fm7.git] / source / build-cmake / cmake / config_sharedlibs.cmake
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)