From a57a38017ab0266eb40d7c72a6d9ee35d8e00bcd Mon Sep 17 00:00:00 2001 From: Paul Emsley Date: Mon, 24 Aug 2026 20:27:16 +0100 Subject: [PATCH] Install gemmi.pc - to help with pkgconfig use Install a gemmi.pc pkg-config file for autotools, meson, bazel and plain-Makefile consumers. Used by Coot and maybe other downstream projects. The version string has any -dev/+build tail stripped, since pkg-config rejects non-numeric version characters. Co-Authored-By: Claude Fable 5 --- CMakeLists.txt | 12 ++++++++++++ tools/gemmi.pc.in | 13 +++++++++++++ 2 files changed, 25 insertions(+) create mode 100644 tools/gemmi.pc.in diff --git a/CMakeLists.txt b/CMakeLists.txt index 54e1a4fd6..2d207df67 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -574,6 +574,16 @@ write_basic_package_version_file(gemmi-config-version.cmake VERSION ${PROJECT_VERSION} COMPATIBILITY AnyNewerVersion) +# pkg-config — for autotools, meson, bazel, and plain-Makefile consumers. +# Strip a "-dev" / "+build" tail off the version because pkg-config rejects +# non-numeric characters per its spec. +string(REGEX REPLACE "[-+].*$" "" GEMMI_VERSION_PC "${PROJECT_VERSION}") +# Optional private deps go in Requires.private so static linking works +# without leaking them onto the consumer's compile line for the dynamic case. +set(GEMMI_PC_REQUIRES_PRIVATE "") +configure_file(tools/gemmi.pc.in + "${CMAKE_CURRENT_BINARY_DIR}/gemmi.pc" @ONLY) + if (BUILD_GEMMI_PROGRAM) # Is it useful to have the program location in gemmi-targets.cmake? install(TARGETS gemmi_prog EXPORT GemmiTargets) @@ -589,6 +599,8 @@ if (INSTALL_DEV_FILES) "${CMAKE_CURRENT_BINARY_DIR}/gemmi-config.cmake" "${CMAKE_CURRENT_BINARY_DIR}/gemmi-config-version.cmake" DESTINATION "${GEMMI_INSTALL_CMAKEDIR}") + install(FILES "${CMAKE_CURRENT_BINARY_DIR}/gemmi.pc" + DESTINATION "${CMAKE_INSTALL_LIBDIR}/pkgconfig") elseif (BUILD_SHARED_LIBS AND BUILD_GEMMI_PROGRAM) install(TARGETS gemmi_cpp) endif() diff --git a/tools/gemmi.pc.in b/tools/gemmi.pc.in new file mode 100644 index 000000000..7ac14b7c9 --- /dev/null +++ b/tools/gemmi.pc.in @@ -0,0 +1,13 @@ +prefix=@CMAKE_INSTALL_PREFIX@ +exec_prefix=${prefix} +includedir=${prefix}/@CMAKE_INSTALL_INCLUDEDIR@ +libdir=${prefix}/@CMAKE_INSTALL_LIBDIR@ + +Name: gemmi +Description: Macromolecular crystallography library +URL: https://gemmi.readthedocs.io/ +Version: @GEMMI_VERSION_PC@ +Requires: zlib +@GEMMI_PC_REQUIRES_PRIVATE@ +Libs: -L${libdir} -lgemmi_cpp +Cflags: -I${includedir}