Skip to content

Commit 7a57f0f

Browse files
authored
Merge pull request #52 from mpeg5/dev-Versioning
Added to CMakeLists.txt reading from file and parsing xeve version st…
2 parents 4b17da9 + 81c0b71 commit 7a57f0f

File tree

4 files changed

+29
-3
lines changed

4 files changed

+29
-3
lines changed

CMakeLists.txt

+26-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,30 @@
11
cmake_minimum_required (VERSION 3.12)
22

3+
function(get_versions versionstring VERSION_MAJOR VERSION_MINOR VERSION_PATCH)
4+
string(REGEX REPLACE "^([vV])([0-9]*)([.][0-9]*[.][0-9]*-?.*)$" "\\2" numbers ${versionstring} )
5+
set(VERSION_MAJOR ${numbers} PARENT_SCOPE)
6+
string(REGEX REPLACE "^([vV][0-9]*[.])([0-9]*)([.][0-9]*-?.*)$" "\\2" numbers ${versionstring} )
7+
set(VERSION_MINOR ${numbers} PARENT_SCOPE)
8+
string(REGEX REPLACE "^([vV][0-9]*[.][0-9]*[.])([0-9]*)(-?.*)$" "\\2" numbers ${versionstring} )
9+
set(VERSION_PATCH ${numbers} PARENT_SCOPE)
10+
endfunction()
11+
12+
if(NOT EXISTS "${CMAKE_SOURCE_DIR}/version.txt")
13+
message(FATAL_ERROR "version.txt file does not exist")
14+
endif()
15+
16+
file(STRINGS "version.txt" VERSION_STRING)
17+
18+
if(NOT ${VERSION_STRING} MATCHES "^[vV][0-9]*[.][0-9]*[.][0-9]*$")
19+
message(FATAL_ERROR "Version string taken from version.txt doesn't match required format v[VERSION_MAJOR].[VERSION_MINOR].[VERSION_PATCH]")
20+
endif()
21+
22+
get_versions(${VERSION_STRING} VERSION_MAJOR VERSION_MINOR VERSION_PATCH)
23+
if(VERSION_MAJOR STREQUAL ${VERSION_STRING})
24+
message(FATAL_ERROR "Version string parsing error")
25+
endif()
26+
message("XEVE VERSION=${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}")
27+
328
# Check input arguments.
429
if(NOT SET_PROF)
530
set(SET_PROF "MAIN")
@@ -28,7 +53,7 @@ cmake_policy(SET CMP0048 NEW)
2853
set(CMAKE_C_STANDARD 99)
2954

3055
# Maps to a solution file (XEVE.sln).
31-
project (XEVE VERSION 1.0.0)
56+
project (XEVE VERSION ${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH})
3257
set_property(GLOBAL PROPERTY USE_FOLDERS ON)
3358

3459
# Set compiler flags and options.

src_base/CMakeLists.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
set( LIB_NAME_BASE xeveb )
22

3-
set( LIB_SOVERSION 1)
3+
set( LIB_SOVERSION ${VERSION_MAJOR})
44

55
file (GLOB XEVE_INC "../inc/*.h")
66
file (GLOB LIB_API_SRC "xeve.c")

src_main/CMakeLists.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
# For shared libraries VERSION and SOVERSION can be used to specify the build version and API version respectively
44
# see https://cmake.org/cmake/help/latest/prop_tgt/SOVERSION.html
55
#
6-
set( LIB_SOVERSION 1)
6+
set( LIB_SOVERSION ${VERSION_MAJOR})
77

88
file (GLOB ETM_INC "../inc/*.h")
99
file (GLOB LIB_BASE_SRC "../src_base/xeve_*.c")

version.txt

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
v1.0.0

0 commit comments

Comments
 (0)