Skip to content

Commit

Permalink
Add generation of registry file for pkg-config (#151)
Browse files Browse the repository at this point in the history
  • Loading branch information
rherilier authored Sep 29, 2024
1 parent b326963 commit fe1a60b
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
7 changes: 7 additions & 0 deletions .pkg-config/taocpp-json.pc.in
Original file line number Diff line number Diff line change
@@ -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}
14 changes: 13 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)

Expand All @@ -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}
Expand Down

0 comments on commit fe1a60b

Please sign in to comment.