提交 4e2071f4 编写于 作者: Y Yi Wang

Make cmake derive Paddle version from Git tag or Git commit ID

上级 aca08255
cmake_minimum_required(VERSION 2.8) cmake_minimum_required(VERSION 2.8)
project(paddle CXX C) project(paddle CXX C)
set(PADDLE_MAJOR_VERSION 0)
set(PADDLE_MINOR_VERSION 9)
set(PADDLE_PATCH_VERSION 0a0)
set(PADDLE_VERSION ${PADDLE_MAJOR_VERSION}.${PADDLE_MINOR_VERSION}.${PADDLE_PATCH_VERSION})
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake") set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake")
set(PROJ_ROOT ${CMAKE_SOURCE_DIR}) set(PROJ_ROOT ${CMAKE_SOURCE_DIR})
...@@ -64,31 +60,31 @@ include(check_packages) ...@@ -64,31 +60,31 @@ include(check_packages)
include(swig) include(swig)
include(coveralls) include(coveralls)
# add PaddlePaddle version # Set PaddlePaddle version to Git tag name or Git commit ID.
if(DEFINED ENV{PADDLE_VERSION}) find_package(Git REQUIRED)
add_definitions(-DPADDLE_VERSION=\"$ENV{PADDLE_VERSION}\") execute_process(
COMMAND ${GIT_EXECUTABLE} describe --tags --exact-match --abbrev=0
WORKING_DIRECTORY ${PROJ_ROOT}
OUTPUT_VARIABLE GIT_TAG_NAME
RESULT_VARIABLE GIT_RESULT
ERROR_QUIET OUTPUT_STRIP_TRAILING_WHITESPACE)
if(NOT ${GIT_RESULT})
set(PADDLE_VERSION ${GIT_TAG_NAME})
else() else()
if(EXISTS ${PROJ_ROOT}/.svn/) execute_process(
find_package(Subversion REQUIRED) COMMAND ${GIT_EXECUTABLE} log -1 --format=%H
if(SUBVERSION_FOUND) WORKING_DIRECTORY ${PROJ_ROOT}
Subversion_WC_INFO(${PROJ_ROOT} Project) OUTPUT_VARIABLE GIT_SHA1
add_definitions(-DPADDLE_VERSION=${Project_WC_REVISION}) RESULT_VARIABLE GIT_RESULT
endif() ERROR_QUIET OUTPUT_STRIP_TRAILING_WHITESPACE)
elseif(EXISTS ${PROJ_ROOT}/.git/) if(NOT ${GIT_RESULT})
find_package(Git REQUIRED) set(PADDLE_VERSION ${GIT_SHA1})
execute_process( else()
COMMAND ${GIT_EXECUTABLE} log -1 --format=%H set(PADDLE_VERSION "unknown")
WORKING_DIRECTORY ${PROJ_ROOT} message(WARNING "Cannot add paddle version from git tag")
OUTPUT_VARIABLE GIT_SHA1 endif()
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() endif()
add_definitions(-DPADDLE_VERSION=\"${PADDLE_VERSION}\")
if(NOT WITH_GPU) if(NOT WITH_GPU)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册