vcpkg/ports/netcdf-c/fix-pkgconfig.patch
Kai Pastor e2d1022400
[netcdf-c] Fix pc files; use features (#18120)
* Format manifest

* New port-version

* Quote filepath expressions

* Port to vcpkg-cmake ports

* Remove invalid nc-config file

* Fix pc files

* Use features

* Add feature 'tools'

* x-add-version

* Fix build with msys2 mingw

* Update git-tree
2021-06-28 17:58:35 -07:00

38 lines
1.2 KiB
Diff

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 57d2d4b..3de6f8c 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -1892,6 +1892,20 @@ LIST(REMOVE_DUPLICATES 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("-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@