From 1f5e492f814061f32a4de100f049ee17ffe4d843 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 | 10 +++++----- logrotate.conf_install.cmake.in | 6 +++--- tcmu.conf_install.cmake.in | 6 +++--- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index e565a671..be290fce 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required (VERSION 2.8 FATAL_ERROR) +cmake_minimum_required (VERSION 3.0 FATAL_ERROR) project (tcmu-runner C) set(VERSION 1.5.4) set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Werror -Wall -Wdeclaration-after-statement -std=c99") @@ -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_FULL_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..fa83c8e0 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_FULL_SYSCONFDIR}/logrotate.d/tcmu-runner") + file(RENAME "${CMAKE_INSTALL_FULL_SYSCONFDIR}/logrotate.d/tcmu-runner" "${CMAKE_INSTALL_FULL_SYSCONFDIR}/logrotate.d/tcmu-runner.bak") endif() -file(INSTALL "${PROJECT_SOURCE_DIR}/logrotate.conf" DESTINATION "/etc/logrotate.d" RENAME "tcmu-runner") +install(FILES "${PROJECT_SOURCE_DIR}/logrotate.conf" DESTINATION "${CMAKE_INSTALL_FULL_SYSCONFDIR}/logrotate.d" RENAME "tcmu-runner") diff --git a/tcmu.conf_install.cmake.in b/tcmu.conf_install.cmake.in index 99775107..fc73221a 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_FULL_SYSCONFDIR}/tcmu/tcmu.conf") + file(RENAME "${CMAKE_INSTALL_FULL_SYSCONFDIR}/tcmu/tcmu.conf" "${CMAKE_INSTALL_FULL_SYSCONFDIR}/tcmu/tcmu.conf.old") endif() -file(INSTALL "${PROJECT_SOURCE_DIR}/tcmu.conf" DESTINATION "/etc/tcmu/") +install(FILES "${PROJECT_SOURCE_DIR}/tcmu.conf" DESTINATION "${CMAKE_INSTALL_FULL_SYSCONFDIR}/tcmu")