Skip to content

Commit

Permalink
add cmake script to write version files
Browse files Browse the repository at this point in the history
  • Loading branch information
arogge committed Nov 13, 2019
1 parent 879350c commit 16ed43e
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 36 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Expand Up @@ -24,3 +24,6 @@ debian/*.log
# etags and cscope db
tags
cscope.out

# generated version files
*/cmake/BareosVersion.cmake
18 changes: 0 additions & 18 deletions core/cmake/BareosVersion.cmake

This file was deleted.

18 changes: 0 additions & 18 deletions webui/cmake/BareosVersion.cmake

This file was deleted.

43 changes: 43 additions & 0 deletions 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()

0 comments on commit 16ed43e

Please sign in to comment.