# HG changeset patch # User David Demelier # Date 1530953959 -7200 # Node ID 1b04ffb2b35e8e6e4305f99b855254af0376f9c7 # Parent 0dd4fb9dfcc82a0548f71f1aaa5699a22598235b CMake: switch to GNUInstallDirs, closes #873 @1h diff -r 0dd4fb9dfcc8 -r 1b04ffb2b35e CMakeLists.txt --- a/CMakeLists.txt Sat Jul 07 09:21:10 2018 +0200 +++ b/CMakeLists.txt Sat Jul 07 10:59:19 2018 +0200 @@ -66,6 +66,7 @@ set_property(GLOBAL PROPERTY USE_FOLDERS On) include(CMakeParseArguments) +include(GNUInstallDirs) include(cmake/function/IrccdBuildHtml.cmake) include(cmake/function/IrccdDefineExecutable.cmake) diff -r 0dd4fb9dfcc8 -r 1b04ffb2b35e MIGRATING.md --- a/MIGRATING.md Sat Jul 07 09:21:10 2018 +0200 +++ b/MIGRATING.md Sat Jul 07 10:59:19 2018 +0200 @@ -29,12 +29,13 @@ - All options are now starting with `IRCCD_` for better compatibility with external projects, - - `IRCCD_WITH_CONFDIR` has been renamed to `IRCCD_WITH_SYSCONFDIR`. + - CMake now use GNUInstallDirs module to specify installation paths, all + IRCCD_WITH_ options have been replaced by CMAKE_INSTALL_ equivalents. ### Paths - The default plugins path has been changed from **share/irccd/plugins** to - **libexec/irccd/plugins**. + **lib64/irccd**. ### Javascript API diff -r 0dd4fb9dfcc8 -r 1b04ffb2b35e cmake/IrccdOptions.cmake --- a/cmake/IrccdOptions.cmake Sat Jul 07 09:21:10 2018 +0200 +++ b/cmake/IrccdOptions.cmake Sat Jul 07 10:59:19 2018 +0200 @@ -36,21 +36,6 @@ # defined automatically from the IRCCD_PLUGINS list. # -# -# Options that controls both installations and the irccd runtime: -# -# IRCCD_WITH_BINDIR Binary directory for irccd, irccdctl -# IRCCD_WITH_CACHEDIR Path where to store temporary files -# IRCCD_WITH_CMAKEDIR Path where to install CMake configuration files -# IRCCD_WITH_DATADIR Path for data files -# IRCCD_WITH_DOCDIR Path where to install documentation -# IRCCD_WITH_MANDIR Path where to install manuals -# IRCCD_WITH_PKGCONFIGDIR Path where to install pkg-config files -# IRCCD_WITH_PLUGINDIR Path where plugins must be installed -# IRCCD_WITH_SYSCONFDIR Path where to install configuration files -# IRCCD_WITH_SYSTEMDDIR Path where to install systemd unit file -# - # Manual pages on Windows are pretty useless. if (WIN32) set(DEFAULT_MAN "No") @@ -85,22 +70,6 @@ option(IRCCD_WITH_VERA "Enable vera++" On) # -# Installation paths. -# ------------------------------------------------------------------- -# - -set(IRCCD_WITH_BINDIR "bin" CACHE STRING "Binary directory") -set(IRCCD_WITH_CACHEDIR "var/cache/irccd" CACHE STRING "Cache directory") -set(IRCCD_WITH_CMAKEDIR "lib/cmake" CACHE STRING "Directory for CMake modules") -set(IRCCD_WITH_DATADIR "share/irccd" CACHE STRING "Directory for additional data") -set(IRCCD_WITH_DOCDIR "share/doc/irccd" CACHE STRING "Documentation directory") -set(IRCCD_WITH_MANDIR "share/man" CACHE STRING "Man directory") -set(IRCCD_WITH_PKGCONFIGDIR "lib/pkgconfig" CACHE STRING "Directory for pkg-config file") -set(IRCCD_WITH_PLUGINDIR "libexec/irccd/plugins" CACHE STRING "Module prefix where to install") -set(IRCCD_WITH_SYSCONFDIR "etc/irccd" CACHE STRING "Configuration directory") -set(IRCCD_WITH_SYSTEMDDIR "/usr/lib/systemd/system" CACHE STRING "Absolute path where to install systemd files") - -# # Internal dependencies. # ------------------------------------------------------------------- # diff -r 0dd4fb9dfcc8 -r 1b04ffb2b35e cmake/function/IrccdBuildHtml.cmake --- a/cmake/function/IrccdBuildHtml.cmake Sat Jul 07 09:21:10 2018 +0200 +++ b/cmake/function/IrccdBuildHtml.cmake Sat Jul 07 10:59:19 2018 +0200 @@ -129,7 +129,7 @@ install( FILES ${output} COMPONENT ${HTML_COMPONENT} - DESTINATION ${IRCCD_WITH_DOCDIR}/${dirname} + DESTINATION ${CMAKE_INSTALL_DOCDIR}/${dirname} ) endif () diff -r 0dd4fb9dfcc8 -r 1b04ffb2b35e cmake/function/IrccdDefineExecutable.cmake --- a/cmake/function/IrccdDefineExecutable.cmake Sat Jul 07 09:21:10 2018 +0200 +++ b/cmake/function/IrccdDefineExecutable.cmake Sat Jul 07 10:59:19 2018 +0200 @@ -74,7 +74,7 @@ install( TARGETS ${EXE_TARGET} COMPONENT ${EXE_TARGET} - RUNTIME DESTINATION ${IRCCD_WITH_BINDIR} + RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} ) # Put the application into a cpack group. diff -r 0dd4fb9dfcc8 -r 1b04ffb2b35e cmake/function/IrccdDefineMan.cmake --- a/cmake/function/IrccdDefineMan.cmake Sat Jul 07 09:21:10 2018 +0200 +++ b/cmake/function/IrccdDefineMan.cmake Sat Jul 07 10:59:19 2018 +0200 @@ -34,6 +34,6 @@ set(input ${doc_SOURCE_DIR}/man/${file}.in) set(output ${CMAKE_CURRENT_BINARY_DIR}/${file}) configure_file(${input} ${output} @ONLY) - install(FILES ${output} DESTINATION ${IRCCD_WITH_MANDIR}/${man}) + install(FILES ${output} DESTINATION ${CMAKE_INSTALL_MANDIR}/${man}) endif () endfunction() diff -r 0dd4fb9dfcc8 -r 1b04ffb2b35e cmake/function/IrccdDefinePlugin.cmake --- a/cmake/function/IrccdDefinePlugin.cmake Sat Jul 07 09:21:10 2018 +0200 +++ b/cmake/function/IrccdDefinePlugin.cmake Sat Jul 07 10:59:19 2018 +0200 @@ -65,7 +65,7 @@ install( FILES ${CMAKE_CURRENT_BINARY_DIR}/${name} COMPONENT ${PLG_NAME} - DESTINATION ${IRCCD_WITH_PLUGINDIR} + DESTINATION ${CMAKE_INSTALL_LIBDIR}/irccd ) add_custom_target( @@ -104,7 +104,7 @@ install( TARGETS plugin-${PLG_NAME} COMPONENT ${PLG_NAME} - LIBRARY DESTINATION ${IRCCD_WITH_PLUGINDIR} + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}/irccd ) endfunction() diff -r 0dd4fb9dfcc8 -r 1b04ffb2b35e cmake/internal/sysconfig.hpp.in --- a/cmake/internal/sysconfig.hpp.in Sat Jul 07 09:21:10 2018 +0200 +++ b/cmake/internal/sysconfig.hpp.in Sat Jul 07 10:59:19 2018 +0200 @@ -39,8 +39,6 @@ * ------------------------------------------------------------------ */ -#define PREFIX "@CMAKE_INSTALL_PREFIX@" - #define IRCCD_VERSION_MAJOR @IRCCD_VERSION_MAJOR@ #define IRCCD_VERSION_MINOR @IRCCD_VERSION_MINOR@ #define IRCCD_VERSION_PATCH @IRCCD_VERSION_PATCH@ @@ -52,11 +50,12 @@ * ------------------------------------------------------------------ */ -#define IRCCD_WITH_CACHEDIR "@IRCCD_WITH_CACHEDIR@" -#define IRCCD_WITH_DATADIR "@IRCCD_WITH_DATADIR@" -#define IRCCD_WITH_BINDIR "@IRCCD_WITH_BINDIR@" -#define IRCCD_WITH_SYSCONFDIR "@IRCCD_WITH_SYSCONFDIR@" -#define IRCCD_WITH_PLUGINDIR "@IRCCD_WITH_PLUGINDIR@" +#define CMAKE_INSTALL_PREFIX "@CMAKE_INSTALL_PREFIX@" +#define CMAKE_INSTALL_LOCALSTATEDIR "@CMAKE_INSTALL_LOCALSTATEDIR@" +#define CMAKE_INSTALL_DATADIR "@CMAKE_INSTALL_DATADIR@" +#define CMAKE_INSTALL_BINDIR "@CMAKE_INSTALL_BINDIR@" +#define CMAKE_INSTALL_LIBDIR "@CMAKE_INSTALL_LIBDIR@" +#define CMAKE_INSTALL_SYSCONFDIR "@CMAKE_INSTALL_SYSCONFDIR@" #cmakedefine IRCCD_HAVE_JS #cmakedefine IRCCD_HAVE_SSL diff -r 0dd4fb9dfcc8 -r 1b04ffb2b35e doc/examples/CMakeLists.txt --- a/doc/examples/CMakeLists.txt Sat Jul 07 09:21:10 2018 +0200 +++ b/doc/examples/CMakeLists.txt Sat Jul 07 10:59:19 2018 +0200 @@ -33,7 +33,7 @@ ${examples_SOURCE_DIR}/irccd.conf.sample ${examples_SOURCE_DIR}/irccdctl.conf.sample COMPONENT examples - DESTINATION ${IRCCD_WITH_SYSCONFDIR} + DESTINATION ${CMAKE_INSTALL_SYSCONFDIR} ) setg(CPACK_COMPONENT_EXAMPLES_HIDDEN On) diff -r 0dd4fb9dfcc8 -r 1b04ffb2b35e doc/src/irccd.md --- a/doc/src/irccd.md Sat Jul 07 09:21:10 2018 +0200 +++ b/doc/src/irccd.md Sat Jul 07 10:59:19 2018 +0200 @@ -33,17 +33,17 @@ files. For example, the files `irccd.conf` and `irccdctl.conf` will be searched there. - - \(W) `%APPDATA%/irccd/config` - - \(U) `${XDG_CONFIG_HOME}/irccd` - - \(U) `${HOME}/.config/irccd` (if `XDG_CONFIG_HOME` is not set) - - `installation-directory/etc` + - \(W) %APPDATA%/irccd/config + - \(U) ${XDG\_CONFIG\_HOME}/irccd + - \(U) ${HOME}/.config/irccd (if XDG\_CONFIG\_HOME is not set) + - CMAKE\_INSTALL\_SYSCONFDIR/irccd Examples: - - `/home/john/.config/irccd/irccd.conf` - - `/usr/local/etc/irccd.conf` - - `C:/Program Files/irccd/etc/irccd.conf` - - `C:/Users/john/AppData/irccd/config` + - /home/john/.config/irccd/irccd.conf + - /usr/local/etc/irccd.conf + - C:/Program Files/irccd/etc/irccd/irccd.conf + - C:/Users/john/AppData/irccd/config # Plugins @@ -51,18 +51,17 @@ are not specified by full paths. - current working directory - - \(W) `%APPDATA%/irccd/share/plugins` - - \(U) `${XDG_DATA_HOME}/irccd/plugins` - - \(U) `${HOME}/.local/share/irccd/plugins` (if `XDG_DATA_HOME` is not set) - - \(W) `installation-directory/share/plugins` - - \(U) `installation-directory/share/irccd/plugins` + - \(W) %APPDATA%/irccd/share/plugins + - \(U) ${XDG\_DATA\_HOME}/irccd/plugins + - \(U) ${HOME}/.local/share/irccd/plugins (if XDG\_DATA\_HOME is not set) + - CMAKE\_INSTALL\_LIBDIR/irccd (both native and Javascript) Examples: - - `/home/john/.local/share/irccd/plugins/ask.js` - - `/usr/local/share/irccd/plugins/ask.js` - - `C:/Users/john/AppDAta/irccd/share/plugins/ask.js` - - `C:/Program Files/irccd/share/plugins/ask.js` + - /home/john/.local/share/irccd/plugins/ask.js + - /usr/local/lib/irccd/plugins/ask.js + - C:/Users/john/AppData/irccd/share/plugins/ask.js + - C:/Program Files/irccd/lib/irccd/plugins/ask.js # Templates and formatting diff -r 0dd4fb9dfcc8 -r 1b04ffb2b35e libcommon/irccd/system.cpp --- a/libcommon/irccd/system.cpp Sat Jul 07 09:21:10 2018 +0200 +++ b/libcommon/irccd/system.cpp Sat Jul 07 10:59:19 2018 +0200 @@ -50,14 +50,6 @@ # include #endif -#if defined(HAVE_SETGID) -# include -#endif - -#if defined(HAVE_SETGID) -# include -#endif - #if defined(HAVE_GETLOGIN) # include #endif @@ -87,8 +79,8 @@ */ boost::filesystem::path base_directory() { - static const boost::filesystem::path bindir(IRCCD_WITH_BINDIR); - static const boost::filesystem::path prefix(PREFIX); + static const boost::filesystem::path bindir(CMAKE_INSTALL_BINDIR); + static const boost::filesystem::path prefix(CMAKE_INSTALL_PREFIX); boost::filesystem::path path("."); @@ -121,16 +113,13 @@ * * Compute the system directory path for the given component. * - * Use with the build options like IRCCD_WITH_CACHEDIR, IRCCD_WITH_PLUGINDIR, - * ... - * * Referenced by: * - cachedir, * - datadir, * - sysconfigdir, * - plugindir. */ -std::string system_directory(const std::string& component) +boost::filesystem::path system_directory(const std::string& component) { boost::filesystem::path path(component); @@ -425,7 +414,7 @@ boost::filesystem::path cachedir() { - return system_directory(IRCCD_WITH_CACHEDIR); + return system_directory(CMAKE_INSTALL_LOCALSTATEDIR) / "cache/irccd"; } // }}} @@ -434,7 +423,7 @@ boost::filesystem::path datadir() { - return system_directory(IRCCD_WITH_DATADIR); + return system_directory(CMAKE_INSTALL_DATADIR); } // }}} @@ -443,7 +432,7 @@ boost::filesystem::path sysconfdir() { - return system_directory(IRCCD_WITH_SYSCONFDIR); + return system_directory(CMAKE_INSTALL_SYSCONFDIR) / "irccd"; } // }}} @@ -452,7 +441,7 @@ boost::filesystem::path plugindir() { - return system_directory(IRCCD_WITH_PLUGINDIR); + return system_directory(CMAKE_INSTALL_LIBDIR) / "irccd"; } // }}} diff -r 0dd4fb9dfcc8 -r 1b04ffb2b35e libcommon/irccd/system.hpp --- a/libcommon/irccd/system.hpp Sat Jul 07 09:21:10 2018 +0200 +++ b/libcommon/irccd/system.hpp Sat Jul 07 10:59:19 2018 +0200 @@ -91,7 +91,7 @@ /** * Get the cache directory as specified as compile time option - * IRCCD_WITH_CACHEDIR, if the value is absolute, it is returned as-is. + * CMAKE_INSTALL_LOCALSTATEDIR, if the value is absolute, it is returned as-is. * * If the component is relative, it is evaluated using the binary executable * path. @@ -103,7 +103,7 @@ boost::filesystem::path cachedir(); /** - * Like cachedir but for IRCCD_WITH_DATADIR. + * Like cachedir but for CMAKE_INSTALL_DATADIR. * * \return the evaluated data directory. * \see cachedir @@ -112,7 +112,7 @@ boost::filesystem::path datadir(); /** - * Like cachedir but for IRCCD_WITH_SYSCONFIGDIR. + * Like cachedir but for CMAKE_INSTALL_SYSCONFDIR. * * \return the evaluated config directory. * \see cachedir @@ -122,7 +122,7 @@ boost::filesystem::path sysconfdir(); /** - * Like cachedir but for IRCCD_WITH_PLUGINDIR. + * Like cachedir but for CMAKE_INSTALL_LIBDIR. * * \return the evaluated system plugin directory. * \see cachedir diff -r 0dd4fb9dfcc8 -r 1b04ffb2b35e systemd/CMakeLists.txt --- a/systemd/CMakeLists.txt Sat Jul 07 09:21:10 2018 +0200 +++ b/systemd/CMakeLists.txt Sat Jul 07 10:59:19 2018 +0200 @@ -19,7 +19,7 @@ project(contrib) if (IRCCD_WITH_SYSTEMD) - set(PATH "${CMAKE_INSTALL_PREFIX}/${IRCCD_WITH_BINDIR}/irccd") + set(PATH "${CMAKE_INSTALL_FULL_BINDIR}/irccd") configure_file( ${CMAKE_CURRENT_SOURCE_DIR}/irccd.service @@ -28,6 +28,6 @@ install( FILES ${CMAKE_CURRENT_BINARY_DIR}/irccd.service - DESTINATION ${IRCCD_WITH_SYSTEMDDIR} + DESTINATION "/usr/lib/systemd/system" ) endif()