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 authored and BareosBot committed Mar 12, 2024
1 parent dda1eb9 commit 4050c51
Show file tree
Hide file tree
Showing 10 changed files with 29 additions and 36 deletions.
25 changes: 0 additions & 25 deletions .gitignore
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
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
Expand Up @@ -728,9 +728,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
6 changes: 4 additions & 2 deletions core/src/dird/CMakeLists.txt
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,7 +204,7 @@ 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)

Expand Down
2 changes: 1 addition & 1 deletion core/src/filed/CMakeLists.txt
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
)
Expand Down
3 changes: 3 additions & 0 deletions core/src/plugins/filed/CMakeLists.txt
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 @@ -84,6 +86,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
3 changes: 3 additions & 0 deletions core/src/plugins/filed/python/CMakeLists.txt
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,8 @@ 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
6 changes: 4 additions & 2 deletions core/src/qt-tray-monitor/CMakeLists.txt
Expand Up @@ -67,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 @@ -95,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
2 changes: 1 addition & 1 deletion core/src/stored/CMakeLists.txt
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
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 4050c51

Please sign in to comment.