Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add generation of registry file for pkg-config #151

Merged
merged 1 commit into from
Sep 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading