Commit 46486381 authored by Rafael Kitover's avatar Rafael Kitover
Browse files

read version info from CHANGELOG.md if no git

If git tags are not available, set the version and revision by finding
the first version tag in `CHANGELOG.md` of the form

```
```

Where N.N.N is the number version (number of components can vary) and
the revision (as speicified by -REV) is optional.

TODO: support named revision without a version number of the form
`[REV]`.
parent 30b6ecf1
......@@ -112,15 +112,12 @@ if(GIT_FOUND AND EXISTS "${CMAKE_SOURCE_DIR}/.git")
# of files that depend on version.h
include(GetGitRevisionDescription)
get_git_head_revision(REFSPEC COMMITHASH)
else()
message(WARNING "Git not found, cannot set version info")
endif()
# no git or no tags
# no git or no tags, use ChangeLog
if(NOT VERSION)
set(VERSION 2.0.0)
set(REVISION "unknown")
set(VERSION_RELEASE 0)
include(ChangeLogVersion)
changelog_version(VERSION REVISION VERSION_RELEASE)
endif()
# generate version.h
......
function(changelog_version version revision version_release)
set(${version} "" CACHE STRING "Latest ChangeLog Version" FORCE)
set(${revision} "" CACHE STRING "Latest ChangeLog Revision" FORCE)
set(${version_release} 0 CACHE STRING "Is this a versioned release without revision" FORCE)
file(READ CHANGELOG.md changelog_file)
if(NOT changelog_file)
return()
endif()
string(REGEX MATCH "\n## +\\[([0-9.]+)(-([^] ]+))?\\] +- +[0-9][0-9]?/" match_out "${changelog_file}")
set(changelog_version "${CMAKE_MATCH_1}")
set(is_version_release 0)
set(changelog_revision "${CMAKE_MATCH_3}")
if(NOT changelog_revision)
set(is_version_release 1)
endif()
set(${version} "${changelog_version}" CACHE STRING "Latest ChangeLog Version" FORCE)
set(${revision} "${changelog_revision}" CACHE STRING "Latest ChangeLog Revision" FORCE)
set(${version_release} "${is_version_release}" CACHE STRING "Is this a versioned release without revision" FORCE)
endfunction()
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment