提交 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,18 +60,17 @@ include(check_packages) ...@@ -64,18 +60,17 @@ 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/)
find_package(Subversion REQUIRED)
if(SUBVERSION_FOUND)
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( execute_process(
COMMAND ${GIT_EXECUTABLE} log -1 --format=%H COMMAND ${GIT_EXECUTABLE} log -1 --format=%H
WORKING_DIRECTORY ${PROJ_ROOT} WORKING_DIRECTORY ${PROJ_ROOT}
...@@ -83,12 +78,13 @@ else() ...@@ -83,12 +78,13 @@ else()
RESULT_VARIABLE GIT_RESULT RESULT_VARIABLE GIT_RESULT
ERROR_QUIET OUTPUT_STRIP_TRAILING_WHITESPACE) ERROR_QUIET OUTPUT_STRIP_TRAILING_WHITESPACE)
if(NOT ${GIT_RESULT}) if(NOT ${GIT_RESULT})
add_definitions(-DPADDLE_VERSION=\"${GIT_SHA1}\") set(PADDLE_VERSION ${GIT_SHA1})
else() else()
set(PADDLE_VERSION "unknown")
message(WARNING "Cannot add paddle version from git tag") message(WARNING "Cannot add paddle version from git tag")
endif() 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.
先完成此消息的编辑!
想要评论请 注册