From b250237e015f7ffb78d576f8192224afac052135 Mon Sep 17 00:00:00 2001 From: Luca Matei Pintilie Date: Sat, 10 Jan 2026 23:04:36 +0100 Subject: [PATCH] install files using GNUInstallDirs --- CMakeLists.txt | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 96854c0..687a442 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -344,11 +344,23 @@ add_custom_target(everything DEPENDS test_suite biboumi) # ## Install target # -install(TARGETS ${PROJECT_NAME} RUNTIME DESTINATION bin) -install(FILES ${CMAKE_CURRENT_BINARY_DIR}/man/biboumi.1 DESTINATION share/man/man1 OPTIONAL COMPONENT documentation) -install(FILES ${CMAKE_CURRENT_BINARY_DIR}/biboumi.service DESTINATION lib/systemd/system COMPONENT init) +include(GNUInstallDirs) + +# From cmake version 4.1 CMAKE_INSTALL_SYSCONFDIR has special behaviour when +# CMAKE_INSTALL_PREFIX is /, /usr, or /opt/..., so to not update cmake version +# just yet reimplement this here +# https://cmake.org/cmake/help/latest/module/GNUInstallDirs.html#special-cases +if (CMAKE_INSTALL_SYSCONFDIR STREQUAL "etc" AND (CMAKE_INSTALL_PREFIX STREQUAL "/" OR CMAKE_INSTALL_PREFIX STREQUAL "/usr")) + set(CMAKE_INSTALL_SYSCONFDIR "/etc") +elseif (CMAKE_INSTALL_SYSCONFDIR STREQUAL "etc" AND (CMAKE_INSTALL_PREFIX MATCHES "^/opt/")) + set(CMAKE_INSTALL_SYSCONFDIR "/etc${CMAKE_INSTALL_PREFIX}") +endif() + +install(TARGETS ${PROJECT_NAME} RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) +install(FILES ${CMAKE_CURRENT_BINARY_DIR}/man/biboumi.1 DESTINATION ${CMAKE_INSTALL_MANDIR}/man1 OPTIONAL COMPONENT documentation) +install(FILES ${CMAKE_CURRENT_BINARY_DIR}/biboumi.service DESTINATION ${CMAKE_INSTALL_LIBDIR}/systemd/system COMPONENT init) file(GLOB policy_files conf/*policy.txt) -install(FILES ${policy_files} DESTINATION etc/biboumi COMPONENT configuration) +install(FILES ${policy_files} DESTINATION ${CMAKE_INSTALL_SYSCONFDIR}/biboumi COMPONENT configuration) # ## Dist target