Skip to content

Commit

Permalink
cmake build: don't hardcode absolute paths in install DESTINATIONs
Browse files Browse the repository at this point in the history
Fixes #683

> Currently, the CMakeLists.txt and *.conf_install.cmake.in files contain
> absolute install paths, that is, not relative to ${CMAKE_INSTALL_PREFIX}.
> This makes packaging this program unusually hard.

Signed-off-by: Alain Zscheile <zseri.devel@ytrizja.de>
  • Loading branch information
fogti committed Sep 4, 2022
1 parent 364ae61 commit d490f6e
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
8 changes: 4 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -324,9 +324,9 @@ configure_file (
install(SCRIPT logrotate.conf_install.cmake)

install(FILES org.kernel.TCMUService1.service
DESTINATION /usr/share/dbus-1/system-services)
install(FILES tcmu-runner.conf DESTINATION /etc/dbus-1/system.d)
DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/dbus-1/system-services)
install(FILES tcmu-runner.conf DESTINATION ${CMAKE_INSTALL_SYSCONFDIR}/dbus-1/system.d)
if (SUPPORT_SYSTEMD)
install(FILES tcmu-runner.service DESTINATION /usr/lib/systemd/system/)
install(FILES tcmu-runner.service DESTINATION ${CMAKE_INSTALL_PREFIX}/lib/systemd/system)
endif (SUPPORT_SYSTEMD)
install(FILES tcmu-runner.8 DESTINATION ${CMAKE_INSTALL_PREFIX}/share/man/man8)
install(FILES tcmu-runner.8 DESTINATION ${CMAKE_INSTALL_MANDIR}/man8)
6 changes: 3 additions & 3 deletions logrotate.conf_install.cmake.in
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
if (EXISTS "/etc/logrotate.d/tcmu-runner")
file(INSTALL "/etc/logrotate.d/tcmu-runner" DESTINATION "/etc/logrotate.d/tcmu-runner.bak" RENAME "tcmu-runner")
if (EXISTS "${CMAKE_INSTALL_SYSCONFDIR}/logrotate.d/tcmu-runner")
file(INSTALL "${CMAKE_INSTALL_SYSCONFDIR}/logrotate.d/tcmu-runner" DESTINATION "${CMAKE_INSTALL_SYSCONFDIR}/logrotate.d/tcmu-runner.bak" RENAME "tcmu-runner")
endif()
file(INSTALL "${PROJECT_SOURCE_DIR}/logrotate.conf" DESTINATION "/etc/logrotate.d" RENAME "tcmu-runner")
file(INSTALL "${PROJECT_SOURCE_DIR}/logrotate.conf" DESTINATION "${CMAKE_INSTALL_SYSCONFDIR}/logrotate.d" RENAME "tcmu-runner")
6 changes: 3 additions & 3 deletions tcmu.conf_install.cmake.in
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
if (EXISTS "/etc/tcmu/tcmu.conf")
file(INSTALL "/etc/tcmu/tcmu.conf" DESTINATION "/etc/tcmu/" RENAME "tcmu.conf.old")
if (EXISTS "${CMAKE_INSTALL_SYSCONFDIR}/tcmu/tcmu.conf")
file(INSTALL "${CMAKE_INSTALL_SYSCONFDIR}/tcmu/tcmu.conf" DESTINATION "${CMAKE_INSTALL_SYSCONFDIR}/tcmu/" RENAME "tcmu.conf.old")
endif()
file(INSTALL "${PROJECT_SOURCE_DIR}/tcmu.conf" DESTINATION "/etc/tcmu/")
file(INSTALL "${PROJECT_SOURCE_DIR}/tcmu.conf" DESTINATION "${CMAKE_INSTALL_SYSCONFDIR}/tcmu")

0 comments on commit d490f6e

Please sign in to comment.