Skip to content

Commit

Permalink
Fix version.cmake when there is no tag
Browse files Browse the repository at this point in the history
  • Loading branch information
TheWillard committed Mar 29, 2021
1 parent 9fb7c64 commit 67693b3
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions cmake/version.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,21 @@ else()
endif()
message("Tag: ${VERSION_TAG}")
message("Build: ${VERSION_BUILD}")
message("")
string(REPLACE "." ";" GIT_VERSION_LIST ${VERSION_TAG})
list(GET GIT_VERSION_LIST 0 VERSION_MAJOR)
list(GET GIT_VERSION_LIST 1 VERSION_MINOR)
list(GET GIT_VERSION_LIST 2 VERSION_PATCH)

list(LENGTH GIT_VERSION_LIST GIT_VERSION_LIST_LENGTH)

if(GIT_VERSION_LIST_LENGTH EQUAL 3)
list(GET GIT_VERSION_LIST 0 VERSION_MAJOR)
list(GET GIT_VERSION_LIST 1 VERSION_MINOR)
list(GET GIT_VERSION_LIST 2 VERSION_PATCH)
else()
set(VERSION_MAJOR 0)
set(VERSION_MINOR 0)
set(VERSION_PATCH 0)
endif()
message("Version: ${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}")
message("")
endif()

set(VERSION "#define MAJOR ${VERSION_MAJOR}
Expand Down

0 comments on commit 67693b3

Please sign in to comment.