aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJustin M. Keyes <justinkz@gmail.com>2015-12-13 12:29:02 -0500
committerJustin M. Keyes <justinkz@gmail.com>2016-01-08 01:09:22 -0500
commitb4b45363396ed717230a78f8a4968e2dd12c014a (patch)
tree9aa187f2758761cf4eb74475648c2660faa9decf
parent7643245470df5bd828569fe465bb13f0e02c47f2 (diff)
downloadrneovim-b4b45363396ed717230a78f8a4968e2dd12c014a.tar.gz
rneovim-b4b45363396ed717230a78f8a4968e2dd12c014a.tar.bz2
rneovim-b4b45363396ed717230a78f8a4968e2dd12c014a.zip
version: semver.org compliance
We use `git describe` to stamp pre-release versions (dev builds). But `git describe` uses the result of the most-recent tag (the current _release_ version)--so we must munge it with the _next_ (i.e. unreleased) version. Also fix non-git builds: do not invoke git_describe(NVIM_VERSION_MEDIUM) if we're not in a git tree, else it gets the dummy value "HEAD-HASH-NOTFOUND". Example :version output in non-git build: NVIM 0.1.2-dev Example :version output in git build: NVIM v0.1.2-176-g9c3c2b5
-rw-r--r--CMakeLists.txt18
1 files changed, 14 insertions, 4 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 29ef806612..321a919494 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -51,15 +51,25 @@ if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE "Dev" CACHE STRING "Choose the type of build." FORCE)
endif()
-# If not in a git repo (e.g., a tarball) these tokens set the version string,
-# otherwise the result of `git describe` is used.
+# If not in a git repo (e.g., a tarball) these tokens define the complete
+# version string, else it is combined with the result of `git describe`.
set(NVIM_VERSION_MAJOR 0)
set(NVIM_VERSION_MINOR 1)
-set(NVIM_VERSION_PATCH 1)
+set(NVIM_VERSION_PATCH 2)
+set(NVIM_VERSION_PRERELEASE "-dev") # for package maintainers
file(TO_CMAKE_PATH ${CMAKE_CURRENT_LIST_DIR}/.git FORCED_GIT_DIR)
include(GetGitRevisionDescription)
-git_describe(NVIM_VERSION_MEDIUM)
+get_git_head_revision(GIT_REFSPEC NVIM_VERSION_COMMIT)
+if(NVIM_VERSION_COMMIT) # is a git repo
+ git_describe(NVIM_VERSION_MEDIUM)
+ # `git describe` annotates the most recent tagged release; for pre-release
+ # builds we must replace that with the unreleased version.
+ string(REGEX REPLACE "^v[0-9]+\\.[0-9]+\\.[0-9]+"
+ "v${NVIM_VERSION_MAJOR}.${NVIM_VERSION_MINOR}.${NVIM_VERSION_PATCH}"
+ NVIM_VERSION_MEDIUM
+ ${NVIM_VERSION_MEDIUM})
+endif()
set(NVIM_VERSION_BUILD_TYPE "${CMAKE_BUILD_TYPE}")
# NVIM_VERSION_CFLAGS set further below.