From 86bb5ef1693c601fd72fc0d5f16a239cb9f8f68a Mon Sep 17 00:00:00 2001 From: QiJune Date: Mon, 10 Oct 2016 10:18:07 +0800 Subject: [PATCH] Read git sha1 when building Paddle, and add it to PADDLE_VERSION macro * save the model file including git sha1 --- CMakeLists.txt | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index af6a13efbde..44e93f22c0e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -65,6 +65,19 @@ else() Subversion_WC_INFO(${PROJ_ROOT} Project) add_definitions(-DPADDLE_VERSION=${Project_WC_REVISION}) endif() + elseif(EXISTS ${PROJ_ROOT}/.git/) + find_package(Git REQUIRED) + execute_process( + COMMAND ${GIT_EXECUTABLE} log -1 --format=%H + WORKING_DIRECTORY ${PROJ_ROOT} + OUTPUT_VARIABLE GIT_SHA1 + RESULT_VARIABLE GIT_RESULT + ERROR_QUIET OUTPUT_STRIP_TRAILING_WHITESPACE) + if(NOT ${GIT_RESULT}) + add_definitions(-DPADDLE_VERSION=\"${GIT_SHA1}\") + else() + message(WARNING "Cannot add paddle version from git tag") + endif() endif() endif() -- GitLab