Skip to content
This repository has been archived by the owner on Apr 25, 2024. It is now read-only.

Commit

Permalink
Change version name behaivour
Browse files Browse the repository at this point in the history
If we are on the master branch and the tip is being built, we name the
package version HEAD to align with the package naming we used to use.

Other wise use the git describe output.
  • Loading branch information
nickoe committed Jul 5, 2018
1 parent 5742374 commit e1daa10
Showing 1 changed file with 4 additions and 15 deletions.
19 changes: 4 additions & 15 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -95,30 +95,19 @@ if( GIT_FOUND )
ERROR_VARIABLE git_branch_error
OUTPUT_STRIP_TRAILING_WHITESPACE )

message (STATUS "On branch ${git_branch_output} with tag ${git_tags_output}" )
# Due to how tags work in Git it's necessary for us to ensure a few things. For a start, if we
# create a new branch, switch to it and create a tag, that tag becomes visible in the master
# branch. Make sure if we're on the master branch that we use that in the
if( "${git_branch_output}" STREQUAL "master" )
# TODO: Should we include a 6-digit hash here too?
set( CPACK_PACKAGE_VERSION "master" )
set( CPACK_PACKAGE_VERSION "HEAD" )
else()
if( NOT "${git_tags_output}" STREQUAL "" )
# Make sure the tag is associated with the current branch. Otherwise we'll use the branch
# name instead. The tag and branch schema means we need branches in the format 1.0, 2.0,
# etc. and tags in the format 1.0.1, 2.0.1, etc. to match

string( SUBSTRING "${git_tags_output}" 0 3 GIT_TAG )

if( "${GIT_TAG}" STREQUAL "${git_branch_output}" )
# The tag matches the branch so use the tag as the package version
set( CPACK_PACKAGE_VERSION ${git_tags_output} )
else()
# Tag didn't match so assume it's there in error and use the more generic branch
# name as the package version instead
set( CPACK_PACKAGE_VERSION ${git_branch_output} )
endif()
set( CPACK_PACKAGE_VERSION ${git_tags_output} )
endif()
endif()
message (STATUS "Setting package version to ${CPACK_PACKAGE_VERSION}")
endif()

# Everything without leading / is relative to CMAKE_INSTALL_PREFIX.
Expand Down

0 comments on commit e1daa10

Please sign in to comment.