Skip to content

Commit

Permalink
refine versioning
Browse files Browse the repository at this point in the history
Need to print version correctly when there is no git.

Tracked-On: OAM-105294
Signed-off-by: Yadong Qi <yadong.qi@intel.com>
  • Loading branch information
YadongQi authored and sysopenci committed Dec 19, 2022
1 parent 133a281 commit 41c8d22
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions src/cmake/revisionCMake.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -6,29 +6,34 @@
#
#

set(build_version_ "unknown")
set(main_revision_ "1.1.0")

set(rel_version_ "unknown")

find_package(Git)
if(GIT_FOUND)
set(tag_ver "v${main_revision_}")
execute_process(
COMMAND ${GIT_EXECUTABLE} describe --tags --long
COMMAND ${GIT_EXECUTABLE} describe --all --match ${tag_ver}
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
OUTPUT_VARIABLE build_version_
OUTPUT_VARIABLE rel_version_
ERROR_QUIET
OUTPUT_STRIP_TRAILING_WHITESPACE
)
if("${build_version_}" STREQUAL "")
if("${rel_version_}" STREQUAL "")
execute_process(
COMMAND ${GIT_EXECUTABLE} rev-parse --short HEAD
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
OUTPUT_VARIABLE build_version_
OUTPUT_VARIABLE rel_version_
ERROR_QUIET
OUTPUT_STRIP_TRAILING_WHITESPACE
)
endif()
else()
message(STATUS "Git not found!")
endif()

set(build_version_ "${main_revision_} ${rel_version_}")
message(STATUS "Build version: ${build_version_}")

set(build_type_ ${CMAKE_BUILD_TYPE})
Expand Down

0 comments on commit 41c8d22

Please sign in to comment.