[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
This commit is contained in:
Kai Pastor 2021-06-29 02:58:35 +02:00 committed by GitHub
parent 6cdc26c884
commit e2d1022400
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 143 additions and 36 deletions

View File

@ -1,6 +0,0 @@
Source: netcdf-c
Version: 4.7.4
Port-Version: 2
Build-Depends: hdf5, curl
Homepage: https://github.com/Unidata/netcdf-c
Description: a set of self-describing, machine-independent data formats that support the creation, access, and sharing of array-oriented scientific data.

View File

@ -1,15 +0,0 @@
diff --git a/CMakeLists.txt b/CMakeLists.txt
index bd7c4f8..e4e92c6 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -2050,7 +2050,9 @@ configure_file(${CMAKE_CURRENT_SOURCE_DIR}/ncdap_test/pingurl.c ${CMAKE_CURRENT_
# Create CMake package configuration files. With these, other packages using
# cmake should be able to find netcdf using find_package and find_library.
# The EXPORT call is paired with one in liblib.
-set(ConfigPackageLocation ${CMAKE_INSTALL_LIBDIR}/cmake/netCDF)
+if(NOT DEFINED ConfigPackageLocation)
+ set(ConfigPackageLocation ${CMAKE_INSTALL_LIBDIR}/cmake/netCDF)
+endif(NOT DEFINED ConfigPackageLocation)
install(EXPORT netCDFTargets
DESTINATION ${ConfigPackageLocation}

View File

@ -0,0 +1,13 @@
diff --git a/liblib/CMakeLists.txt b/liblib/CMakeLists.txt
index 5b578f7..0731460 100644
--- a/liblib/CMakeLists.txt
+++ b/liblib/CMakeLists.txt
@@ -58,7 +58,7 @@ ENDIF()
SET(TLL_LIBS "")
-SET(TLL_LIBS ${TLL_LIBS} ${HAVE_LIBM} ZLIB::ZLIB)
+SET(TLL_LIBS ${TLL_LIBS} ${HAVE_LIBM})
# Add extra dependencies specified via NC_EXTRA_DEPS
SET(TLL_LIBS ${TLL_LIBS} ${EXTRA_DEPS})

View File

@ -0,0 +1,13 @@
diff --git a/libsrc/CMakeLists.txt b/libsrc/CMakeLists.txt
index 65a3f87..30a008d 100644
--- a/libsrc/CMakeLists.txt
+++ b/libsrc/CMakeLists.txt
@@ -61,7 +61,7 @@ IF(HAVE_M4)
IF(NOT MSVC)
ADD_CUSTOM_TARGET(manpage ALL
- COMMAND ${NC_M4} ${ARGS_MANPAGE} '${CMAKE_CURRENT_BINARY_DIR}/netcdf.m4' > '${CMAKE_CURRENT_BINARY_DIR}/netcdf.3'
+ COMMAND ${NC_M4} ${ARGS_MANPAGE} "${CMAKE_CURRENT_BINARY_DIR}/netcdf.m4" > "${CMAKE_CURRENT_BINARY_DIR}/netcdf.3" VERBATIM
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
)

View File

@ -0,0 +1,37 @@
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@

View File

@ -6,10 +6,12 @@ vcpkg_from_github(
HEAD_REF master
PATCHES
no-install-deps.patch
config-pkg-location.patch
use_targets.patch
fix-dependency-libmath.patch
fix-linkage-error.patch
fix-pkgconfig.patch
fix-dependency-zlib.patch
fix-manpage-msys.patch
)
#Remove outdated find modules
@ -23,31 +25,46 @@ else()
set(NC_USE_STATIC_CRT OFF)
endif()
vcpkg_configure_cmake(
SOURCE_PATH ${SOURCE_PATH}
vcpkg_check_features(OUT_FEATURE_OPTIONS FEATURE_OPTIONS
FEATURES
dap ENABLE_DAP
netcdf-4 ENABLE_NETCDF_4
netcdf-4 USE_HDF5
tools BUILD_UTILITIES
INVERTED_FEATURES
dap CMAKE_DISABLE_FIND_PACKAGE_CURL
netcdf-4 CMAKE_DISABLE_FIND_PACKAGE_HDF5
)
vcpkg_cmake_configure(
SOURCE_PATH "${SOURCE_PATH}"
DISABLE_PARALLEL_CONFIGURE # netcdf-c configures in the source!
PREFER_NINJA
OPTIONS
-DBUILD_UTILITIES=OFF
-DBUILD_TESTING=OFF
-DENABLE_EXAMPLES=OFF
-DENABLE_TESTS=OFF
-DENABLE_FILTER_TESTING=OFF
-DUSE_HDF5=ON
-DENABLE_DAP_REMOTE_TESTS=OFF
-DDISABLE_INSTALL_DEPENDENCIES=ON
-DNC_USE_STATIC_CRT=${NC_USE_STATIC_CRT}
-DConfigPackageLocation=share/netcdf
${FEATURE_OPTIONS}
)
vcpkg_install_cmake()
vcpkg_fixup_cmake_targets(CONFIG_PATH share/netcdf TARGET_PATH share/netcdf)
vcpkg_cmake_install()
vcpkg_cmake_config_fixup(PACKAGE_NAME "netcdf" CONFIG_PATH "lib/cmake/netCDF")
vcpkg_fixup_pkgconfig()
if(VCPKG_LIBRARY_LINKAGE STREQUAL "static")
file(REMOVE_RECURSE ${CURRENT_PACKAGES_DIR}/debug/bin ${CURRENT_PACKAGES_DIR}/bin)
file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/bin/nc-config" "${CURRENT_PACKAGES_DIR}/bin/nc-config") # invalid
if("tools" IN_LIST FEATURES)
vcpkg_copy_tools(
TOOL_NAMES nccopy ncdump ncgen ncgen3
AUTO_CLEAN
)
elseif(VCPKG_LIBRARY_LINKAGE STREQUAL "static")
file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/bin" "${CURRENT_PACKAGES_DIR}/bin")
endif()
file(REMOVE_RECURSE ${CURRENT_PACKAGES_DIR}/debug/include)
file(REMOVE_RECURSE ${CURRENT_PACKAGES_DIR}/debug/share)
file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/include")
file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/share")
file(INSTALL ${SOURCE_PATH}/COPYRIGHT DESTINATION ${CURRENT_PACKAGES_DIR}/share/${PORT} RENAME copyright)
file(INSTALL "${SOURCE_PATH}/COPYRIGHT" DESTINATION "${CURRENT_PACKAGES_DIR}/share/${PORT}" RENAME copyright)

43
ports/netcdf-c/vcpkg.json Normal file
View File

@ -0,0 +1,43 @@
{
"name": "netcdf-c",
"version-string": "4.7.4",
"port-version": 3,
"description": "A set of self-describing, machine-independent data formats that support the creation, access, and sharing of array-oriented scientific data.",
"homepage": "https://github.com/Unidata/netcdf-c",
"dependencies": [
{
"name": "vcpkg-cmake",
"host": true
},
{
"name": "vcpkg-cmake-config",
"host": true
}
],
"default-features": [
"dap",
"netcdf-4"
],
"features": {
"dap": {
"description": "Build with DAP remote access client support",
"dependencies": [
"curl"
]
},
"netcdf-4": {
"description": "Build with netCDF-4/HDF5 support",
"dependencies": [
{
"name": "hdf5",
"features": [
"zlib"
]
}
]
},
"tools": {
"description": "Build utilities"
}
}
}

View File

@ -4290,7 +4290,7 @@
},
"netcdf-c": {
"baseline": "4.7.4",
"port-version": 2
"port-version": 3
},
"netcdf-cxx4": {
"baseline": "4.3.1",

View File

@ -1,5 +1,10 @@
{
"versions": [
{
"git-tree": "069ccb40f8ce75d6ec88b8fe31966c11fcf6906b",
"version-string": "4.7.4",
"port-version": 3
},
{
"git-tree": "aa42781f00db0c2de52798f0345801b667977c79",
"version-string": "4.7.4",