Unidata / UDUNITS-2

API and utility for arithmetic manipulation of units of physical quantities
http://www.unidata.ucar.edu/software/udunits
Other
59 stars 36 forks source link

Please add udunits.pc to support pkg-config #118

Closed ckhroulev closed 7 months ago

ckhroulev commented 7 months ago

2.2.28 and earlier

any, although packages on Debian and derivatives provide udunits.pc (see the link below)

Please consider providing udunits.pc to support pkg-config: this will make it easier to build software that uses UDUNITS. See https://sources.debian.org/patches/udunits/2.2.28-5/pkg-config.patch/ (for example) for a complete solution.

Thanks!

See also: https://github.com/conda-forge/conda-forge.github.io/discussions/1957

semmerson commented 7 months ago

Looks good. It'll be in the next release.

ckhroulev commented 7 months ago

@semmerson Great, thanks!

(Now that I think of it, the patch written by Debian package maintainers is not quite a complete solution since it does not take care of the CMake-based build, but that's pretty easy to fix.)

semmerson commented 7 months ago

@ckhroulev, send that in if you can.

ckhroulev commented 7 months ago

@semmerson Please see the patch (based on the current devel branch) below.

From 7e5851d87166aa3995cc0e421a77902fd924e19a Mon Sep 17 00:00:00 2001
From: Constantine Khrulev <ckhroulev@alaska.edu>
Date: Wed, 13 Dec 2023 11:06:33 -0900
Subject: [PATCH] CMake build system: generate udunits.pc

---
 CMakeLists.txt | 15 +++++++++++++++
 1 file changed, 15 insertions(+)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index ff89d48..f69a1f2 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -210,6 +210,21 @@ CONFIGURE_FILE(
 # Necessary for the compiler to find "config.h":
 INCLUDE_DIRECTORIES("${PROJECT_BINARY_DIR}")

+FUNCTION(generate_udunits_pc)
+  # Generates udunits.pc. This code is wrapped in a function to avoid
+  # polluting the global scope with variables used by the
+  # configure_file() call below.
+  SET(prefix ${CMAKE_INSTALL_PREFIX})
+  SET(libdir "\${exec_prefix}/lib")
+  SET(PACKAGE_VERSION ${PROJECT_VERSION})
+  CONFIGURE_FILE(
+    "${PROJECT_SOURCE_DIR}/udunits.pc.in"
+    "${PROJECT_BINARY_DIR}/udunits.pc" @ONLY)
+  INSTALL(FILES ${PROJECT_BINARY_DIR}/udunits.pc DESTINATION ${CMAKE_INSTALL_PREFIX}/lib/pkgconfig)
+ENDFUNCTION()
+
+generate_udunits_pc()
+
 ADD_SUBDIRECTORY (lib)

 # Import symbols instead of export them.
-- 
2.34.1
semmerson commented 7 months ago

@ckhroulev, done. It'll be in the next release.

Thanks for sending this in.