From d490f6ee8bf5086f4df98beaab2775e43b55c800 Mon Sep 17 00:00:00 2001 From: Alain Zscheile Date: Mon, 5 Sep 2022 01:15:11 +0200 Subject: [PATCH] cmake build: don't hardcode absolute paths in install DESTINATIONs 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 --- CMakeLists.txt | 8 ++++---- logrotate.conf_install.cmake.in | 6 +++--- tcmu.conf_install.cmake.in | 6 +++--- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index e565a671..d2c5ae0f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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) diff --git a/logrotate.conf_install.cmake.in b/logrotate.conf_install.cmake.in index c8dcc40b..baa218eb 100644 --- a/logrotate.conf_install.cmake.in +++ b/logrotate.conf_install.cmake.in @@ -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") diff --git a/tcmu.conf_install.cmake.in b/tcmu.conf_install.cmake.in index 99775107..bf7f2aa4 100644 --- a/tcmu.conf_install.cmake.in +++ b/tcmu.conf_install.cmake.in @@ -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")