Skip to content

Commit

Permalink
Merge pull request #52 from mpeg5/dev-Versioning
Browse files Browse the repository at this point in the history
Added to CMakeLists.txt reading from file and parsing xeve version st…
  • Loading branch information
mpeg5 authored May 22, 2022
2 parents 4b17da9 + 81c0b71 commit 7a57f0f
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 3 deletions.
27 changes: 26 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,30 @@
cmake_minimum_required (VERSION 3.12)

function(get_versions versionstring VERSION_MAJOR VERSION_MINOR VERSION_PATCH)
string(REGEX REPLACE "^([vV])([0-9]*)([.][0-9]*[.][0-9]*-?.*)$" "\\2" numbers ${versionstring} )
set(VERSION_MAJOR ${numbers} PARENT_SCOPE)
string(REGEX REPLACE "^([vV][0-9]*[.])([0-9]*)([.][0-9]*-?.*)$" "\\2" numbers ${versionstring} )
set(VERSION_MINOR ${numbers} PARENT_SCOPE)
string(REGEX REPLACE "^([vV][0-9]*[.][0-9]*[.])([0-9]*)(-?.*)$" "\\2" numbers ${versionstring} )
set(VERSION_PATCH ${numbers} PARENT_SCOPE)
endfunction()

if(NOT EXISTS "${CMAKE_SOURCE_DIR}/version.txt")
message(FATAL_ERROR "version.txt file does not exist")
endif()

file(STRINGS "version.txt" VERSION_STRING)

if(NOT ${VERSION_STRING} MATCHES "^[vV][0-9]*[.][0-9]*[.][0-9]*$")
message(FATAL_ERROR "Version string taken from version.txt doesn't match required format v[VERSION_MAJOR].[VERSION_MINOR].[VERSION_PATCH]")
endif()

get_versions(${VERSION_STRING} VERSION_MAJOR VERSION_MINOR VERSION_PATCH)
if(VERSION_MAJOR STREQUAL ${VERSION_STRING})
message(FATAL_ERROR "Version string parsing error")
endif()
message("XEVE VERSION=${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}")

# Check input arguments.
if(NOT SET_PROF)
set(SET_PROF "MAIN")
Expand Down Expand Up @@ -28,7 +53,7 @@ cmake_policy(SET CMP0048 NEW)
set(CMAKE_C_STANDARD 99)

# Maps to a solution file (XEVE.sln).
project (XEVE VERSION 1.0.0)
project (XEVE VERSION ${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH})
set_property(GLOBAL PROPERTY USE_FOLDERS ON)

# Set compiler flags and options.
Expand Down
2 changes: 1 addition & 1 deletion src_base/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
set( LIB_NAME_BASE xeveb )

set( LIB_SOVERSION 1)
set( LIB_SOVERSION ${VERSION_MAJOR})

file (GLOB XEVE_INC "../inc/*.h")
file (GLOB LIB_API_SRC "xeve.c")
Expand Down
2 changes: 1 addition & 1 deletion src_main/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# For shared libraries VERSION and SOVERSION can be used to specify the build version and API version respectively
# see https://cmake.org/cmake/help/latest/prop_tgt/SOVERSION.html
#
set( LIB_SOVERSION 1)
set( LIB_SOVERSION ${VERSION_MAJOR})

file (GLOB ETM_INC "../inc/*.h")
file (GLOB LIB_BASE_SRC "../src_base/xeve_*.c")
Expand Down
1 change: 1 addition & 0 deletions version.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
v1.0.0

0 comments on commit 7a57f0f

Please sign in to comment.