diff options
author | Andreas Rogge <andreas.rogge@bareos.com> | 2019-10-21 13:31:20 +0300 |
---|---|---|
committer | Andreas Rogge <andreas.rogge@bareos.com> | 2019-11-13 12:46:33 +0300 |
commit | 16ed43e8db13daf01b449f82dd9d37d8d604d5b6 (patch) | |
tree | aada0fb22d9cd001e663ba45f90dd9326f3047c2 /write_version_files.cmake | |
parent | 879350caf3ad695a0e27405a0fe69837c53452d1 (diff) |
add cmake script to write version files
Diffstat (limited to 'write_version_files.cmake')
-rw-r--r-- | write_version_files.cmake | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/write_version_files.cmake b/write_version_files.cmake new file mode 100644 index 000000000..0becb098a --- /dev/null +++ b/write_version_files.cmake @@ -0,0 +1,43 @@ +# BAREOSĀ® - Backup Archiving REcovery Open Sourced +# +# Copyright (C) 2019-2019 Bareos GmbH & Co. KG +# +# This program is Free Software; you can redistribute it and/or modify it under +# the terms of version three of the GNU Affero General Public License as +# published by the Free Software Foundation and included in the file LICENSE. +# +# This program is distributed in the hope that it will be useful, but WITHOUT +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +# FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more +# details. +# +# You should have received a copy of the GNU Affero General Public License along +# with this program; if not, write to the Free Software Foundation, Inc., 51 +# Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + +cmake_minimum_required(VERSION 3.0) + +set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/cmake" + "${CMAKE_CURRENT_LIST_DIR}/core/cmake" + "${CMAKE_CURRENT_LIST_DIR}/webui/cmake") + +find_package(Git) +include(BareosVersionFromGit) + +include(BareosVersion OPTIONAL RESULT_VARIABLE BareosVersionFile) +if(BareosVersionFile STREQUAL "NOTFOUND") + if(GIT_DESCRIBE_VERSION) + set(VERSION_STRING "${GIT_DESCRIBE_VERSION}") + else() + message(FATAL_ERROR "No version information from git available.") + endif() +endif() + +set(version_file_header "# autogenerated by write_version_files.cmake") +set(version_file_contents "${version_file_header}\nset(VERSION_STRING \"${GIT_DESCRIBE_VERSION}\")\nset(VERSION_TIMESTAMP \"${GIT_COMMIT_TIMESTAMP}\")\n") + +foreach(subdir "core" "webui") + set(version_file_name "${CMAKE_CURRENT_LIST_DIR}/${subdir}/cmake/BareosVersion.cmake") + message(STATUS "Writing ${version_file_name}") + file(WRITE ${version_file_name} "${version_file_contents}") +endforeach() |