From 54d34416617c63a6181bf51b816cc656783a23d9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20H=C3=A9rilier?= Date: Thu, 19 Sep 2024 20:16:18 +0200 Subject: [PATCH] Add generation of registry file for pkg-config --- .pkg-config/taocpp-json.pc.in | 7 +++++++ CMakeLists.txt | 14 +++++++++++++- 2 files changed, 20 insertions(+), 1 deletion(-) create mode 100644 .pkg-config/taocpp-json.pc.in diff --git a/.pkg-config/taocpp-json.pc.in b/.pkg-config/taocpp-json.pc.in new file mode 100644 index 00000000..7a7cdf82 --- /dev/null +++ b/.pkg-config/taocpp-json.pc.in @@ -0,0 +1,7 @@ +includedir="@CMAKE_INSTALL_FULL_INCLUDEDIR@" + +Name: @PROJECT_NAME@ +Description: taoJSON is a C++ header-only JSON library +Version: @PROJECT_VERSION@ +URL: https://github.com/taocpp/json +Cflags: -I${includedir} diff --git a/CMakeLists.txt b/CMakeLists.txt index 65e2dcfe..0a753591 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -12,6 +12,7 @@ include(GNUInstallDirs) set(TAOCPP_JSON_INSTALL_DOC_DIR "${CMAKE_INSTALL_DOCDIR}/tao/json" CACHE STRING "The installation doc directory") set(TAOCPP_JSON_INSTALL_CMAKE_DIR "${CMAKE_INSTALL_DATAROOTDIR}/${PROJECT_NAME}/cmake" CACHE STRING "The installation cmake directory") +set(TAOCPP_JSON_INSTALL_PKGCONFIG_DIR "${CMAKE_INSTALL_DATAROOTDIR}/pkgconfig" CACHE STRING "The installation pkgconfig directory") # define a header-only library add_library(taocpp-json INTERFACE) @@ -61,13 +62,20 @@ option(TAOCPP_JSON_INSTALL "Generate the install target" ${TAOCPP_JSON_IS_MAIN_P if(TAOCPP_JSON_INSTALL) include(CMakePackageConfigHelpers) - # Make package findable + # Make package findable by CMake configure_package_config_file(.cmake/taocpp-json-config.cmake.in ${PROJECT_NAME}-config.cmake INSTALL_DESTINATION ${TAOCPP_JSON_INSTALL_CMAKE_DIR} NO_CHECK_REQUIRED_COMPONENTS_MACRO NO_SET_AND_CHECK_MACRO ) + # Make package findable by pkg-config + configure_package_config_file(.pkg-config/taocpp-json.pc.in ${PROJECT_NAME}.pc + INSTALL_DESTINATION ${TAOCPP_JSON_INSTALL_PKGCONFIG_DIR} + NO_CHECK_REQUIRED_COMPONENTS_MACRO + NO_SET_AND_CHECK_MACRO + ) + # Ignore pointer width differences since this is a header-only library unset(CMAKE_SIZEOF_VOID_P) @@ -84,6 +92,10 @@ if(TAOCPP_JSON_INSTALL) ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}-config-version.cmake DESTINATION ${TAOCPP_JSON_INSTALL_CMAKE_DIR} ) + install(FILES + ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}.pc + DESTINATION ${TAOCPP_JSON_INSTALL_PKGCONFIG_DIR} + ) install(EXPORT ${PROJECT_NAME}-targets NAMESPACE taocpp:: DESTINATION ${TAOCPP_JSON_INSTALL_CMAKE_DIR}