# HG changeset patch # User David Demelier # Date 1634738533 -7200 # Node ID 8c53096eef1ed3304855150259d5a059e62d7c1a # Parent 2519760439863705033ccc22acbac587372b3252 cmake: add pkg-config file support diff -r 251976043986 -r 8c53096eef1e CMakeLists.txt --- a/CMakeLists.txt Wed Oct 20 15:54:07 2021 +0200 +++ b/CMakeLists.txt Wed Oct 20 16:02:13 2021 +0200 @@ -52,20 +52,23 @@ set(CMAKE_C_FLAGS "-Wall -Wextra -pedantic ${CMAKE_C_FLAGS}") endif () +include(GNUInstallDirs) + option(IRCCD_WITH_EXAMPLES "Enable example files" On) option(IRCCD_WITH_JS "Enable Javascript" On) option(IRCCD_WITH_MAN "Enable manual pages" On) option(IRCCD_WITH_SSL "Enable SSL (requires OpenSSL)" On) option(IRCCD_WITH_TESTS "Enable unit tests" On) +option(IRCCD_WITH_PKGCONFIG "Enable installation of pkg-config file" On) set(IRCCD_WITH_UID "irccd" CACHE STRING "Default uid to run irccd as") set(IRCCD_WITH_GID "irccd" CACHE STRING "Default gid to run irccd as") +set(IRCCD_WITH_PKGCONFIGDIR "${CMAKE_INSTALL_LIBDIR}/pkgconfig" + CACHE STRING "Directory for pkg-config files") # Check presence of POSIX m library find_library(M_LIBRARY m libm) -include(GNUInstallDirs) - include(cmake/IrccdDefinePlugin.cmake) if (IRCCD_WITH_SSL) diff -r 251976043986 -r 8c53096eef1e INSTALL.md --- a/INSTALL.md Wed Oct 20 15:54:07 2021 +0200 +++ b/INSTALL.md Wed Oct 20 16:02:13 2021 +0200 @@ -46,13 +46,15 @@ The following options are available: -- `IRCCD_WITH_MAN`: disable installation of manpages. -- `IRCCD_WITH_JS`: disable Javascript support (and all Javascript plugins). -- `IRCCD_WITH_SSL`: disable OpenSSL support. -- `IRCCD_WITH_TESTS`: disable building of tests. -- `IRCCD_WITH_EXAMPLES`: disable plugin templates. +- `IRCCD_WITH_MAN`: installation of manpages. +- `IRCCD_WITH_JS`: Javascript support (and all Javascript plugins). +- `IRCCD_WITH_SSL`: OpenSSL support. +- `IRCCD_WITH_TESTS`: building of tests. +- `IRCCD_WITH_EXAMPLES`: plugin templates. +- `IRCCD_WITH_PKGCONFIG`: pkg-config file installation. +- `IRCCD_WITH_PKGCONFIGDIR`: path to pkg-config directory installation. -The following options control installation directories. +The following standard CMake options control installation directories. - `CMAKE_INSTALL_PREFIX`: root directory for installing (default: /usr/local). - `CMAKE_INSTALL_BINDIR`: binaries (default: ${CMAKE_INSTALL_PREFIX}/bin). diff -r 251976043986 -r 8c53096eef1e lib/CMakeLists.txt --- a/lib/CMakeLists.txt Wed Oct 20 15:54:07 2021 +0200 +++ b/lib/CMakeLists.txt Wed Oct 20 16:02:13 2021 +0200 @@ -77,6 +77,16 @@ if (IRCCD_WITH_SSL) target_link_libraries(libirccd PUBLIC OpenSSL::SSL OpenSSL::Crypto) endif () +if (IRCCD_WITH_PKGCONFIG) + configure_file( + ${libirccd_SOURCE_DIR}/irccd.pc.in + ${libirccd_BINARY_DIR}/irccd.pc + ) + install( + FILES ${libirccd_BINARY_DIR}/irccd.pc + DESTINATION ${IRCCD_WITH_PKGCONFIGDIR} + ) +endif () source_group(extern/libbsd FILES ${LIBBSD_SOURCES}) source_group(irccd FILES ${SOURCES}) diff -r 251976043986 -r 8c53096eef1e lib/irccd.pc.in --- a/lib/irccd.pc.in Wed Oct 20 15:54:07 2021 +0200 +++ b/lib/irccd.pc.in Wed Oct 20 16:02:13 2021 +0200 @@ -1,5 +1,4 @@ Name: irccd Description: Native C interface for irccd plugins -Version: @MAJOR@.@MINOR@.@PATCH@ -Cflags: -I@INCDIR@ -Libs: @SHFLAGS@ +Version: @irccd_VERSION_MAJOR@.@irccd_VERSION_MINOR@.@irccd_VERSION_PATCH@ +Cflags: -I@CMAKE_INSTALL_FULL_INCLUDEDIR@