From bddb8740342af6615d6df15587e18b05f0a73108 Mon Sep 17 00:00:00 2001 From: Thomas Lauf Date: Tue, 8 Aug 2023 22:12:32 +0200 Subject: [PATCH] Improve configurability of CMake install directories Make installation of man pages configurable per section Use configuration variable TIMEW_BINDIR Update documentation Closes #553 Signed-off-by: Thomas Lauf --- AUTHORS | 1 + CMakeLists.txt | 21 ++++++++++--------- ChangeLog | 2 ++ INSTALL | 42 ++++++++++++++++--------------------- doc/holidays/CMakeLists.txt | 6 +++--- doc/man1/CMakeLists.txt | 4 +--- doc/man7/CMakeLists.txt | 4 +--- doc/themes/CMakeLists.txt | 10 ++++----- src/CMakeLists.txt | 2 +- 9 files changed, 43 insertions(+), 49 deletions(-) diff --git a/AUTHORS b/AUTHORS index 3f0aba22..440126e2 100644 --- a/AUTHORS +++ b/AUTHORS @@ -117,3 +117,4 @@ Thanks to the following, who submitted detailed bug reports and excellent sugges apkawel Leon Grünewald Ivo Forlin + aMOPel diff --git a/CMakeLists.txt b/CMakeLists.txt index 4becb45a..62c02916 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -32,17 +32,18 @@ set (PACKAGE_STRING "${PACKAGE} ${VERSION}") string (TIMESTAMP PACKAGE_DATE "%Y-%m-%d") if (FREEBSD OR DRAGONFLY) -set (TIMEW_MANDIR man CACHE STRING "Installation directory for man pages") -set (TIMEW_MAN1DIR man/man1 CACHE STRING "Installation directory for man pages, section 1") -set (TIMEW_MAN5DIR man/man5 CACHE STRING "Installation directory for man pages, section 5") -set (TIMEW_MAN7DIR man/man7 CACHE STRING "Installation directory for man pages, section 7") + set (TIMEW_MANDIR man CACHE STRING "Installation directory for man pages") + set (TIMEW_MAN1DIR ${TIMEW_MANDIR}/man1 CACHE STRING "Installation directory for man pages, section 1") + set (TIMEW_MAN5DIR ${TIMEW_MANDIR}/man5 CACHE STRING "Installation directory for man pages, section 5") + set (TIMEW_MAN7DIR ${TIMEW_MANDIR}/man7 CACHE STRING "Installation directory for man pages, section 7") else (FREEBSD OR DRAGONFLY) -set (TIMEW_MANDIR share/man CACHE STRING "Installation directory for man pages") -set (TIMEW_MAN1DIR share/man/man1 CACHE STRING "Installation directory for man pages, section 1") -set (TIMEW_MAN5DIR share/man/man5 CACHE STRING "Installation directory for man pages, section 5") -set (TIMEW_MAN7DIR share/man/man7 CACHE STRING "Installation directory for man pages, section 7") + set (TIMEW_MANDIR share/man CACHE STRING "Installation directory for man pages") + set (TIMEW_MAN1DIR ${TIMEW_MANDIR}/man1 CACHE STRING "Installation directory for man pages, section 1") + set (TIMEW_MAN5DIR ${TIMEW_MANDIR}/man5 CACHE STRING "Installation directory for man pages, section 5") + set (TIMEW_MAN7DIR ${TIMEW_MANDIR}/man7 CACHE STRING "Installation directory for man pages, section 7") endif (FREEBSD OR DRAGONFLY) -set (TIMEW_DOCDIR share/doc/timew CACHE STRING "Installation directory for doc files") +set (TIMEW_DOCDIR share/doc/timew CACHE STRING "Installation directory for doc files") +set (TIMEW_BINDIR bin CACHE STRING "Installation directory for Timewarrior executable") message ("-- Configuring cmake.h") configure_file (${CMAKE_SOURCE_DIR}/cmake.h.in @@ -58,7 +59,7 @@ endif (EXISTS ${CMAKE_SOURCE_DIR}/test) set (doc_FILES ChangeLog README.md INSTALL AUTHORS LICENSE) foreach (doc_FILE ${doc_FILES}) - install (FILES ${doc_FILE} DESTINATION ${TIMEW_DOCDIR}) + install (FILES ${doc_FILE} DESTINATION ${TIMEW_DOCDIR}) endforeach (doc_FILE) # --- diff --git a/ChangeLog b/ChangeLog index d4fc536b..4c240c58 100644 --- a/ChangeLog +++ b/ChangeLog @@ -14,6 +14,8 @@ (thanks to Iúri Archer) - #552 Extend XDG support to macOS (thanks to Tadeas Uhlir) +- #553 Configurability of CMake install directories + (thanks to aMOPel) - #554 Update documentation for command 'retag' (thanks to quazgar) - Use local man pages in tests diff --git a/INSTALL b/INSTALL index 9f0adb15..7e0abfc3 100644 --- a/INSTALL +++ b/INSTALL @@ -48,41 +48,35 @@ These commands are explained below: # Build and configurations options You can customize the configuration run with CMake variables. -This will modify the installation process: - -To change the installation directory you use the following configuration variable: - - $ cmake -DCMAKE_INSTALL_PREFIX= . - -CMake configuration variables are applied with the -D option and consist of a and a : +CMake configuration variables are applied with the `-D` option and consist of a `` and a ``: $ cmake -D= . +To change the installation directory, use the `CMAKE_INSTALL_PREFIX` variable: + + $ cmake -DCMAKE_INSTALL_PREFIX= . + +This variable defaults to `/usr/local` on UNIX/Linux systems. + Five more variables can customize the installation process. -The following table lists them and their defaults plus the `CMAKE_INSTALL_PREFIX`: +The following table lists them and their default values: - CMAKE_INSTALL_PREFIX /usr/local - TIMEW_BINDIR bin - TIMEW_DOCDIR share/doc/timew - TIMEW_MAN1DIR share/man/man1 - TIMEW_MAN5DIR share/man/man5 - TIMEW_MAN7DIR share/man/man7 +| Variable | Default Value | +|-----------------|-------------------| +| `TIMEW_BINDIR` | `bin` | +| `TIMEW_DOCDIR` | `share/doc/timew` | +| `TIMEW_MANDIR` | `share/man` | +| `TIMEW_MAN1DIR` | `share/man/man1` | +| `TIMEW_MAN7DIR` | `share/man/man7` | -The corresponding `TIMEW_*` variables will be combined with `CMAKE_INSTALL_PREFIX` to get absolute installation directories: +On FreeBSD or DragonFly BSD systems, the `share/` directory is omitted for the `TIMEW_MAN*DIR` variables. - CMAKE_INSTALL_PREFIX/TIMEW_BINDIR /usr/local/bin - CMAKE_INSTALL_PREFIX/TIMEW_DOCDIR /usr/local/share/doc/timew - CMAKE_INSTALL_PREFIX/TIMEW_MAN1DIR /usr/local/share/man/man1 - CMAKE_INSTALL_PREFIX/TIMEW_MAN5DIR /usr/local/share/man/man5 - CMAKE_INSTALL_PREFIX/TIMEW_MAN7DIR /usr/local/share/man/man7 +The `TIMEW_*` variables are combined with the value of `CMAKE_INSTALL_PREFIX` to get the absolute paths. # Updating Timewarrior build -This section concerns itself with the description of the procedure needed to update the local Timewarrior build from the 'timew' Git repository. - -To update the local Timewarrior build, you need to update the Git repository, including the `src/libshared` submodule. -To do that, run: +To update the local Timewarrior build, you need to update the Git repository, including the `src/libshared` submodule, run: $ git pull --recurse-submodules $ git submodule update diff --git a/doc/holidays/CMakeLists.txt b/doc/holidays/CMakeLists.txt index 182fe606..daffa3b2 100644 --- a/doc/holidays/CMakeLists.txt +++ b/doc/holidays/CMakeLists.txt @@ -2,6 +2,6 @@ cmake_minimum_required (VERSION 3.8) message ("-- Configuring holiday documentation") -install (FILES README DESTINATION ${TIMEW_DOCDIR}/doc/holidays) -install (FILES holidays.en-US DESTINATION ${TIMEW_DOCDIR}/doc/holidays) -install (FILES refresh DESTINATION ${TIMEW_DOCDIR}/doc/holidays) +install (FILES README DESTINATION ${TIMEW_DOCDIR}/holidays) +install (FILES holidays.en-US DESTINATION ${TIMEW_DOCDIR}/holidays) +install (FILES refresh DESTINATION ${TIMEW_DOCDIR}/holidays) diff --git a/doc/man1/CMakeLists.txt b/doc/man1/CMakeLists.txt index 8d710d3d..83382d5a 100644 --- a/doc/man1/CMakeLists.txt +++ b/doc/man1/CMakeLists.txt @@ -16,6 +16,4 @@ endforeach (SRC) add_custom_target (man1 DEPENDS ${DOC_FILES}) -install (DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} - DESTINATION ${TIMEW_MANDIR} - FILES_MATCHING PATTERN "*.1") +install (FILES ${DOC_FILES} DESTINATION ${TIMEW_MAN1DIR}) diff --git a/doc/man7/CMakeLists.txt b/doc/man7/CMakeLists.txt index 74b482e3..0ffcd6bf 100644 --- a/doc/man7/CMakeLists.txt +++ b/doc/man7/CMakeLists.txt @@ -16,6 +16,4 @@ endforeach (SRC) add_custom_target (man7 DEPENDS ${DOC_FILES}) -install (DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} - DESTINATION ${TIMEW_MANDIR} - FILES_MATCHING PATTERN "*.7") +install (FILES ${DOC_FILES} DESTINATION ${TIMEW_MAN7DIR}) diff --git a/doc/themes/CMakeLists.txt b/doc/themes/CMakeLists.txt index cb94d223..db438276 100644 --- a/doc/themes/CMakeLists.txt +++ b/doc/themes/CMakeLists.txt @@ -2,8 +2,8 @@ cmake_minimum_required (VERSION 3.8) message ("-- Configuring theme documentation") -install (FILES README DESTINATION ${TIMEW_DOCDIR}/doc/themes) -install (FILES dark.theme DESTINATION ${TIMEW_DOCDIR}/doc/themes) -install (FILES dark_blue.theme DESTINATION ${TIMEW_DOCDIR}/doc/themes) -install (FILES dark_green.theme DESTINATION ${TIMEW_DOCDIR}/doc/themes) -install (FILES dark_red.theme DESTINATION ${TIMEW_DOCDIR}/doc/themes) +install (FILES README DESTINATION ${TIMEW_DOCDIR}/themes) +install (FILES dark.theme DESTINATION ${TIMEW_DOCDIR}/themes) +install (FILES dark_blue.theme DESTINATION ${TIMEW_DOCDIR}/themes) +install (FILES dark_green.theme DESTINATION ${TIMEW_DOCDIR}/themes) +install (FILES dark_red.theme DESTINATION ${TIMEW_DOCDIR}/themes) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 54737c58..21e7aabc 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -71,4 +71,4 @@ target_link_libraries (lex_executable timew libshared libshared set_property (TARGET timew_executable PROPERTY OUTPUT_NAME "timew") set_property (TARGET lex_executable PROPERTY OUTPUT_NAME "lex") -install (TARGETS timew_executable DESTINATION bin) +install (TARGETS timew_executable DESTINATION ${TIMEW_BINDIR})