Changeset - 28eb5333089b
[Not reviewed]
version
0 1 2
Hasan Yavuz Ă–ZDERYA - 9 years ago 2016-09-27 11:15:23
hy@ozderya.net
draft of a script that extracts version information from source

.hg_archival.txt is added for test purposes, should be removed
3 files changed with 50 insertions and 4 deletions:
0 comments (0 inline, 0 general)
.hg_archival.txt
Show inline comments
 
new file 100644
 
repo: 58db5f6bf2b13824531f84a0e3718f67513a9958
 
node: fd5f1eb480ec372b49df58b497458de05c30057c
 
branch: default
 
latesttag: v0.8.0
 
latesttagdistance: 77
CMakeLists.txt
Show inline comments
 
@@ -145,12 +145,14 @@ else()
 
endif()
 

	
 
# version number
 
set(MAJOR_VERSION 0 CACHE INT "Program major version number.")
 
set(MINOR_VERSION 8 CACHE INT "Program minor version number.")
 
set(PATCH_VERSION 0 CACHE INT "Program patch version number.")
 
# set(MAJOR_VERSION 0 CACHE INT "Program major version number.")
 
# set(MINOR_VERSION 8 CACHE INT "Program minor version number.")
 
# set(PATCH_VERSION 0 CACHE INT "Program patch version number.")
 

	
 
# get version number from mercurial
 
include(version)
 
set(VERSION_STRING "${MAJOR_VERSION}.${MINOR_VERSION}.${PATCH_VERSION}")
 

	
 
# get revision number from mercurial
 
find_program(MERCURIAL hg)
 

	
 
if (MERCURIAL)
cmake/modules/version.cmake
Show inline comments
 
new file 100644
 

	
 
find_program(MERCURIAL hg)
 

	
 
# try hg_archival.txt file
 
if (EXISTS ${CMAKE_SOURCE_DIR}/.hg_archival.txt)
 
  message("Found .hg_archival.txt")
 
  file(STRINGS "${CMAKE_SOURCE_DIR}/.hg_archival.txt" latest_tag_string
 
    REGEX "latesttag:.*")
 
  if (latest_tag_string)
 
    message("Found ${latest_tag_string}")
 
    string(REGEX REPLACE "latesttag:[ \t]*v([0-9.]+).*" "\\1"
 
      found_version_string ${latest_tag_string})
 
    message("Version from latest tag: ${found_version_string}")
 

	
 
    if (found_version_string MATCHES "([0-9]+)[0-9.]*")
 
      set(MAJOR_VERSION ${CMAKE_MATCH_1})
 
    endif()
 

	
 
    if (found_version_string MATCHES "[0-9]+\\.([0-9]+)[0-9.]*")
 
      set(MINOR_VERSION ${CMAKE_MATCH_1})
 
    endif()
 

	
 
    if (found_version_string MATCHES "[0-9]+\\.[0-9]+\\.([0-9]+)")
 
      set(PATCH_VERSION ${CMAKE_MATCH_1})
 
    endif()
 

	
 
    message("found_major_version: ${MAJOR_VERSION}")
 
    message("found_minor_version: ${MINOR_VERSION}")
 
    message("found_patch_version: ${PATCH_VERSION}")
 
  else(latest_tag_string)
 
    message(WARNING "Couldn't find latest tag in .hg_archival.txt.")
 
  endif()
 

	
 
elseif(MERCURIAL)
 

	
 

	
 

	
 
endif()
 

	
0 comments (0 inline, 0 general)