Skip to content

Commit

Permalink
cmake: stage configs in binary dir
Browse files Browse the repository at this point in the history
Previously all to-be-installed configuration files were taken from the
source tree. As some of them need to be configured we stage all
configuration files in the binary dir during configuration first and
install from there.
  • Loading branch information
arogge committed Feb 2, 2024
1 parent fb83861 commit 481c0ba
Show file tree
Hide file tree
Showing 10 changed files with 37 additions and 41 deletions.
25 changes: 0 additions & 25 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -19,31 +19,6 @@ webui/version.php
# Ignore files created by core/cmake/BareosConfigureFile.cmake
# can be regenerated by running the following command:
# find debian/ core/src/defaultconfigs -name '*.in' -print | sed -e 's/\.in$//' | sort
core/src/defaultconfigs/bareos-dir.d/catalog/MyCatalog.conf
core/src/defaultconfigs/bareos-dir.d/client/bareos-fd.conf
core/src/defaultconfigs/bareos-dir.d/console/bareos-mon.conf
core/src/defaultconfigs/bareos-dir.d/director/bareos-dir.conf
core/src/defaultconfigs/bareos-dir.d/fileset/Catalog.conf
core/src/defaultconfigs/bareos-dir.d/fileset/LinuxAll.conf
core/src/defaultconfigs/bareos-dir.d/fileset/SelfTest.conf
core/src/defaultconfigs/bareos-dir.d/job/backup-bareos-fd.conf
core/src/defaultconfigs/bareos-dir.d/job/BackupCatalog.conf
core/src/defaultconfigs/bareos-dir.d/jobdefs/DefaultJob.conf
core/src/defaultconfigs/bareos-dir.d/job/RestoreFiles.conf
core/src/defaultconfigs/bareos-dir.d/messages/Daemon.conf
core/src/defaultconfigs/bareos-dir.d/messages/Standard.conf
core/src/defaultconfigs/bareos-dir.d/storage/File.conf
core/src/defaultconfigs/bareos-fd.d/client/myself.conf
core/src/defaultconfigs/bareos-fd.d/director/bareos-dir.conf
core/src/defaultconfigs/bareos-fd.d/director/bareos-mon.conf
core/src/defaultconfigs/bareos-sd.d/device/FileStorage.conf
core/src/defaultconfigs/bareos-sd.d/director/bareos-dir.conf
core/src/defaultconfigs/bareos-sd.d/director/bareos-mon.conf
core/src/defaultconfigs/bareos-sd.d/storage/bareos-sd.conf
core/src/defaultconfigs/tray-monitor.d/client/FileDaemon-local.conf
core/src/defaultconfigs/tray-monitor.d/director/Director-local.conf
core/src/defaultconfigs/tray-monitor.d/monitor/bareos-mon.conf
core/src/defaultconfigs/tray-monitor.d/storage/StorageDaemon-local.conf
debian/bareos-bconsole.install
debian/bareos-bconsole.postinst
debian/bareos-common.install
Expand Down
11 changes: 8 additions & 3 deletions cmake/BareosConfigureFile.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
# to its template or into the corresponding CMAKE_CURRENT_BINARY_DIR

function(bareos_configure_file)
cmake_parse_arguments(ARG "IN_TREE" "" "FILES;GLOB_RECURSE" ${ARGN})
cmake_parse_arguments(ARG "IN_TREE;COPY" "" "FILES;GLOB_RECURSE" ${ARGN})
set(file_list "")
if(ARG_FILES)
list(APPEND file_list ${ARG_FILES})
Expand Down Expand Up @@ -52,8 +52,13 @@ function(bareos_configure_file)
message(STATUS "creating directory ${out_dir}")
file(MAKE_DIRECTORY "${out_dir}")
endif()
message(STATUS "creating symlinking ${out_file}")
file(CREATE_LINK "${in_file}" "${out_file}" SYMBOLIC)
if(ARG_COPY)
message(STATUS "creating file ${out_file}")
configure_file("${in_file}" "${out_file}" COPYONLY)
else()
message(STATUS "creating symlinking ${out_file}")
file(CREATE_LINK "${in_file}" "${out_file}" SYMBOLIC)
endif()
endif()
endforeach()
endfunction()
5 changes: 3 additions & 2 deletions core/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -776,9 +776,10 @@ else()
endif()

include(BareosConfigureFile)
bareos_configure_file(GLOB_RECURSE "${CMAKE_SOURCE_DIR}/debian/*.in" IN_TREE)

bareos_configure_file(
GLOB_RECURSE "${CMAKE_SOURCE_DIR}/debian/*.in" "src/*.in"
IN_TREE
GLOB_RECURSE "${CMAKE_CURRENT_SOURCE_DIR}/src/defaultconfigs/*" COPY
)

add_subdirectory(platforms)
Expand Down
8 changes: 5 additions & 3 deletions core/src/dird/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# BAREOS® - Backup Archiving REcovery Open Sourced
#
# Copyright (C) 2017-2023 Bareos GmbH & Co. KG
# Copyright (C) 2017-2024 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
Expand Down Expand Up @@ -114,7 +114,9 @@ set(DIRD_OBJECTS_SRCS

if(HAVE_WIN32)
bareos_configure_file(FILES ../win32/dird/dirdres.rc.in)
list(APPEND DIRD_OBJECTS_SRCS ${CMAKE_CURRENT_BINARY_DIR}/../win32/dird/dirdres.rc)
list(APPEND DIRD_OBJECTS_SRCS
${CMAKE_CURRENT_BINARY_DIR}/../win32/dird/dirdres.rc
)
endif()

if(HAVE_PAM)
Expand Down Expand Up @@ -202,6 +204,6 @@ message("using PLUGINS: ${PLUGINS}")
install(CODE "set(BACKENDS \"${BACKENDS}\")")
install(CODE "set(PLUGINS \"${PLUGINS}\")")
install(CODE "set(configtemplatedir \"${configtemplatedir}\")")
install(CODE "set(SRC_DIR \"${PROJECT_SOURCE_DIR}\")")
install(CODE "set(SRC_DIR \"${PROJECT_BINARY_DIR}\")")

install(SCRIPT ${PROJECT_SOURCE_DIR}/cmake/install-dird-configfiles.cmake)
4 changes: 2 additions & 2 deletions core/src/filed/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# BAREOS® - Backup Archiving REcovery Open Sourced
#
# Copyright (C) 2017-2022 Bareos GmbH & Co. KG
# Copyright (C) 2017-2024 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
Expand Down Expand Up @@ -112,7 +112,7 @@ install(CODE "set(BACKENDS \"${BACKENDS}\")" COMPONENT filedaemon)
install(CODE "set(configtemplatedir \"${configtemplatedir}\")"
COMPONENT filedaemon
)
install(CODE "set(SRC_DIR \"${PROJECT_SOURCE_DIR}\")" COMPONENT filedaemon)
install(CODE "set(SRC_DIR \"${PROJECT_BINARY_DIR}\")" COMPONENT filedaemon)
install(SCRIPT ${PROJECT_SOURCE_DIR}/cmake/install-filed-configfiles.cmake
COMPONENT filedaemon
)
3 changes: 3 additions & 0 deletions core/src/plugins/filed/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
# 02110-1301, USA.
message("Entering ${CMAKE_CURRENT_SOURCE_DIR}")

include(BareosConfigureFile)

if(HAVE_WIN32)
include_directories(
${PROJECT_SOURCE_DIR}/src/win32
Expand Down Expand Up @@ -79,6 +81,7 @@ endif()

option(ENABLE_GFAPI_FD "Build gfapi-fd plugin if possible" ON)
if(HAVE_GLUSTERFS AND ENABLE_GFAPI_FD)
bareos_configure_file(GLOB_RECURSE "gfapi/gfapi-conf.d/*" COPY)
add_library(gfapi-fd MODULE gfapi/gfapi-fd.cc)
set_target_properties(gfapi-fd PROPERTIES PREFIX "")
install(
Expand Down
4 changes: 4 additions & 0 deletions core/src/plugins/filed/python/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
# 02110-1301, USA.

include(BareosDisableWarnings)
include(BareosConfigureFile)

if(Python3_FOUND)
add_library(python3-fd MODULE python-fd.cc)
Expand Down Expand Up @@ -115,6 +116,9 @@ if(Python3_FOUND)
set_property(TEST python-simple-test-example PROPERTY DISABLED true)
endif()


bareos_configure_file(GLOB_RECURSE "ldap/python-ldap-conf.d/*" COPY)

set(PYFILES
pyfiles/BareosFdPluginBaseclass.py
pyfiles/BareosFdWrapper.py
Expand Down
12 changes: 8 additions & 4 deletions core/src/qt-tray-monitor/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# BAREOS® - Backup Archiving REcovery Open Sourced
#
# Copyright (C) 2017-2022 Bareos GmbH & Co. KG
# Copyright (C) 2017-2024 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
Expand Down Expand Up @@ -40,7 +40,9 @@ else()
message(STATUS "QT5Widgets NOT found, checking for Qt4 ...")
find_package(Qt4)
if(NOT Qt4_FOUND)
message(FATAL_ERROR "Both Qt5 and Qt4 not found, cannot build tray-monitor")
message(
FATAL_ERROR "Both Qt5 and Qt4 not found, cannot build tray-monitor"
)
endif()
endif()
endif()
Expand All @@ -65,7 +67,9 @@ set(SOURCES

if(HAVE_WIN32)
bareos_configure_file(FILES ../win32/qt-tray-monitor/traymon.rc.in)
list(APPEND SOURCES ${CMAKE_CURRENT_BINARY_DIR}/../win32/qt-tray-monitor/traymon.rc)
list(APPEND SOURCES
${CMAKE_CURRENT_BINARY_DIR}/../win32/qt-tray-monitor/traymon.rc
)
endif()

if(HAVE_WIN32)
Expand Down Expand Up @@ -93,7 +97,7 @@ bareos_configure_file(FILES bareos-tray-monitor.desktop.in)
install(TARGETS bareos-tray-monitor DESTINATION "${bindir}")

install(CODE "set(configtemplatedir \"${configtemplatedir}\")")
install(CODE "set(SRC_DIR \"${PROJECT_SOURCE_DIR}\")")
install(CODE "set(SRC_DIR \"${PROJECT_BINARY_DIR}\")")

install(
SCRIPT ${PROJECT_SOURCE_DIR}/cmake/install-tray-monitor-configfiles.cmake
Expand Down
4 changes: 2 additions & 2 deletions core/src/stored/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# BAREOS® - Backup Archiving REcovery Open Sourced
#
# Copyright (C) 2017-2023 Bareos GmbH & Co. KG
# Copyright (C) 2017-2024 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
Expand Down Expand Up @@ -215,7 +215,7 @@ install(TARGETS bareos-sd bls bextract bscan btape bcopy

install(CODE "set(BACKENDS \"${BACKENDS}\")")
install(CODE "set(configtemplatedir \"${configtemplatedir}\")")
install(CODE "set(SRC_DIR \"${PROJECT_SOURCE_DIR}\")")
install(CODE "set(SRC_DIR \"${PROJECT_BINARY_DIR}\")")
install(SCRIPT ${PROJECT_SOURCE_DIR}/cmake/install-stored-configfiles.cmake)

install(DIRECTORY DESTINATION "${archivedir}")
Expand Down
2 changes: 2 additions & 0 deletions core/src/stored/backends/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
# 02110-1301, USA.

message("Entering ${CMAKE_CURRENT_SOURCE_DIR}")
include(BareosConfigureFile)
bareos_configure_file(GLOB_RECURSE "*.d/*" COPY)

list(APPEND CMAKE_INSTALL_RPATH ${backenddir})

Expand Down

0 comments on commit 481c0ba

Please sign in to comment.