From 8cc1b4fcfda58d64921476b9599c84064815d3a4 Mon Sep 17 00:00:00 2001 From: patrick96 Date: Mon, 13 Feb 2023 21:08:48 +0100 Subject: [PATCH] fix(build): Use CMAKE_INSTALL_FULL_ for default config Using CMAKE_INSTALL_SYSCONFDIR does respect CMAKE_INSTALL_PREFIX, but it prefixes it to CMAKE_INSTALL_SYSCONFDIR, which results in the default config being installed to /usr/etc/polybar/config.ini or /usr/local/etc/polybar/config.ini CMAKE_INSTALL_FULL_SYSCONFDIR gives an absolute path that respects the prefix but does the right thing (uses /etc) if it is /usr Ref: #2770 --- CHANGELOG.md | 3 ++- CMakeLists.txt | 11 +++++++++-- cmake/05-summary.cmake | 11 ++++++----- 3 files changed, 17 insertions(+), 8 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 62645e39..5703aaac 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,7 +15,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - If the `exec` command produced no output and exited with a non-zero exit code the module is no longer completely empty, but just has an empty `%output%` token. If you relied on this behavior to hide the module under certain circumstances, make sure the script exits with an exit code of zero. ([`#2857`](https://github.com/polybar/polybar/discussions/2857), [`#2861`](https://github.com/polybar/polybar/pull/2861)) ### Build -- Respect `CMAKE_INSTALL_PREFIX` when installing default config ([`#2770`](https://github.com/polybar/polybar/pull/2770)) +- Respect `CMAKE_INSTALL_PREFIX` when installing default config ([`#2770`](https://github.com/polybar/polybar/pull/2770), [`#2917`](https://github.com/polybar/polybar/pull/2917)) +- Change default `CMAKE_INSTALL_PREFIX` to `/usr`. Installations with default flags will now go into `/usr` instead of `/usr/local` ([`#2917`](https://github.com/polybar/polybar/pull/2917)) - Bump C++ version to C++17 ([`#2847`](https://github.com/polybar/polybar/pull/2847)) ### Deprecated diff --git a/CMakeLists.txt b/CMakeLists.txt index 0979f8af..acb58b6b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -22,6 +22,14 @@ else() set(APP_VERSION "${version_txt}") endif() +# Set the default installation prefix to /usr +# Otherwise the default value is /usr/local which causes the default config +# file to be installed to /usr/local/etc, with /usr, cmake has special handling +# for this. +if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT) + set(CMAKE_INSTALL_PREFIX "/usr" CACHE PATH "Project-default installation prefix" FORCE) +endif() + list(APPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake ${PROJECT_SOURCE_DIR}/cmake/common @@ -60,10 +68,9 @@ if(BUILD_TESTS) add_subdirectory(tests) endif() - if(BUILD_CONFIG) install(FILES ${CMAKE_SOURCE_DIR}/doc/config.ini - DESTINATION ${CMAKE_INSTALL_SYSCONFDIR}/${PROJECT_NAME} + DESTINATION ${CMAKE_INSTALL_FULL_SYSCONFDIR}/${PROJECT_NAME} COMPONENT config) endif() diff --git a/cmake/05-summary.cmake b/cmake/05-summary.cmake index 5f71936f..c649647d 100644 --- a/cmake/05-summary.cmake +++ b/cmake/05-summary.cmake @@ -13,11 +13,12 @@ if (BUILD_DOC) endif() message(STATUS " Install Paths:") -message_colored(STATUS " PREFIX: ${CMAKE_INSTALL_PREFIX}" "32") -message_colored(STATUS " BINDIR: ${CMAKE_INSTALL_FULL_BINDIR}" "32") -message_colored(STATUS " DATADIR: ${CMAKE_INSTALL_FULL_DATADIR}" "32") -message_colored(STATUS " DOCDIR: ${CMAKE_INSTALL_FULL_DOCDIR}" "32") -message_colored(STATUS " MANDIR: ${CMAKE_INSTALL_FULL_MANDIR}" "32") +message_colored(STATUS " PREFIX: ${CMAKE_INSTALL_PREFIX}" "32") +message_colored(STATUS " BINDIR: ${CMAKE_INSTALL_FULL_BINDIR}" "32") +message_colored(STATUS " DATADIR: ${CMAKE_INSTALL_FULL_DATADIR}" "32") +message_colored(STATUS " DOCDIR: ${CMAKE_INSTALL_FULL_DOCDIR}" "32") +message_colored(STATUS " MANDIR: ${CMAKE_INSTALL_FULL_MANDIR}" "32") +message_colored(STATUS " SYSCONFDIR: ${CMAKE_INSTALL_FULL_SYSCONFDIR}" "32") message(STATUS " Targets:") colored_option(" polybar" BUILD_POLYBAR)