1# BAREOS® - Backup Archiving REcovery Open Sourced 2# 3# Copyright (C) 2017-2019 Bareos GmbH & Co. KG 4# 5# This program is Free Software; you can redistribute it and/or modify it under 6# the terms of version three of the GNU Affero General Public License as 7# published by the Free Software Foundation and included in the file LICENSE. 8# 9# This program is distributed in the hope that it will be useful, but WITHOUT 10# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 11# FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more 12# details. 13# 14# You should have received a copy of the GNU Affero General Public License along 15# with this program; if not, write to the Free Software Foundation, Inc., 51 16# Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 17 18include(BareosVersion OPTIONAL RESULT_VARIABLE BareosVersionFile) 19if(BareosVersionFile STREQUAL "NOTFOUND") 20 # no version file, try data from git 21 if(GIT_DESCRIBE_VERSION) 22 message(STATUS "Using version information from Git") 23 if(DEFINED VERSION_STRING) 24 message( 25 STATUS 26 "VERSION_STRING already set to ${VERSION_STRING}. Will not overwrite" 27 ) 28 else() 29 set(VERSION_STRING "${GIT_DESCRIBE_VERSION}") 30 endif() 31 set(VERSION_TIMESTAMP "${GIT_COMMIT_TIMESTAMP}") 32 else() 33 message( 34 FATAL_ERROR 35 "VERSION_STRING not set, BareosVersion.cmake not found and no version data from git available.\n" 36 "For more information why this happened and how to fix it, please see " 37 "https://docs.bareos.org/DeveloperGuide/AutomaticVersionGeneration.html#troubleshooting" 38 ) 39 endif() 40else() 41 message(STATUS "Using version information from ${BareosVersionFile}") 42endif() 43 44string(REGEX MATCH [0-9.a-zA-Z~]+ BAREOS_FULL_VERSION ${VERSION_STRING}) 45 46if(BAREOS_FULL_VERSION STREQUAL "") 47 message(FATAL_ERROR "BAREOS_FULL_VERSION is not set") 48endif() 49 50# set BAREOS_FULL_VERSION in parent scope if there is a parent scope 51get_directory_property(hasParent PARENT_DIRECTORY) 52if(hasParent) 53 set(BAREOS_FULL_VERSION 54 ${BAREOS_FULL_VERSION} 55 PARENT_SCOPE 56 ) 57endif() 58 59string(REGEX MATCH [0-9]+.[0-9]+.[0-9]+ BAREOS_NUMERIC_VERSION 60 ${VERSION_STRING} 61) 62 63string(REPLACE "." ";" VERSION_LIST ${BAREOS_NUMERIC_VERSION}) 64list(GET VERSION_LIST 0 BAREOS_VERSION_MAJOR) 65list(GET VERSION_LIST 1 BAREOS_VERSION_MINOR) 66list(GET VERSION_LIST 2 BAREOS_VERSION_PATCH) 67 68message("BAREOS_NUMERIC_VERSION is ${BAREOS_NUMERIC_VERSION}") 69message("BAREOS_FULL_VERSION is ${BAREOS_FULL_VERSION}") 70 71if(VERSION_TIMESTAMP GREATER 0) 72 include(BareosTimeFunctions) 73 timestamp_at("${VERSION_TIMESTAMP}" DATE "%d %B %Y") 74 timestamp_at("${VERSION_TIMESTAMP}" BAREOS_SHORT_DATE "%d%b%y") 75 timestamp_at("${VERSION_TIMESTAMP}" BAREOS_YEAR "%Y") 76 timestamp_at("${VERSION_TIMESTAMP}" BAREOS_PROG_DATE_TIME "%Y-%m-%d %H:%M:%S") 77else() 78 message(FATAL_ERROR "VERSION_TIMESTAMP is not set") 79endif() 80 81# extract db version from cats.h 82file(STRINGS ${CMAKE_CURRENT_LIST_DIR}/../src/cats/cats.h DB_VERSION_STRING 83 REGEX .*BDB_VERSION.* 84) 85string(REGEX MATCH [0-9]+ BDB_VERSION ${DB_VERSION_STRING}) 86