From b62e5f4b8df0715f5caee2b38589ce2c1f0a91b6 Mon Sep 17 00:00:00 2001
From: Jan Travnicek <Jan.Travnicek@fit.cvut.cz>
Date: Tue, 13 Nov 2018 16:21:28 +0100
Subject: [PATCH] allow version specification via config + retrieve git version
 and commit hash in cmake

---
 CMake/CMakeLists_lib.txt                   |  3 ++
 CMake/CMakeLists_root.txt                  | 41 ++++++++++++++++++++--
 CMake/config.ini                           |  5 +++
 CMake/generate.py                          |  3 ++
 aaccess2/src/aaccess.cpp                   |  4 ++-
 aarbology2/src/aarbology.cpp               |  4 ++-
 acast2/src/acast.cpp                       |  4 ++-
 acompaction2/src/acompaction.cpp           |  4 ++-
 acompare2/src/acompare.cpp                 |  4 ++-
 aconversions2/src/aconversion.cpp          |  4 ++-
 aconvert2/src/aconvert.cpp                 |  4 ++-
 aderivation2/src/aderivation.cpp           |  4 ++-
 adeterminize2/src/adeterminize.cpp         |  4 ++-
 aecho2/src/aecho.cpp                       |  4 ++-
 aepsilon2/src/aepsilon.cpp                 |  4 ++-
 agenerate2/src/agenerate.cpp               |  4 ++-
 agui2/src/main.cpp                         |  2 ++
 aintegral2/src/aintegral.cpp               |  4 ++-
 aintrospection2/src/aintrospection.cpp     |  4 ++-
 alangop2/src/alangop.cpp                   |  4 ++-
 alib2abstraction/test-src/main.cpp         |  4 ++-
 alib2algo/test-src/main.cpp                |  4 ++-
 alib2algo_experimental/test-src/main.cpp   |  4 ++-
 alib2aux/test-src/main.cpp                 |  4 ++-
 alib2cli/test-src/main.cpp                 |  4 ++-
 alib2common/test-src/main.cpp              |  4 ++-
 alib2data/test-src/main.cpp                |  4 ++-
 alib2data_experimental/test-src/main.cpp   |  4 ++-
 alib2dummy/test-src/main.cpp               |  4 ++-
 alib2elgo/test-src/main.cpp                |  4 ++-
 alib2graph_algo/test-src/main.cpp          |  4 ++-
 alib2graph_data/test-src/main.cpp          |  4 ++-
 alib2gui/test-src/main.cpp                 |  4 ++-
 alib2measure/test-src/main.cpp             |  4 ++-
 alib2raw/test-src/main.cpp                 |  4 ++-
 alib2raw_cli_integration/test-src/main.cpp |  4 ++-
 alib2std/test-src/main.cpp                 |  4 ++-
 alib2str/test-src/main.cpp                 |  4 ++-
 alib2str_cli_integration/test-src/main.cpp |  4 ++-
 alib2xml/test-src/main.cpp                 |  4 ++-
 aminimize2/src/aminimize.cpp               |  4 ++-
 anormalize2/src/anormalize.cpp             |  4 ++-
 aql2/src/aql.cpp                           |  4 ++-
 aquery2/src/aquery.cpp                     |  4 ++-
 arand2/src/arand.cpp                       |  4 ++-
 araw2/src/araw.cpp                         |  4 ++-
 arename2/src/arename.cpp                   |  4 ++-
 areverse2/src/areverse.cpp                 |  4 ++-
 arun2/src/arun.cpp                         |  4 ++-
 astat2/src/astat.cpp                       |  4 ++-
 astringology2/src/astringology.cpp         |  4 ++-
 atrim2/src/atrim.cpp                       |  4 ++-
 include/version.hpp                        | 25 +++++++++++++
 tniceprint/src/tniceprint.cpp              |  4 ++-
 54 files changed, 220 insertions(+), 51 deletions(-)
 create mode 100644 include/version.hpp

diff --git a/CMake/CMakeLists_lib.txt b/CMake/CMakeLists_lib.txt
index af1942d543..502d81f7cd 100644
--- a/CMake/CMakeLists_lib.txt
+++ b/CMake/CMakeLists_lib.txt
@@ -26,6 +26,9 @@ set_target_properties(${{PROJECT_NAME}} PROPERTIES
         LINKER_LANGUAGE CXX
 
         INTERFACE_POSITION_INDEPENDENT_CODE ON
+
+        VERSION ${{ALIB_VERSION}}
+        SOVERSION ${{ALIB_VERSION_MAJOR}}
         )
 
 # if (CMAKE_BUILD_TYPE STREQUAL "Release")
diff --git a/CMake/CMakeLists_root.txt b/CMake/CMakeLists_root.txt
index 660769cdc8..2c24be81fe 100644
--- a/CMake/CMakeLists_root.txt
+++ b/CMake/CMakeLists_root.txt
@@ -15,12 +15,46 @@ endif ()
 
 #################
 # ALIB Versioning
-set(ALIB_VERSION_MAJOR 2)
-set(ALIB_VERSION_MINOR 0)
-set(ALIB_VERSION_PATCH 0)
+set(ALIB_VERSION_MAJOR {alib_versioning_major})
+set(ALIB_VERSION_MINOR {alib_versioning_minor})
+set(ALIB_VERSION_PATCH {alib_versioning_patch})
 set(ALIB_VERSION ${{ALIB_VERSION_MAJOR}}.${{ALIB_VERSION_MINOR}}.${{ALIB_VERSION_PATCH}})
 mark_as_advanced(ALIB_VERSION)
 
+add_definitions ( -DALIB_VERSION_MAJOR=${{ALIB_VERSION_MAJOR}} -DALIB_VERSION_MINOR=${{ALIB_VERSION_MINOR}} -DALIB_VERSION_PATCH=${{ALIB_VERSION_PATCH}} -DALIB_VERSION=${{ALIB_VERSION}} )
+
+# Get the current working commit hash
+execute_process (
+  COMMAND git rev-parse HEAD
+  WORKING_DIRECTORY ${{CMAKE_SOURCE_DIR}}
+  OUTPUT_VARIABLE ALIB_GIT_COMMIT_HASH
+  RESULT_VARIABLE RET_CODE
+  OUTPUT_STRIP_TRAILING_WHITESPACE
+)
+
+if("${{RET_CODE}}" STREQUAL "0")
+  add_definitions ( -DALIB_GIT_COMMIT_HASH=${{ALIB_GIT_COMMIT_HASH}} )
+  message ( Git commit hash ${{ALIB_GIT_COMMIT_HASH}} )
+else()
+  message ( Git commit hash not found )
+endif()
+
+# Get the current working branch
+execute_process (
+  COMMAND git rev-parse --abbrev-ref HEAD
+  WORKING_DIRECTORY ${{CMAKE_SOURCE_DIR}}
+  OUTPUT_VARIABLE ALIB_GIT_BRANCH
+  RESULT_VARIABLE RET_CODE
+  OUTPUT_STRIP_TRAILING_WHITESPACE
+)
+
+if("${{RET_CODE}}" STREQUAL "0")
+  add_definitions ( -DALIB_GIT_BRANCH=${{ALIB_GIT_BRANCH}} )
+  message ( Git branch ${{ALIB_GIT_BRANCH}} )
+else()
+  message ( Git branch not found )
+endif()
+
 ######################
 # Some Makefile tuning
 set(CMAKE_COLOR_MAKEFILE ON)
@@ -97,6 +131,7 @@ if (ALIB_NOGUI)
     list (REMOVE_ITEM ALIB_MODULES_EXE "agui2")
 endif ()
 
+include_directories ( include )
 
 ##################
 # Register modules
diff --git a/CMake/config.ini b/CMake/config.ini
index 4d15d9b95d..4e9fd5c589 100644
--- a/CMake/config.ini
+++ b/CMake/config.ini
@@ -1,3 +1,8 @@
+[Versioning]
+major = 0
+minor = 0
+patch = 1
+
 [Templates]
 root = CMakeLists_root.txt
 lib  = CMakeLists_lib.txt
diff --git a/CMake/generate.py b/CMake/generate.py
index 6ec1dd7933..e250be7063 100755
--- a/CMake/generate.py
+++ b/CMake/generate.py
@@ -140,6 +140,9 @@ def create_root_cmakelist(dry_run, packages):
         f.write(TEMPLATES['root'].format(
             alib_modules_lib=to_rows(packages['library']),
             alib_modules_exe=to_rows(packages['executable']),
+            alib_versioning_major=config['Versioning']['major'],
+            alib_versioning_minor=config['Versioning']['minor'],
+            alib_versioning_patch=config['Versioning']['patch'],
         ))
 
         if dry_run:
diff --git a/aaccess2/src/aaccess.cpp b/aaccess2/src/aaccess.cpp
index 2b576979f0..ecd8dbaf5b 100644
--- a/aaccess2/src/aaccess.cpp
+++ b/aaccess2/src/aaccess.cpp
@@ -5,6 +5,8 @@
  *	  Author: Jan Travnicek
  */
 
+#include <version.hpp>
+
 #include <tclap/CmdLine.h>
 #include <global/GlobalData.h>
 #include <measure>
@@ -32,7 +34,7 @@ int main ( int argc, char * argv[] ) {
 		common::GlobalData::argc = argc;
 		common::GlobalData::argv = argv;
 
-		TCLAP::CmdLine cmd ( "Access internals of automata, grammars, regexps, ...", ' ', "0.01" );
+		TCLAP::CmdLine cmd ( "Access internals of automata, grammars, regexps, ...", ' ', ALIB_VERSION_STRING );
 
 		// ----------------------------------------------------------------------------------------------------------------------------------------------------------------------
 		std::vector < std::string > automatonSettings {
diff --git a/aarbology2/src/aarbology.cpp b/aarbology2/src/aarbology.cpp
index 8b8fc80a88..e33a99c92e 100644
--- a/aarbology2/src/aarbology.cpp
+++ b/aarbology2/src/aarbology.cpp
@@ -5,6 +5,8 @@
  *	  Author: Jan Travnicek
  */
 
+#include <version.hpp>
+
 #include <tclap/CmdLine.h>
 #include <global/GlobalData.h>
 #include <measure>
@@ -20,7 +22,7 @@ int main ( int argc, char * argv[] ) {
 		common::GlobalData::argc = argc;
 		common::GlobalData::argv = argv;
 
-		TCLAP::CmdLine cmd ( "Arbology algorithm access binary", ' ', "0.01" );
+		TCLAP::CmdLine cmd ( "Arbology algorithm access binary", ' ', ALIB_VERSION_STRING );
 
 		std::vector < std::string > allowed;
 		allowed.push_back ( "exactSubtreeMatch" );
diff --git a/acast2/src/acast.cpp b/acast2/src/acast.cpp
index a9fa297ce9..e801612116 100644
--- a/acast2/src/acast.cpp
+++ b/acast2/src/acast.cpp
@@ -5,6 +5,8 @@
  *      Author: Jan Travnicek
  */
 
+#include <version.hpp>
+
 #include <tclap/CmdLine.h>
 #include <global/GlobalData.h>
 #include <measure>
@@ -22,7 +24,7 @@ int main(int argc, char** argv) {
 		common::GlobalData::argc = argc;
 		common::GlobalData::argv = argv;
 
-		TCLAP::CmdLine cmd("cast binary", ' ', "0.01");
+		TCLAP::CmdLine cmd("cast binary", ' ', ALIB_VERSION_STRING);
 
 		TCLAP::ValueArg<std::string> input(	"i",	"input",	"Input to cast",	false,	"-",		"file");
 		cmd.add( input );
diff --git a/acompaction2/src/acompaction.cpp b/acompaction2/src/acompaction.cpp
index 9d8eb65ad2..f77ee7dca7 100644
--- a/acompaction2/src/acompaction.cpp
+++ b/acompaction2/src/acompaction.cpp
@@ -5,6 +5,8 @@
  *      Author: Tomas Pecka
  */
 
+#include <version.hpp>
+
 #include <tclap/CmdLine.h>
 #include <global/GlobalData.h>
 #include <measure>
@@ -20,7 +22,7 @@ int main(int argc, char** argv) {
 		common::GlobalData::argc = argc;
 		common::GlobalData::argv = argv;
 
-		TCLAP::CmdLine cmd("Automaton compaction binary", ' ', "0.01");
+		TCLAP::CmdLine cmd("Automaton compaction binary", ' ', ALIB_VERSION_STRING);
 
 		TCLAP::ValueArg<std::string> input(	"i",	"input",	"Automaton to compactify",		false,	"-",		"file");
 		cmd.add( input );
diff --git a/acompare2/src/acompare.cpp b/acompare2/src/acompare.cpp
index 4f91a71711..ae88ea8fb5 100644
--- a/acompare2/src/acompare.cpp
+++ b/acompare2/src/acompare.cpp
@@ -5,6 +5,8 @@
  *      Author: Jan Travnicek
  */
 
+#include <version.hpp>
+
 #include <tclap/CmdLine.h>
 #include <global/GlobalData.h>
 #include <measure>
@@ -21,7 +23,7 @@ int main ( int argc, char * * argv ) {
 		common::GlobalData::argc = argc;
 		common::GlobalData::argv = argv;
 
-		TCLAP::CmdLine cmd ( "Regexp derivative compute binary", ' ', "0.01" );
+		TCLAP::CmdLine cmd ( "Regexp derivative compute binary", ' ', ALIB_VERSION_STRING );
 
 		TCLAP::UnlabeledValueArg < std::string > input1 ( "input1", "The first input to compare", true, "-", "file" );
 		cmd.add ( input1 );
diff --git a/aconversions2/src/aconversion.cpp b/aconversions2/src/aconversion.cpp
index ba1feba4d1..16831c20fa 100644
--- a/aconversions2/src/aconversion.cpp
+++ b/aconversions2/src/aconversion.cpp
@@ -5,6 +5,8 @@
  *	  Author: Tomas Pecka
  */
 
+#include <version.hpp>
+
 #include <tclap/CmdLine.h>
 #include <global/GlobalData.h>
 #include <measure>
@@ -22,7 +24,7 @@ int main ( int argc, char * argv[] ) {
 		common::GlobalData::argc = argc;
 		common::GlobalData::argv = argv;
 
-		TCLAP::CmdLine cmd ( "Converts between regular expressions, regular grammars and finite automaton.", ' ', "0.01" );
+		TCLAP::CmdLine cmd ( "Converts between regular expressions, regular grammars and finite automaton.", ' ', ALIB_VERSION_STRING );
 
 		std::vector < std::string > formalisms {
 			"fa", "re", "rg", "pda"
diff --git a/aconvert2/src/aconvert.cpp b/aconvert2/src/aconvert.cpp
index 6275a5ae1d..18e516a2ca 100644
--- a/aconvert2/src/aconvert.cpp
+++ b/aconvert2/src/aconvert.cpp
@@ -5,6 +5,8 @@
  *	  Author: Martin Zak
  */
 
+#include <version.hpp>
+
 #include <tclap/CmdLine.h>
 #include <global/GlobalData.h>
 #include <measure>
@@ -20,7 +22,7 @@ int main ( int argc, char * argv[] ) {
 		common::GlobalData::argc = argc;
 		common::GlobalData::argv = argv;
 
-		TCLAP::CmdLine cmd ( "Convert binary", ' ', "0.01" );
+		TCLAP::CmdLine cmd ( "Convert binary", ' ', ALIB_VERSION_STRING );
 
 		TCLAP::SwitchArg automaton_from_string ( "", "automaton_from_string", "Convert automaton from string representation" );
 		cmd.add ( automaton_from_string );
diff --git a/aderivation2/src/aderivation.cpp b/aderivation2/src/aderivation.cpp
index cafb232eac..96f428e291 100644
--- a/aderivation2/src/aderivation.cpp
+++ b/aderivation2/src/aderivation.cpp
@@ -5,6 +5,8 @@
  *      Author: Tomas Pecka
  */
 
+#include <version.hpp>
+
 #include <tclap/CmdLine.h>
 #include <global/GlobalData.h>
 #include <measure>
@@ -20,7 +22,7 @@ int main(int argc, char** argv) {
 		common::GlobalData::argc = argc;
 		common::GlobalData::argv = argv;
 
-		TCLAP::CmdLine cmd("Regexp derivative compute binary", ' ', "0.01");
+		TCLAP::CmdLine cmd("Regexp derivative compute binary", ' ', ALIB_VERSION_STRING);
 		TCLAP::ValueArg<std::string> string(	"s",	"string",	"String to derivate by",	false,	"-",		"file");
 		cmd.add( string );
 
diff --git a/adeterminize2/src/adeterminize.cpp b/adeterminize2/src/adeterminize.cpp
index 221051774e..55b2fcd3fa 100644
--- a/adeterminize2/src/adeterminize.cpp
+++ b/adeterminize2/src/adeterminize.cpp
@@ -5,6 +5,8 @@
  *	  Author: Tomas Pecka
  */
 
+#include <version.hpp>
+
 #include <tclap/CmdLine.h>
 #include <global/GlobalData.h>
 #include <measure>
@@ -20,7 +22,7 @@ int main ( int argc, char * * argv ) {
 		common::GlobalData::argc = argc;
 		common::GlobalData::argv = argv;
 
-		TCLAP::CmdLine cmd ( "Automaton determinize binary", ' ', "0.01" );
+		TCLAP::CmdLine cmd ( "Automaton determinize binary", ' ', ALIB_VERSION_STRING );
 
 		TCLAP::ValueArg < std::string > input (	"i",	"input",	"Automaton to determinize",	false,	"-",	"file" );
 		cmd.add ( input );
diff --git a/aecho2/src/aecho.cpp b/aecho2/src/aecho.cpp
index d19b65620f..9103f37c2d 100644
--- a/aecho2/src/aecho.cpp
+++ b/aecho2/src/aecho.cpp
@@ -5,6 +5,8 @@
  *      Author: Martin Zak
  */
 
+#include <version.hpp>
+
 #include <tclap/CmdLine.h>
 #include <global/GlobalData.h>
 #include <measure>
@@ -20,7 +22,7 @@ int main(int argc, char** argv) {
 		common::GlobalData::argc = argc;
 		common::GlobalData::argv = argv;
 
-		TCLAP::CmdLine cmd("echo binary", ' ', "0.01");
+		TCLAP::CmdLine cmd("echo binary", ' ', ALIB_VERSION_STRING);
 
 		TCLAP::ValueArg<std::string> input(	"i",	"input",	"Input to echo",		false,	"-",		"file");
 		cmd.add( input );
diff --git a/aepsilon2/src/aepsilon.cpp b/aepsilon2/src/aepsilon.cpp
index 849e8ce845..ea0b74ab3f 100644
--- a/aepsilon2/src/aepsilon.cpp
+++ b/aepsilon2/src/aepsilon.cpp
@@ -5,6 +5,8 @@
  *      Author: Jan Travnicek
  */
 
+#include <version.hpp>
+
 #include <tclap/CmdLine.h>
 #include <global/GlobalData.h>
 #include <measure>
@@ -20,7 +22,7 @@ int main(int argc, char** argv) {
 		common::GlobalData::argc = argc;
 		common::GlobalData::argv = argv;
 
-		TCLAP::CmdLine cmd("Automaton rename binary", ' ', "0.01");
+		TCLAP::CmdLine cmd("Automaton rename binary", ' ', ALIB_VERSION_STRING);
 
 		TCLAP::ValueArg<std::string> input(	"i",	"input",	"Automaton/Grammar where to remove epsilon transitions",		false,	"-",		"file");
 		cmd.add( input );
diff --git a/agenerate2/src/agenerate.cpp b/agenerate2/src/agenerate.cpp
index 8be59eae24..08b9ae0274 100644
--- a/agenerate2/src/agenerate.cpp
+++ b/agenerate2/src/agenerate.cpp
@@ -5,6 +5,8 @@
  *	  Author: Jan Travnicek
  */
 
+#include <version.hpp>
+
 #include <tclap/CmdLine.h>
 #include <global/GlobalData.h>
 #include <measure>
@@ -20,7 +22,7 @@ int main ( int argc, char * argv[] ) {
 		common::GlobalData::argc = argc;
 		common::GlobalData::argv = argv;
 
-		TCLAP::CmdLine cmd ( "String generate from grammar", ' ', "0.01" );
+		TCLAP::CmdLine cmd ( "String generate from grammar", ' ', ALIB_VERSION_STRING );
 
 		std::vector < std::string > allowed;
 		allowed.push_back ( "upTo" );
diff --git a/agui2/src/main.cpp b/agui2/src/main.cpp
index b2ef847dbb..31d3ab2f6e 100644
--- a/agui2/src/main.cpp
+++ b/agui2/src/main.cpp
@@ -2,6 +2,8 @@
 
 #include <MainWindow.hpp>
 
+#include <version.hpp>
+
 int main(int argc, char *argv[])
 {
     QApplication a(argc, argv);
diff --git a/aintegral2/src/aintegral.cpp b/aintegral2/src/aintegral.cpp
index 9ebd428809..93a736ac0d 100644
--- a/aintegral2/src/aintegral.cpp
+++ b/aintegral2/src/aintegral.cpp
@@ -5,6 +5,8 @@
  *      Author: Tomas Pecka
  */
 
+#include <version.hpp>
+
 #include <tclap/CmdLine.h>
 #include <global/GlobalData.h>
 #include <measure>
@@ -20,7 +22,7 @@ int main(int argc, char** argv) {
 		common::GlobalData::argc = argc;
 		common::GlobalData::argv = argv;
 
-		TCLAP::CmdLine cmd("Regexp derivative compute binary", ' ', "0.01");
+		TCLAP::CmdLine cmd("Regexp derivative compute binary", ' ', ALIB_VERSION_STRING);
 		TCLAP::ValueArg<std::string> string(	"s",	"string",	"String to integrate by",	false,	"-",		"file");
 		cmd.add( string );
 
diff --git a/aintrospection2/src/aintrospection.cpp b/aintrospection2/src/aintrospection.cpp
index b84e9f41c6..a44aca0131 100644
--- a/aintrospection2/src/aintrospection.cpp
+++ b/aintrospection2/src/aintrospection.cpp
@@ -5,6 +5,8 @@
  *	  Author: Martin Zak
  */
 
+#include <version.hpp>
+
 #include <tclap/CmdLine.h>
 #include <global/GlobalData.h>
 #include <measure>
@@ -20,7 +22,7 @@ int main ( int argc, char * argv[] ) {
 		common::GlobalData::argc = argc;
 		common::GlobalData::argv = argv;
 
-		TCLAP::CmdLine cmd ( "Introspection binary", ' ', "0.01" );
+		TCLAP::CmdLine cmd ( "Introspection binary", ' ', ALIB_VERSION_STRING );
 
 		TCLAP::SwitchArg dataTypes ( "d", "datatypes", "Data types", false );
 		cmd.add ( dataTypes );
diff --git a/alangop2/src/alangop.cpp b/alangop2/src/alangop.cpp
index 8a4c5476dc..6314f18c0f 100644
--- a/alangop2/src/alangop.cpp
+++ b/alangop2/src/alangop.cpp
@@ -5,6 +5,8 @@
  *	  Author: Tomas Pecka
  */
 
+#include <version.hpp>
+
 #include <tclap/CmdLine.h>
 #include <global/GlobalData.h>
 #include <measure>
@@ -20,7 +22,7 @@ int main(int argc, char* argv[]) {
 		common::GlobalData::argc = argc;
 		common::GlobalData::argv = argv;
 
-		TCLAP::CmdLine cmd("Stringology algorithm access binary", ' ', "0.01");
+		TCLAP::CmdLine cmd("Stringology algorithm access binary", ' ', ALIB_VERSION_STRING);
 
 		std::vector<std::string> allowed;
 		allowed.push_back("unionEpsilon");
diff --git a/alib2abstraction/test-src/main.cpp b/alib2abstraction/test-src/main.cpp
index 0026f79acd..e87a624706 100644
--- a/alib2abstraction/test-src/main.cpp
+++ b/alib2abstraction/test-src/main.cpp
@@ -1,3 +1,5 @@
+#include <version.hpp>
+
 #include <tclap/CmdLine.h>
 
 #include <cppunit/CompilerOutputter.h>
@@ -97,7 +99,7 @@ CPPUNIT_NS_END
 
 int main(int argc, char* argv[]) {
 	try {
-		TCLAP::CmdLine cmd("Main test binary.", ' ', "0.01");
+		TCLAP::CmdLine cmd("Main test binary.", ' ', ALIB_VERSION_STRING);
 
 		TCLAP::MultiArg<std::string> testPathSegments("p", "path", "test path", false, "string" );
 		cmd.add( testPathSegments );
diff --git a/alib2algo/test-src/main.cpp b/alib2algo/test-src/main.cpp
index fd442ebd12..fccf89ba66 100644
--- a/alib2algo/test-src/main.cpp
+++ b/alib2algo/test-src/main.cpp
@@ -1,3 +1,5 @@
+#include <version.hpp>
+
 #include <tclap/CmdLine.h>
 
 #include <cppunit/CompilerOutputter.h>
@@ -97,7 +99,7 @@ CPPUNIT_NS_END
 
 int main(int argc, char* argv[]) {
 	try {
-		TCLAP::CmdLine cmd("Main test binary.", ' ', "0.01");
+		TCLAP::CmdLine cmd("Main test binary.", ' ', ALIB_VERSION_STRING);
 
 		TCLAP::MultiArg<std::string> testPathSegments("p", "path", "test path", false, "string" );
 		cmd.add( testPathSegments );
diff --git a/alib2algo_experimental/test-src/main.cpp b/alib2algo_experimental/test-src/main.cpp
index fd442ebd12..fccf89ba66 100644
--- a/alib2algo_experimental/test-src/main.cpp
+++ b/alib2algo_experimental/test-src/main.cpp
@@ -1,3 +1,5 @@
+#include <version.hpp>
+
 #include <tclap/CmdLine.h>
 
 #include <cppunit/CompilerOutputter.h>
@@ -97,7 +99,7 @@ CPPUNIT_NS_END
 
 int main(int argc, char* argv[]) {
 	try {
-		TCLAP::CmdLine cmd("Main test binary.", ' ', "0.01");
+		TCLAP::CmdLine cmd("Main test binary.", ' ', ALIB_VERSION_STRING);
 
 		TCLAP::MultiArg<std::string> testPathSegments("p", "path", "test path", false, "string" );
 		cmd.add( testPathSegments );
diff --git a/alib2aux/test-src/main.cpp b/alib2aux/test-src/main.cpp
index fd442ebd12..fccf89ba66 100644
--- a/alib2aux/test-src/main.cpp
+++ b/alib2aux/test-src/main.cpp
@@ -1,3 +1,5 @@
+#include <version.hpp>
+
 #include <tclap/CmdLine.h>
 
 #include <cppunit/CompilerOutputter.h>
@@ -97,7 +99,7 @@ CPPUNIT_NS_END
 
 int main(int argc, char* argv[]) {
 	try {
-		TCLAP::CmdLine cmd("Main test binary.", ' ', "0.01");
+		TCLAP::CmdLine cmd("Main test binary.", ' ', ALIB_VERSION_STRING);
 
 		TCLAP::MultiArg<std::string> testPathSegments("p", "path", "test path", false, "string" );
 		cmd.add( testPathSegments );
diff --git a/alib2cli/test-src/main.cpp b/alib2cli/test-src/main.cpp
index fd442ebd12..fccf89ba66 100644
--- a/alib2cli/test-src/main.cpp
+++ b/alib2cli/test-src/main.cpp
@@ -1,3 +1,5 @@
+#include <version.hpp>
+
 #include <tclap/CmdLine.h>
 
 #include <cppunit/CompilerOutputter.h>
@@ -97,7 +99,7 @@ CPPUNIT_NS_END
 
 int main(int argc, char* argv[]) {
 	try {
-		TCLAP::CmdLine cmd("Main test binary.", ' ', "0.01");
+		TCLAP::CmdLine cmd("Main test binary.", ' ', ALIB_VERSION_STRING);
 
 		TCLAP::MultiArg<std::string> testPathSegments("p", "path", "test path", false, "string" );
 		cmd.add( testPathSegments );
diff --git a/alib2common/test-src/main.cpp b/alib2common/test-src/main.cpp
index fd442ebd12..fccf89ba66 100644
--- a/alib2common/test-src/main.cpp
+++ b/alib2common/test-src/main.cpp
@@ -1,3 +1,5 @@
+#include <version.hpp>
+
 #include <tclap/CmdLine.h>
 
 #include <cppunit/CompilerOutputter.h>
@@ -97,7 +99,7 @@ CPPUNIT_NS_END
 
 int main(int argc, char* argv[]) {
 	try {
-		TCLAP::CmdLine cmd("Main test binary.", ' ', "0.01");
+		TCLAP::CmdLine cmd("Main test binary.", ' ', ALIB_VERSION_STRING);
 
 		TCLAP::MultiArg<std::string> testPathSegments("p", "path", "test path", false, "string" );
 		cmd.add( testPathSegments );
diff --git a/alib2data/test-src/main.cpp b/alib2data/test-src/main.cpp
index fd442ebd12..fccf89ba66 100644
--- a/alib2data/test-src/main.cpp
+++ b/alib2data/test-src/main.cpp
@@ -1,3 +1,5 @@
+#include <version.hpp>
+
 #include <tclap/CmdLine.h>
 
 #include <cppunit/CompilerOutputter.h>
@@ -97,7 +99,7 @@ CPPUNIT_NS_END
 
 int main(int argc, char* argv[]) {
 	try {
-		TCLAP::CmdLine cmd("Main test binary.", ' ', "0.01");
+		TCLAP::CmdLine cmd("Main test binary.", ' ', ALIB_VERSION_STRING);
 
 		TCLAP::MultiArg<std::string> testPathSegments("p", "path", "test path", false, "string" );
 		cmd.add( testPathSegments );
diff --git a/alib2data_experimental/test-src/main.cpp b/alib2data_experimental/test-src/main.cpp
index fd442ebd12..fccf89ba66 100644
--- a/alib2data_experimental/test-src/main.cpp
+++ b/alib2data_experimental/test-src/main.cpp
@@ -1,3 +1,5 @@
+#include <version.hpp>
+
 #include <tclap/CmdLine.h>
 
 #include <cppunit/CompilerOutputter.h>
@@ -97,7 +99,7 @@ CPPUNIT_NS_END
 
 int main(int argc, char* argv[]) {
 	try {
-		TCLAP::CmdLine cmd("Main test binary.", ' ', "0.01");
+		TCLAP::CmdLine cmd("Main test binary.", ' ', ALIB_VERSION_STRING);
 
 		TCLAP::MultiArg<std::string> testPathSegments("p", "path", "test path", false, "string" );
 		cmd.add( testPathSegments );
diff --git a/alib2dummy/test-src/main.cpp b/alib2dummy/test-src/main.cpp
index fd442ebd12..fccf89ba66 100644
--- a/alib2dummy/test-src/main.cpp
+++ b/alib2dummy/test-src/main.cpp
@@ -1,3 +1,5 @@
+#include <version.hpp>
+
 #include <tclap/CmdLine.h>
 
 #include <cppunit/CompilerOutputter.h>
@@ -97,7 +99,7 @@ CPPUNIT_NS_END
 
 int main(int argc, char* argv[]) {
 	try {
-		TCLAP::CmdLine cmd("Main test binary.", ' ', "0.01");
+		TCLAP::CmdLine cmd("Main test binary.", ' ', ALIB_VERSION_STRING);
 
 		TCLAP::MultiArg<std::string> testPathSegments("p", "path", "test path", false, "string" );
 		cmd.add( testPathSegments );
diff --git a/alib2elgo/test-src/main.cpp b/alib2elgo/test-src/main.cpp
index fd442ebd12..fccf89ba66 100644
--- a/alib2elgo/test-src/main.cpp
+++ b/alib2elgo/test-src/main.cpp
@@ -1,3 +1,5 @@
+#include <version.hpp>
+
 #include <tclap/CmdLine.h>
 
 #include <cppunit/CompilerOutputter.h>
@@ -97,7 +99,7 @@ CPPUNIT_NS_END
 
 int main(int argc, char* argv[]) {
 	try {
-		TCLAP::CmdLine cmd("Main test binary.", ' ', "0.01");
+		TCLAP::CmdLine cmd("Main test binary.", ' ', ALIB_VERSION_STRING);
 
 		TCLAP::MultiArg<std::string> testPathSegments("p", "path", "test path", false, "string" );
 		cmd.add( testPathSegments );
diff --git a/alib2graph_algo/test-src/main.cpp b/alib2graph_algo/test-src/main.cpp
index 9108274fa4..cdc69e4c14 100644
--- a/alib2graph_algo/test-src/main.cpp
+++ b/alib2graph_algo/test-src/main.cpp
@@ -1,3 +1,5 @@
+#include <version.hpp>
+
 #include <tclap/CmdLine.h>
 
 #include <cppunit/CompilerOutputter.h>
@@ -90,7 +92,7 @@ CPPUNIT_NS_END
 
 int main(int argc, char *argv[]) {
   try {
-    TCLAP::CmdLine cmd("Main test binary.", ' ', "0.01");
+    TCLAP::CmdLine cmd("Main test binary.", ' ', ALIB_VERSION_STRING);
 
     TCLAP::MultiArg<std::string> testPathSegments("p", "path", "test path", false, "string");
     cmd.add(testPathSegments);
diff --git a/alib2graph_data/test-src/main.cpp b/alib2graph_data/test-src/main.cpp
index 9108274fa4..cdc69e4c14 100644
--- a/alib2graph_data/test-src/main.cpp
+++ b/alib2graph_data/test-src/main.cpp
@@ -1,3 +1,5 @@
+#include <version.hpp>
+
 #include <tclap/CmdLine.h>
 
 #include <cppunit/CompilerOutputter.h>
@@ -90,7 +92,7 @@ CPPUNIT_NS_END
 
 int main(int argc, char *argv[]) {
   try {
-    TCLAP::CmdLine cmd("Main test binary.", ' ', "0.01");
+    TCLAP::CmdLine cmd("Main test binary.", ' ', ALIB_VERSION_STRING);
 
     TCLAP::MultiArg<std::string> testPathSegments("p", "path", "test path", false, "string");
     cmd.add(testPathSegments);
diff --git a/alib2gui/test-src/main.cpp b/alib2gui/test-src/main.cpp
index fd442ebd12..fccf89ba66 100644
--- a/alib2gui/test-src/main.cpp
+++ b/alib2gui/test-src/main.cpp
@@ -1,3 +1,5 @@
+#include <version.hpp>
+
 #include <tclap/CmdLine.h>
 
 #include <cppunit/CompilerOutputter.h>
@@ -97,7 +99,7 @@ CPPUNIT_NS_END
 
 int main(int argc, char* argv[]) {
 	try {
-		TCLAP::CmdLine cmd("Main test binary.", ' ', "0.01");
+		TCLAP::CmdLine cmd("Main test binary.", ' ', ALIB_VERSION_STRING);
 
 		TCLAP::MultiArg<std::string> testPathSegments("p", "path", "test path", false, "string" );
 		cmd.add( testPathSegments );
diff --git a/alib2measure/test-src/main.cpp b/alib2measure/test-src/main.cpp
index 0026f79acd..e87a624706 100644
--- a/alib2measure/test-src/main.cpp
+++ b/alib2measure/test-src/main.cpp
@@ -1,3 +1,5 @@
+#include <version.hpp>
+
 #include <tclap/CmdLine.h>
 
 #include <cppunit/CompilerOutputter.h>
@@ -97,7 +99,7 @@ CPPUNIT_NS_END
 
 int main(int argc, char* argv[]) {
 	try {
-		TCLAP::CmdLine cmd("Main test binary.", ' ', "0.01");
+		TCLAP::CmdLine cmd("Main test binary.", ' ', ALIB_VERSION_STRING);
 
 		TCLAP::MultiArg<std::string> testPathSegments("p", "path", "test path", false, "string" );
 		cmd.add( testPathSegments );
diff --git a/alib2raw/test-src/main.cpp b/alib2raw/test-src/main.cpp
index fd442ebd12..fccf89ba66 100644
--- a/alib2raw/test-src/main.cpp
+++ b/alib2raw/test-src/main.cpp
@@ -1,3 +1,5 @@
+#include <version.hpp>
+
 #include <tclap/CmdLine.h>
 
 #include <cppunit/CompilerOutputter.h>
@@ -97,7 +99,7 @@ CPPUNIT_NS_END
 
 int main(int argc, char* argv[]) {
 	try {
-		TCLAP::CmdLine cmd("Main test binary.", ' ', "0.01");
+		TCLAP::CmdLine cmd("Main test binary.", ' ', ALIB_VERSION_STRING);
 
 		TCLAP::MultiArg<std::string> testPathSegments("p", "path", "test path", false, "string" );
 		cmd.add( testPathSegments );
diff --git a/alib2raw_cli_integration/test-src/main.cpp b/alib2raw_cli_integration/test-src/main.cpp
index fd442ebd12..fccf89ba66 100644
--- a/alib2raw_cli_integration/test-src/main.cpp
+++ b/alib2raw_cli_integration/test-src/main.cpp
@@ -1,3 +1,5 @@
+#include <version.hpp>
+
 #include <tclap/CmdLine.h>
 
 #include <cppunit/CompilerOutputter.h>
@@ -97,7 +99,7 @@ CPPUNIT_NS_END
 
 int main(int argc, char* argv[]) {
 	try {
-		TCLAP::CmdLine cmd("Main test binary.", ' ', "0.01");
+		TCLAP::CmdLine cmd("Main test binary.", ' ', ALIB_VERSION_STRING);
 
 		TCLAP::MultiArg<std::string> testPathSegments("p", "path", "test path", false, "string" );
 		cmd.add( testPathSegments );
diff --git a/alib2std/test-src/main.cpp b/alib2std/test-src/main.cpp
index 0c2f15bc1c..7017268372 100644
--- a/alib2std/test-src/main.cpp
+++ b/alib2std/test-src/main.cpp
@@ -1,3 +1,5 @@
+#include <version.hpp>
+
 #include <tclap/CmdLine.h>
 
 #include <cppunit/CompilerOutputter.h>
@@ -95,7 +97,7 @@ CPPUNIT_NS_END
 
 int main(int argc, char* argv[]) {
 	try {
-		TCLAP::CmdLine cmd("Main test binary.", ' ', "0.01");
+		TCLAP::CmdLine cmd("Main test binary.", ' ', ALIB_VERSION_STRING);
 
 		TCLAP::MultiArg<std::string> testPathSegments("p", "path", "test path", false, "string" );
 		cmd.add( testPathSegments );
diff --git a/alib2str/test-src/main.cpp b/alib2str/test-src/main.cpp
index fd442ebd12..fccf89ba66 100644
--- a/alib2str/test-src/main.cpp
+++ b/alib2str/test-src/main.cpp
@@ -1,3 +1,5 @@
+#include <version.hpp>
+
 #include <tclap/CmdLine.h>
 
 #include <cppunit/CompilerOutputter.h>
@@ -97,7 +99,7 @@ CPPUNIT_NS_END
 
 int main(int argc, char* argv[]) {
 	try {
-		TCLAP::CmdLine cmd("Main test binary.", ' ', "0.01");
+		TCLAP::CmdLine cmd("Main test binary.", ' ', ALIB_VERSION_STRING);
 
 		TCLAP::MultiArg<std::string> testPathSegments("p", "path", "test path", false, "string" );
 		cmd.add( testPathSegments );
diff --git a/alib2str_cli_integration/test-src/main.cpp b/alib2str_cli_integration/test-src/main.cpp
index fd442ebd12..fccf89ba66 100644
--- a/alib2str_cli_integration/test-src/main.cpp
+++ b/alib2str_cli_integration/test-src/main.cpp
@@ -1,3 +1,5 @@
+#include <version.hpp>
+
 #include <tclap/CmdLine.h>
 
 #include <cppunit/CompilerOutputter.h>
@@ -97,7 +99,7 @@ CPPUNIT_NS_END
 
 int main(int argc, char* argv[]) {
 	try {
-		TCLAP::CmdLine cmd("Main test binary.", ' ', "0.01");
+		TCLAP::CmdLine cmd("Main test binary.", ' ', ALIB_VERSION_STRING);
 
 		TCLAP::MultiArg<std::string> testPathSegments("p", "path", "test path", false, "string" );
 		cmd.add( testPathSegments );
diff --git a/alib2xml/test-src/main.cpp b/alib2xml/test-src/main.cpp
index fd442ebd12..fccf89ba66 100644
--- a/alib2xml/test-src/main.cpp
+++ b/alib2xml/test-src/main.cpp
@@ -1,3 +1,5 @@
+#include <version.hpp>
+
 #include <tclap/CmdLine.h>
 
 #include <cppunit/CompilerOutputter.h>
@@ -97,7 +99,7 @@ CPPUNIT_NS_END
 
 int main(int argc, char* argv[]) {
 	try {
-		TCLAP::CmdLine cmd("Main test binary.", ' ', "0.01");
+		TCLAP::CmdLine cmd("Main test binary.", ' ', ALIB_VERSION_STRING);
 
 		TCLAP::MultiArg<std::string> testPathSegments("p", "path", "test path", false, "string" );
 		cmd.add( testPathSegments );
diff --git a/aminimize2/src/aminimize.cpp b/aminimize2/src/aminimize.cpp
index 0640cbc403..0ed54f1fc6 100644
--- a/aminimize2/src/aminimize.cpp
+++ b/aminimize2/src/aminimize.cpp
@@ -5,6 +5,8 @@
  *      Author: Jan Travnicek
  */
 
+#include <version.hpp>
+
 #include <tclap/CmdLine.h>
 #include <global/GlobalData.h>
 #include <measure>
@@ -20,7 +22,7 @@ int main(int argc, char** argv) {
 		common::GlobalData::argc = argc;
 		common::GlobalData::argv = argv;
 
-		TCLAP::CmdLine cmd("Automaton minimize binary", ' ', "0.01");
+		TCLAP::CmdLine cmd("Automaton minimize binary", ' ', ALIB_VERSION_STRING);
 
 		TCLAP::ValueArg<std::string> input(	"i",	"input",	"Automaton to minimize",	false,	"-",		"file");
 		cmd.add( input );
diff --git a/anormalize2/src/anormalize.cpp b/anormalize2/src/anormalize.cpp
index 7c95c87d1e..69b74934cb 100644
--- a/anormalize2/src/anormalize.cpp
+++ b/anormalize2/src/anormalize.cpp
@@ -5,6 +5,8 @@
  *      Author: Jan Travnicek
  */
 
+#include <version.hpp>
+
 #include <tclap/CmdLine.h>
 #include <global/GlobalData.h>
 #include <measure>
@@ -20,7 +22,7 @@ int main ( int argc, char * * argv ) {
 		common::GlobalData::argc = argc;
 		common::GlobalData::argv = argv;
 
-		TCLAP::CmdLine cmd ( "Automaton normalize binary", ' ', "0.01" );
+		TCLAP::CmdLine cmd ( "Automaton normalize binary", ' ', ALIB_VERSION_STRING );
 
 		TCLAP::ValueArg < std::string > input ( "i", "input", "Input to normalize", false, "-", "file" );
 		cmd.add ( input );
diff --git a/aql2/src/aql.cpp b/aql2/src/aql.cpp
index a320af5c5a..0022612729 100644
--- a/aql2/src/aql.cpp
+++ b/aql2/src/aql.cpp
@@ -5,6 +5,8 @@
  *	  Author: Jan Travnicek
  */
 
+#include <version.hpp>
+
 #include <istream>
 #include <iostream>
 
@@ -51,7 +53,7 @@ int main ( int argc, char * argv[] ) {
 		common::GlobalData::argc = argc;
 		common::GlobalData::argv = argv;
 
-		TCLAP::CmdLine cmd ( "Algorithms query language binary", ' ', "0.01" );
+		TCLAP::CmdLine cmd ( "Algorithms query language binary", ' ', ALIB_VERSION_STRING );
 
 		TCLAP::MultiArg < std::string > queries ( "q", "query", "Query string", false, "string" );
 		cmd.add ( queries );
diff --git a/aquery2/src/aquery.cpp b/aquery2/src/aquery.cpp
index 6813ac08ab..ddb26dd37a 100644
--- a/aquery2/src/aquery.cpp
+++ b/aquery2/src/aquery.cpp
@@ -5,6 +5,8 @@
  *	  Author: Jan Travnicek
  */
 
+#include <version.hpp>
+
 #include <tclap/CmdLine.h>
 #include <global/GlobalData.h>
 #include <measure>
@@ -20,7 +22,7 @@ int main ( int argc, char * argv[] ) {
 		common::GlobalData::argc = argc;
 		common::GlobalData::argv = argv;
 
-		TCLAP::CmdLine cmd ( "Stringology algorithm access binary", ' ', "0.01" );
+		TCLAP::CmdLine cmd ( "Stringology algorithm access binary", ' ', ALIB_VERSION_STRING );
 
 		std::vector < std::string > allowed;
 		allowed.push_back ( "suffixTrieFactors" );
diff --git a/arand2/src/arand.cpp b/arand2/src/arand.cpp
index a7d57c0cd4..6bbe35bca9 100644
--- a/arand2/src/arand.cpp
+++ b/arand2/src/arand.cpp
@@ -5,6 +5,8 @@
  *	  Author: Tomas Pecka
  */
 
+#include <version.hpp>
+
 #include <tclap/CmdLine.h>
 #include <global/GlobalData.h>
 #include <measure>
@@ -21,7 +23,7 @@ int main ( int argc, char * argv[] ) {
 		common::GlobalData::argc = argc;
 		common::GlobalData::argv = argv;
 
-		TCLAP::CmdLine cmd ( "Random generator binary", ' ', "0.01" );
+		TCLAP::CmdLine cmd ( "Random generator binary", ' ', ALIB_VERSION_STRING );
 
 		std::vector < std::string > allowed;
 		allowed.push_back ( "FSM" );
diff --git a/araw2/src/araw.cpp b/araw2/src/araw.cpp
index 0a066e9f9d..f09736165d 100644
--- a/araw2/src/araw.cpp
+++ b/araw2/src/araw.cpp
@@ -5,6 +5,8 @@
  *      Author: Jan Travnicek
 **/
 
+#include <version.hpp>
+
 #include <tclap/CmdLine.h>
 #include <global/GlobalData.h>
 #include <measure>
@@ -20,7 +22,7 @@ int main(int argc, char** argv) {
 		common::GlobalData::argc = argc;
 		common::GlobalData::argv = argv;
 
-		TCLAP::CmdLine cmd("raw reading binary", ' ', "0.01");
+		TCLAP::CmdLine cmd("raw reading binary", ' ', ALIB_VERSION_STRING);
 
 		TCLAP::ValueArg<std::string> input(	"i",	"input",	"Input to read",		false,	"-",		"file");
 		cmd.add( input );
diff --git a/arename2/src/arename.cpp b/arename2/src/arename.cpp
index 990de61692..6ed5cea141 100644
--- a/arename2/src/arename.cpp
+++ b/arename2/src/arename.cpp
@@ -5,6 +5,8 @@
  *      Author: Jan Travnicek
  */
 
+#include <version.hpp>
+
 #include <tclap/CmdLine.h>
 #include <global/GlobalData.h>
 #include <measure>
@@ -20,7 +22,7 @@ int main ( int argc, char * * argv ) {
 		common::GlobalData::argc = argc;
 		common::GlobalData::argv = argv;
 
-		TCLAP::CmdLine cmd ( "Automaton rename binary", ' ', "0.01" );
+		TCLAP::CmdLine cmd ( "Automaton rename binary", ' ', ALIB_VERSION_STRING );
 
 		TCLAP::ValueArg < std::string > input ( "i", "input", "Automaton to rename", false, "-", "file" );
 		cmd.add ( input );
diff --git a/areverse2/src/areverse.cpp b/areverse2/src/areverse.cpp
index c8fd549b6c..02857b7202 100644
--- a/areverse2/src/areverse.cpp
+++ b/areverse2/src/areverse.cpp
@@ -5,6 +5,8 @@
  *      Author: Tomas Pecka
  */
 
+#include <version.hpp>
+
 #include <tclap/CmdLine.h>
 #include <global/GlobalData.h>
 #include <measure>
@@ -20,7 +22,7 @@ int main(int argc, char** argv) {
 		common::GlobalData::argc = argc;
 		common::GlobalData::argv = argv;
 
-		TCLAP::CmdLine cmd("Automaton reverse binary", ' ', "0.01");
+		TCLAP::CmdLine cmd("Automaton reverse binary", ' ', ALIB_VERSION_STRING);
 
 		TCLAP::ValueArg<std::string> input(	"i",	"input",	"Automaton to reverse",		false,	"-",		"file");
 		cmd.add( input );
diff --git a/arun2/src/arun.cpp b/arun2/src/arun.cpp
index cfe860e495..8296a63f69 100644
--- a/arun2/src/arun.cpp
+++ b/arun2/src/arun.cpp
@@ -5,6 +5,8 @@
  *	  Author: Jan Travnicek
  */
 
+#include <version.hpp>
+
 #include <tclap/CmdLine.h>
 #include <global/GlobalData.h>
 #include <measure>
@@ -20,7 +22,7 @@ int main(int argc, char* argv[]) {
 		common::GlobalData::argc = argc;
 		common::GlobalData::argv = argv;
 
-		TCLAP::CmdLine cmd("Automaton run binary", ' ', "0.01");
+		TCLAP::CmdLine cmd("Automaton run binary", ' ', ALIB_VERSION_STRING);
 
 		std::vector<std::string> allowed;
 		allowed.push_back("occurrences");
diff --git a/astat2/src/astat.cpp b/astat2/src/astat.cpp
index 1bbe2ece4e..28c2b60270 100644
--- a/astat2/src/astat.cpp
+++ b/astat2/src/astat.cpp
@@ -5,6 +5,8 @@
  *	  Author: Jan Travnicek
  */
 
+#include <version.hpp>
+
 #include <tclap/CmdLine.h>
 #include <global/GlobalData.h>
 #include <measure>
@@ -20,7 +22,7 @@ int main ( int argc, char * argv[] ) {
 		common::GlobalData::argc = argc;
 		common::GlobalData::argv = argv;
 
-		TCLAP::CmdLine cmd ( "Prints useful information about raw data structures", ' ', "0.01" );
+		TCLAP::CmdLine cmd ( "Prints useful information about raw data structures", ' ', ALIB_VERSION_STRING );
 
 		// ----------------------------------------------------------------------------------------------------------------------------------------------------------------------
 
diff --git a/astringology2/src/astringology.cpp b/astringology2/src/astringology.cpp
index 4b75041ba0..00d1eb2df4 100644
--- a/astringology2/src/astringology.cpp
+++ b/astringology2/src/astringology.cpp
@@ -5,6 +5,8 @@
  *	  Author: Jan Travnicek
  */
 
+#include <version.hpp>
+
 #include <tclap/CmdLine.h>
 #include <global/GlobalData.h>
 #include <measure>
@@ -20,7 +22,7 @@ int main ( int argc, char * argv[] ) {
 		common::GlobalData::argc = argc;
 		common::GlobalData::argv = argv;
 
-		TCLAP::CmdLine cmd ( "Stringology algorithm access binary", ' ', "0.01" );
+		TCLAP::CmdLine cmd ( "Stringology algorithm access binary", ' ', ALIB_VERSION_STRING );
 
 		std::vector < std::string > allowed;
 		allowed.push_back ( "exactFactorMatch" );
diff --git a/atrim2/src/atrim.cpp b/atrim2/src/atrim.cpp
index 0ca7ff32d9..956bbdce18 100644
--- a/atrim2/src/atrim.cpp
+++ b/atrim2/src/atrim.cpp
@@ -5,6 +5,8 @@
  *	  Author: Tomas Pecka
  */
 
+#include <version.hpp>
+
 #include <tclap/CmdLine.h>
 #include <global/GlobalData.h>
 #include <measure>
@@ -54,7 +56,7 @@ int main(int argc, char* argv[]) {
 		common::GlobalData::argc = argc;
 		common::GlobalData::argv = argv;
 
-		TCLAP::CmdLine cmd("Removes unreachable and useless states from FSM, productive and unreachable nonterminals from CFG. Simplifies representation of RE", ' ', "0.01");
+		TCLAP::CmdLine cmd("Removes unreachable and useless states from FSM, productive and unreachable nonterminals from CFG. Simplifies representation of RE", ' ', ALIB_VERSION_STRING);
 
 		TCLAP::SwitchArg useless(		"u",	"useless",	"Removes useless states (or symbols). (works with FSM, FTA or CFG)"	);
 		cmd.add( useless );
diff --git a/include/version.hpp b/include/version.hpp
new file mode 100644
index 0000000000..2d914e78a9
--- /dev/null
+++ b/include/version.hpp
@@ -0,0 +1,25 @@
+#ifndef __VERSION_HPP_
+#define __VERSION_HPP_
+
+#define __alib__xstr(s) __alib__str(s)
+#define __alib__str(s) #s
+
+#define ALIB_VERSION_STRING __alib__xstr(ALIB_VERSION)
+#define ALIB_VERSION_STAMP ALIB_VERSION_MAJOR*10000+ALIB_VERSION_MINOR*100+ALIB_VERSION_PATCH
+
+#ifdef ALIB_GIT_COMMIT_HASH
+  #define ALIB_GIT_COMMIT_HASH_STRING __alib__xstr(ALIB_GIT_COMMIT_HASH)
+#endif
+
+#ifdef ALIB_GIT_BRANCH
+  #define ALIB_GIT_BRANCH_STRING __alib__xstr(ALIB_GIT_BRANCH)
+#endif
+
+#if defined ALIB_GIT_COMMIT_HASH_STRING && defined ALIB_GIT_BRANCH_STRING
+  #define ALIB_FULL_VERSION_STRING "version: " ALIB_VERSION_STRING "  branch: " ALIB_GIT_BRANCH_STRING "  hash: " ALIB_GIT_COMMIT_HASH_STRING
+#else
+  #define ALIB_FULL_VERSION_STRING ALIB_VERSION_STRING
+#endif
+
+
+#endif // __VERSION_HPP_
diff --git a/tniceprint/src/tniceprint.cpp b/tniceprint/src/tniceprint.cpp
index 51f3090c91..561c478c3e 100644
--- a/tniceprint/src/tniceprint.cpp
+++ b/tniceprint/src/tniceprint.cpp
@@ -5,6 +5,8 @@
  *      Author: Martin Zak
  */
 
+#include <version.hpp>
+
 #include <tclap/CmdLine.h>
 #include <global/GlobalData.h>
 #include <measure>
@@ -23,7 +25,7 @@ int main(int argc, char** argv) {
 		common::GlobalData::argc = argc;
 		common::GlobalData::argv = argv;
 
-		TCLAP::CmdLine cmd("Tree nice print binary", ' ', "0.01");
+		TCLAP::CmdLine cmd("Tree nice print binary", ' ', ALIB_VERSION_STRING);
 
 		TCLAP::ValueArg<std::string> input(	"i",	"input",	"Input to nice print",		false,	"-",		"file");
 		cmd.add( input );
-- 
GitLab