提交 bb13328e 编写于 作者: W wangkuiyi 提交者: GitHub

Merge pull request #1 from reyoung/docker_openssh

Refine cmake version tag.
...@@ -73,28 +73,8 @@ include(coveralls) ...@@ -73,28 +73,8 @@ include(coveralls)
# Set PaddlePaddle version to Git tag name or Git commit ID. # Set PaddlePaddle version to Git tag name or Git commit ID.
find_package(Git REQUIRED) find_package(Git REQUIRED)
execute_process( # version.cmake will get the current PADDLE_VERSION
COMMAND ${GIT_EXECUTABLE} describe --tags --exact-match --abbrev=0 include(version)
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()
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})
set(PADDLE_VERSION ${GIT_SHA1})
else()
set(PADDLE_VERSION "unknown")
message(WARNING "Cannot add paddle version from git tag")
endif()
endif()
add_definitions(-DPADDLE_VERSION=\"${PADDLE_VERSION}\") add_definitions(-DPADDLE_VERSION=\"${PADDLE_VERSION}\")
......
# Get the latest git tag.
set(PADDLE_VERSION $ENV{PADDLE_VERSION})
set(tmp_version "HEAD")
while ("${PADDLE_VERSION}" STREQUAL "")
execute_process(
COMMAND ${GIT_EXECUTABLE} describe --tags --abbrev=0 ${tmp_version}
WORKING_DIRECTORY ${PROJ_ROOT}
OUTPUT_VARIABLE GIT_TAG_NAME
RESULT_VARIABLE GIT_RESULT
ERROR_QUIET OUTPUT_STRIP_TRAILING_WHITESPACE)
if (NOT ${GIT_RESULT})
# Check the tag is a correct version
if (${GIT_TAG_NAME} MATCHES "v[0-9]+\\.[0-9]+\\.[0-9]+(\\.(a|b|rc)\\.[0-9]+)?")
string(REPLACE "v" "" PADDLE_VERSION ${GIT_TAG_NAME})
else() # otherwise, get the previous git tag name.
set(tmp_version "${GIT_TAG_NAME}~1")
endif()
else()
set(PADDLE_VERSION "0.0.0")
message(WARNING "Cannot add paddle version from git tag")
endif()
endwhile()
message(STATUS "Paddle version is ${PADDLE_VERSION}")
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册