File tree Expand file tree Collapse file tree 2 files changed +26
-22
lines changed
Expand file tree Collapse file tree 2 files changed +26
-22
lines changed Original file line number Diff line number Diff line change @@ -73,28 +73,8 @@ include(coveralls)
7373
7474# Set PaddlePaddle version to Git tag name or Git commit ID.
7575find_package (Git REQUIRED)
76- execute_process (
77- COMMAND ${GIT_EXECUTABLE} describe --tags --exact-match --abbrev=0
78- WORKING_DIRECTORY ${PROJ_ROOT}
79- OUTPUT_VARIABLE GIT_TAG_NAME
80- RESULT_VARIABLE GIT_RESULT
81- ERROR_QUIET OUTPUT_STRIP_TRAILING_WHITESPACE)
82- if (NOT ${GIT_RESULT} )
83- set (PADDLE_VERSION ${GIT_TAG_NAME} )
84- else ()
85- execute_process (
86- COMMAND ${GIT_EXECUTABLE} log -1 --format=%h
87- WORKING_DIRECTORY ${PROJ_ROOT}
88- OUTPUT_VARIABLE GIT_SHA1
89- RESULT_VARIABLE GIT_RESULT
90- ERROR_QUIET OUTPUT_STRIP_TRAILING_WHITESPACE)
91- if (NOT ${GIT_RESULT} )
92- set (PADDLE_VERSION ${GIT_SHA1} )
93- else ()
94- set (PADDLE_VERSION "unknown" )
95- message (WARNING "Cannot add paddle version from git tag" )
96- endif ()
97- endif ()
76+ # version.cmake will get the current PADDLE_VERSION
77+ include (version )
9878add_definitions (-DPADDLE_VERSION=\"${PADDLE_VERSION} \")
9979
10080
Original file line number Diff line number Diff line change 1+ # Get the latest git tag.
2+ set (PADDLE_VERSION $ENV{PADDLE_VERSION} )
3+ set (tmp_version "HEAD" )
4+ while ("${PADDLE_VERSION} " STREQUAL "" )
5+ execute_process (
6+ COMMAND ${GIT_EXECUTABLE} describe --tags --abbrev=0 ${tmp_version}
7+ WORKING_DIRECTORY ${PROJ_ROOT}
8+ OUTPUT_VARIABLE GIT_TAG_NAME
9+ RESULT_VARIABLE GIT_RESULT
10+ ERROR_QUIET OUTPUT_STRIP_TRAILING_WHITESPACE)
11+ if (NOT ${GIT_RESULT} )
12+ # Check the tag is a correct version
13+ if (${GIT_TAG_NAME} MATCHES "v[0-9]+\\ .[0-9]+\\ .[0-9]+(\\ .(a|b|rc)\\ .[0-9]+)?" )
14+ string (REPLACE "v" "" PADDLE_VERSION ${GIT_TAG_NAME} )
15+ else () # otherwise, get the previous git tag name.
16+ set (tmp_version "${GIT_TAG_NAME} ~1" )
17+ endif ()
18+ else ()
19+ set (PADDLE_VERSION "0.0.0" )
20+ message (WARNING "Cannot add paddle version from git tag" )
21+ endif ()
22+ endwhile ()
23+
24+ message (STATUS "Paddle version is ${PADDLE_VERSION} " )
You can’t perform that action at this time.
0 commit comments