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 <[email protected]>
  • Loading branch information
fogti committed Sep 5, 2022
1 parent 364ae61 commit 1f5e492
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 11 deletions.
10 changes: 5 additions & 5 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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")
Expand Down 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_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)
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_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")
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_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")

0 comments on commit 1f5e492

Please sign in to comment.