vcpkg/ports/netcdf-c/fix-pkgconfig.patch
Kai Pastor 297ff7ba3e
[netcdf-c] Update to 4.8.1, revise features (#21239)
* Consolidate netcdf-c ZLIB patching

* Update to 4.8.1, refresh patches

* Resolve parameter warning

* Decouple netcdf-4 feature from hdf5

* Expose NCZarr features

* Break vcpkg CI cascade

* Fix hdf5 szip support detection for static linkage

* Allow curl, hdf5, libzip with minimal dependencies

* Disable fatal warnings on uwp

* Update versions

* Fix libzip dependency

* Fix and simplify szip config patch

* Revert nczarr-s3 feature for now

* Update versions

* [skip actions] CI

* [skip actions] Debug ci failure

* Revert "[skip actions] Debug ci failure"

This reverts commit 03f3d52623026e9f16f8be067a07499aa5788b55.
2021-11-18 21:25:08 -08:00

39 lines
1.3 KiB
Diff

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 390ac0a..4bcd909 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -2100,6 +2100,21 @@ STRING(REPLACE ";" " " LINKFLAGS "${LINKFLAGS}")
SET(LIBS ${NC_LIBS})
SET(NC_LIBS "-lnetcdf")
+set(NC_LIBS_PRIVATE " ${LIBS} ")
+set(NC_REQUIRES_PRIVATE "")
+macro(replace_pkgconfig_module PATTERN MODULE)
+ if(NC_LIBS_PRIVATE MATCHES " ${PATTERN} ")
+ string(REPLACE "${CMAKE_MATCH_0}" " " NC_LIBS_PRIVATE "${NC_LIBS_PRIVATE}")
+ string(APPEND NC_REQUIRES_PRIVATE " ${MODULE}")
+ endif()
+endmacro()
+replace_pkgconfig_module("-lhdf5_hl" "hdf5_hl")
+replace_pkgconfig_module("-lhdf5" "hdf5")
+replace_pkgconfig_module("-lmpi" "ompi-c")
+replace_pkgconfig_module("-lzip" "libzip")
+replace_pkgconfig_module("-lCURL[^ ]*" "libcurl")
+replace_pkgconfig_module("-lZLIB[^ ]*" "zlib")
+
configure_file(
${netCDF_SOURCE_DIR}/netcdf.pc.in
${netCDF_BINARY_DIR}/netcdf.pc @ONLY)
diff --git a/netcdf.pc.in b/netcdf.pc.in
index 22b5594..a48b7c2 100644
--- a/netcdf.pc.in
+++ b/netcdf.pc.in
@@ -9,5 +9,6 @@ Description: NetCDF Client Library for C
URL: http://www.unidata.ucar.edu/netcdf
Version: @PACKAGE_VERSION@
Libs: -L${libdir} @NC_LIBS@
-Libs.private: @LIBS@
+Libs.private: @NC_LIBS_PRIVATE@
Cflags: -I${includedir}
+Requires.private: @NC_REQUIRES_PRIVATE@