[gdal] Add features for hdf5, netcdf, postgresql (#21231)

* Revise configuration, avoid hidden dependencies

* Expose hdf5 and netcdf feature, fix static linkage

* Fix hdf5 pc files

* Add spatialite flag

* Update versions

* Expose feature platform dependencies

* Update versions

* Configure gdal for windows arm and arm64

* Add postgresql feature

* Update versions

* Update wrapper

* Update versions

* Update baseline

* [skip actions] CI

* Use pkgconfig for expat

* Update versions

* uwp is unsupported (comsuppw.lib, atls.lib)

* Update versions
This commit is contained in:
Kai Pastor 2022-01-03 22:08:39 +01:00 committed by GitHub
parent 1085a57da0
commit cccfe836db
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
11 changed files with 148 additions and 55 deletions

View File

@ -203,8 +203,8 @@ index 30cd613..43f1daf 100644
dnl Expat 1.95.0 released in 2000-09-28
EXPAT_REQ_VERSION="1.95.0"
-AX_LIB_EXPAT($EXPAT_REQ_VERSION)
+AC_CHECK_LIB(expat,XML_ParserCreate,HAVE_EXPAT=yes,AC_MSG_ERROR([vcpkg expat not found]))
+EXPAT_LDFLAGS="-lexpat"
+PKG_CHECK_MODULES([EXPAT],[expat],[HAVE_EXPAT=yes],[AC_MSG_ERROR([vcpkg expat not found])])
+EXPAT_LDFLAGS="$EXPAT_LIBS"
+EXPAT_INCLUDE=""
if test "$HAVE_EXPAT" = "yes"; then

View File

@ -42,20 +42,12 @@ macro(find_dependency_win)
set(SQLITE_LIBRARY_REL "${CURRENT_INSTALLED_DIR}/lib/sqlite3.lib" )
set(SQLITE_LIBRARY_DBG "${CURRENT_INSTALLED_DIR}/debug/lib/sqlite3.lib" )
# Setup PostgreSQL libraries + include path
set(PGSQL_INCLUDE_DIR "${CURRENT_INSTALLED_DIR}/include" )
set(PGSQL_LIBRARY_REL "${CURRENT_INSTALLED_DIR}/lib/libpq.lib" )
set(PGSQL_LIBRARY_DBG "${CURRENT_INSTALLED_DIR}/debug/lib/libpq.lib" )
set(TMP_REL "${CURRENT_INSTALLED_DIR}/lib/libpgcommon.lib" )
set(TMP_DBG "${CURRENT_INSTALLED_DIR}/debug/lib/libpgcommon.lib" )
set(PGSQL_LIBRARY_REL "${PGSQL_LIBRARY_REL} ${TMP_REL}")
set(PGSQL_LIBRARY_DBG "${PGSQL_LIBRARY_DBG} ${TMP_DBG}")
set(TMP_REL "${CURRENT_INSTALLED_DIR}/lib/libpgport.lib" )
set(TMP_DBG "${CURRENT_INSTALLED_DIR}/debug/lib/libpgport.lib" )
set(PGSQL_LIBRARY_REL "${PGSQL_LIBRARY_REL} ${TMP_REL}")
set(PGSQL_LIBRARY_DBG "${PGSQL_LIBRARY_DBG} ${TMP_DBG}")
if ("postgresql" IN_LIST FEATURES)
# Setup PostgreSQL libraries + include path
set(PGSQL_INCLUDE_DIR "${CURRENT_INSTALLED_DIR}/include" )
set(PGSQL_LIBRARY_REL "${CURRENT_INSTALLED_DIR}/lib/libpq.lib ${CURRENT_INSTALLED_DIR}/lib/libpgcommon.lib ${CURRENT_INSTALLED_DIR}/lib/libpgport.lib" )
set(PGSQL_LIBRARY_DBG "${CURRENT_INSTALLED_DIR}/debug/lib/libpq.lib ${CURRENT_INSTALLED_DIR}/debug/lib/libpgcommon.lib ${CURRENT_INSTALLED_DIR}/debug/lib/libpgport.lib")
endif()
# Setup OpenJPEG libraries + include path
set(OPENJPEG_INCLUDE_DIR "${CURRENT_INSTALLED_DIR}/include" )
@ -161,27 +153,36 @@ macro(find_dependency_win)
endif()
# Setup netcdf libraries
if(VCPKG_LIBRARY_LINKAGE STREQUAL "dynamic")
if(EXISTS "${CURRENT_INSTALLED_DIR}/lib/netcdf.lib")
file(TO_NATIVE_PATH "${CURRENT_INSTALLED_DIR}/include" NETCDF_INCLUDE)
file(TO_NATIVE_PATH "${CURRENT_INSTALLED_DIR}/lib/netcdf.lib" NETCDF_LIBRARY_REL)
file(TO_NATIVE_PATH "${CURRENT_INSTALLED_DIR}/debug/lib/netcdf.lib" NETCDF_LIBRARY_DBG)
list(APPEND NMAKE_OPTIONS NETCDF_PLUGIN=NO)
list(APPEND NMAKE_OPTIONS NETCDF_SETTING=yes)
list(APPEND NMAKE_OPTIONS NETCDF_INC_DIR=${NETCDF_INCLUDE})
list(APPEND NMAKE_OPTIONS_REL NETCDF_LIB=${NETCDF_LIBRARY_REL})
list(APPEND NMAKE_OPTIONS_DBG NETCDF_LIB=${NETCDF_LIBRARY_DBG})
endif()
if("netcdf" IN_LIST FEATURES)
x_vcpkg_pkgconfig_get_modules(
PREFIX NETCDF
MODULES --msvc-syntax netcdf
INCLUDE_DIRS
LIBS
)
string(REGEX REPLACE "^/I" "" NETCDF_INC_DIR "${NETCDF_INCLUDE_DIRS}")
list(APPEND NMAKE_OPTIONS NETCDF_PLUGIN=NO)
list(APPEND NMAKE_OPTIONS NETCDF_SETTING=yes)
list(APPEND NMAKE_OPTIONS "NETCDF_INC_DIR=${NETCDF_INC_DIR}")
list(APPEND NMAKE_OPTIONS_REL "NETCDF_LIB=${NETCDF_LIBS_RELEASE}")
list(APPEND NMAKE_OPTIONS_DBG "NETCDF_LIB=${NETCDF_LIBS_DEBUG}")
endif()
if(VCPKG_LIBRARY_LINKAGE STREQUAL "dynamic")
file(TO_NATIVE_PATH "${CURRENT_INSTALLED_DIR}" HDF5_DIR)
file(TO_NATIVE_PATH "${CURRENT_INSTALLED_DIR}/debug/lib/hdf5_D.lib" HDF5_LIBRARY_DBG)
file(TO_NATIVE_PATH "${CURRENT_INSTALLED_DIR}/lib/hdf5.lib" HDF5_LIBRARY_REL)
list(APPEND NMAKE_OPTIONS HDF5_PLUGIN=NO)
list(APPEND NMAKE_OPTIONS HDF5_H5_IS_DLL=YES)
list(APPEND NMAKE_OPTIONS HDF5_DIR=${HDF5_DIR})
list(APPEND NMAKE_OPTIONS_REL HDF5_LIB=${HDF5_LIBRARY_REL})
list(APPEND NMAKE_OPTIONS_DBG HDF5_LIB=${HDF5_LIBRARY_DBG})
# Setup hdf5 libraries
if("hdf5" IN_LIST FEATURES)
file(TO_NATIVE_PATH "${CURRENT_INSTALLED_DIR}" HDF5_DIR)
x_vcpkg_pkgconfig_get_modules(
PREFIX HDF5
MODULES --msvc-syntax hdf5
LIBS
)
list(APPEND NMAKE_OPTIONS HDF5_PLUGIN=NO)
list(APPEND NMAKE_OPTIONS "HDF5_DIR=${HDF5_DIR}")
list(APPEND NMAKE_OPTIONS_REL "HDF5_LIB=${HDF5_LIBS_RELEASE}")
list(APPEND NMAKE_OPTIONS_DBG "HDF5_LIB=${HDF5_LIBS_DEBUG}")
if(VCPKG_LIBRARY_LINKAGE STREQUAL "dynamic")
list(APPEND NMAKE_OPTIONS HDF5_H5_IS_DLL=YES)
endif()
endif()
# Setup libkml libraries
@ -238,6 +239,7 @@ macro(find_dependency_win)
set(SPATIALITE_LIBRARY_DBG "${CURRENT_INSTALLED_DIR}/debug/lib/spatialite.lib" )
endif()
set(HAVE_SPATIALITE "-DHAVE_SPATIALITE")
list(APPEND NMAKE_OPTIONS SPATIALITE_412_OR_LATER=yes)
endif()
if ("cfitsio" IN_LIST FEATURES)

View File

@ -64,10 +64,14 @@ if (VCPKG_TARGET_IS_WINDOWS AND NOT VCPKG_TARGET_IS_MINGW)
MSVC_VER=1900
)
if(VCPKG_TARGET_ARCHITECTURE STREQUAL "x64")
if(VCPKG_TARGET_ARCHITECTURE STREQUAL "x64" OR VCPKG_TARGET_ARCHITECTURE STREQUAL "arm64")
list(APPEND NMAKE_OPTIONS WIN64=YES)
endif()
if(VCPKG_TARGET_ARCHITECTURE MATCHES "^arm")
list(APPEND NMAKE_OPTIONS SSEFLAGS=/DNO_SSSE AVXFLAGS=/DNO_AVX)
endif()
if (VCPKG_LIBRARY_LINKAGE STREQUAL "static")
list(APPEND NMAKE_OPTIONS CURL_CFLAGS=-DCURL_STATICLIB)
list(APPEND NMAKE_OPTIONS DLLBUILD=0)
@ -187,10 +191,11 @@ else()
file(TOUCH "${SOURCE_PATH}/gdal/config.rpath")
set(CONF_OPTS
--with-gnm=yes
--with-hide-internal-symbols=yes
--with-java=no
--with-perl=no
--with-python=no
--with-java=no
)
set(CONF_CHECKS "")
function(add_config option check)
@ -204,16 +209,13 @@ else()
add_config("--with-expat=yes" "Expat support: yes")
add_config("--with-geos=yes" "GEOS support: yes")
add_config("--with-gif=yes" "LIBGIF support: external")
add_config("--with-hdf5=yes" "HDF5 support: yes")
add_config("--with-libjson=yes" "checking for JSONC... yes")
add_config("--with-geotiff=yes" "LIBGEOTIFF support: external")
add_config("--with-jpeg=yes" "LIBJPEG support: external")
add_config("--with-liblzma=yes" "LIBLZMA support: yes")
add_config("--with-png=yes" "LIBPNG support: external")
add_config("--with-pg=yes" "PostgreSQL support: yes")
add_config("--with-webp=yes" "WebP support: yes")
add_config("--with-xml2=yes" "libxml2 support: yes")
add_config("--with-netcdf=yes" "NetCDF support: yes")
add_config("--with-openjpeg=yes" "OpenJPEG support: yes")
add_config("--with-proj=yes" "PROJ >= 6: yes")
add_config("--with-sqlite3=yes" "SQLite support: yes")
@ -237,6 +239,12 @@ else()
add_config("--with-spatialite=no" "SpatiaLite support: no")
endif()
if ("postgresql" IN_LIST FEATURES)
add_config("--with-pg=yes" "PostgreSQL support: yes")
elseif(DISABLE_SYSTEM_LIBRARIES)
add_config("--with-pg=yes" "PostgreSQL support: no")
endif()
if ("mysql-libmariadb" IN_LIST FEATURES)
add_config("--with-mysql=yes" "MySQL support: yes")
elseif(DISABLE_SYSTEM_LIBRARIES)
@ -249,11 +257,25 @@ else()
add_config("--with-cfitsio=no" "CFITSIO support: no")
endif()
if ("hdf5" IN_LIST FEATURES)
add_config("--with-hdf5=yes" "HDF5 support: yes")
elseif(DISABLE_SYSTEM_LIBRARIES)
add_config("--with-hdf5=no" "HDF5 support: no")
endif()
if ("netcdf" IN_LIST FEATURES)
add_config("--with-netcdf=yes" "NetCDF support: yes")
elseif(DISABLE_SYSTEM_LIBRARIES)
add_config("--with-netcdf=no" "NetCDF support: no")
endif()
if(DISABLE_SYSTEM_LIBRARIES)
list(APPEND CONF_OPTS
# Too much: --disable-all-optional-drivers
# alphabetical order
--with-armadillo=no
--with-blosc=no
--with-brunsli=no
--with-charls=no
--with-crypto=no
--with-cryptopp=no
@ -272,20 +294,24 @@ else()
--with-heif=no
--with-idb=no
--with-ingres=no
--with-jasper=no
--with-jp2lura=no
--with-jp2mrsid=no
--with-jasper=no
--with-jxl=no
--with-kakadu=no
--with-kea=no
--with-lerc=no
--with-libdeflate=no
--with-libgrass=no
--with-libkml=no
--with-lz4=no
--with-mdb=no
--with-mongocxx=no
--with-mongocxxv3=no
--with-mrsid=no
--with-mrsid_lidar=no
--with-msg=no
--with-mongocxx=no
--with-mongocxxv3=no
--with-null=no
--with-oci=no
--with-odbc=no
--with-ogdi=no

View File

@ -81,7 +81,9 @@ if(GDAL_FOUND)
_gdal_add_dependency(expat::expat expat CONFIG)
_gdal_add_dependency(GEOS::geos_c geos CONFIG)
_gdal_add_dependency(GIF::GIF GIF)
_gdal_add_dependency(hdf5::hdf5 hdf5 CONFIG)
if("hdf5" IN_LIST Z_VCPKG_PORT_FEATURES)
_gdal_add_dependency(hdf5::hdf5 hdf5 CONFIG)
endif()
if(NOT WIN32 OR MINGW)
_gdal_add_dependency(json-c::json-c json-c CONFIG)
endif()
@ -89,10 +91,14 @@ if(GDAL_FOUND)
_gdal_add_dependency(JPEG::JPEG JPEG)
_gdal_add_dependency(liblzma::liblzma liblzma CONFIG)
_gdal_add_dependency(png libpng CONFIG)
_gdal_add_dependency(PostgreSQL::PostgreSQL PostgreSQL)
if("postgresql" IN_LIST Z_VCPKG_PORT_FEATURES)
_gdal_add_dependency(PostgreSQL::PostgreSQL PostgreSQL)
endif()
_gdal_add_dependency(WebP::webp WebP CONFIG)
_gdal_add_dependency(LibXml2::LibXml2 LibXml2)
_gdal_add_dependency(netCDF::netcdf netCDF CONFIG)
if("netcdf" IN_LIST Z_VCPKG_PORT_FEATURES)
_gdal_add_dependency(netCDF::netcdf netCDF CONFIG)
endif()
_gdal_add_dependency(openjp2 OpenJPEG CONFIG)
_gdal_add_dependency(PROJ::proj PROJ4 CONFIG)
_gdal_add_dependency(unofficial::sqlite3::sqlite3 unofficial-sqlite3 CONFIG)

View File

@ -1,16 +1,15 @@
{
"name": "gdal",
"version-semver": "3.4.0",
"port-version": 4,
"port-version": 5,
"description": "The Geographic Data Abstraction Library for reading and writing geospatial raster and vector data",
"homepage": "https://gdal.org",
"supports": "!(arm & windows)",
"supports": "!uwp",
"dependencies": [
"curl",
"expat",
"geos",
"giflib",
"hdf5",
{
"name": "json-c",
"platform": "!windows | mingw"
@ -19,10 +18,8 @@
"libjpeg-turbo",
"liblzma",
"libpng",
"libpq",
"libwebp",
"libxml2",
"netcdf-c",
"openjpeg",
"proj4",
"sqlite3",
@ -34,6 +31,9 @@
"zlib",
"zstd"
],
"default-features": [
"supported-default-features"
],
"features": {
"cfitsio": {
"description": "Enable cfitsio support",
@ -41,6 +41,12 @@
"cfitsio"
]
},
"hdf5": {
"description": "Enable HDF5 support",
"dependencies": [
"hdf5"
]
},
"libspatialite": {
"description": "Create or update SpatiaLite databases using libspatialite",
"dependencies": [
@ -53,6 +59,40 @@
"libmariadb"
]
},
"netcdf": {
"description": "Enable NetCDF support",
"dependencies": [
"netcdf-c"
]
},
"postgresql": {
"description": "Enable PostgreSQL support",
"dependencies": [
"libpq"
]
},
"supported-default-features": {
"description": "Default set of features, dependent on platform",
"dependencies": [
{
"name": "gdal",
"default-features": false,
"features": [
"postgresql"
],
"platform": "!uwp"
},
{
"name": "gdal",
"default-features": false,
"features": [
"hdf5",
"netcdf"
],
"platform": "!uwp & !(windows & arm64)"
}
]
},
"system-libraries": {
"$supports": "!windows",
"description": "Include drivers which need additional libraries"

View File

@ -86,6 +86,12 @@ if(VCPKG_TARGET_IS_WINDOWS)
endif()
vcpkg_fixup_pkgconfig()
if(VCPKG_TARGET_IS_WINDOWS AND NOT VCPKG_TARGET_IS_MINGW AND VCPKG_LIBRARY_LINKAGE STREQUAL "static")
file(GLOB pc_files "${CURRENT_PACKAGES_DIR}/lib/pkgconfig/*.pc" "${CURRENT_PACKAGES_DIR}/debug/lib/pkgconfig/*.pc")
foreach(file IN LISTS pc_files)
vcpkg_replace_string("${file}" " -lhdf5" " -llibhdf5")
endforeach()
endif()
file(READ "${CURRENT_PACKAGES_DIR}/share/hdf5/hdf5-config.cmake" contents)
string(REPLACE [[${HDF5_PACKAGE_NAME}_TOOLS_DIR "${PACKAGE_PREFIX_DIR}/bin"]]

View File

@ -1,7 +1,7 @@
{
"name": "hdf5",
"version": "1.12.1",
"port-version": 1,
"port-version": 3,
"description": "HDF5 is a data model, library, and file format for storing and managing data",
"homepage": "https://www.hdfgroup.org/downloads/hdf5/",
"supports": "!uwp",

View File

@ -338,6 +338,9 @@ gasol:arm64-windows=fail
gasol:arm-uwp=fail
gasol:x64-uwp=fail
# Requires ATL for ARM64 to be installed in CI
gdal:arm64-windows=fail
# gsoap does not offer stable public source downloads
gsoap:x64-windows = skip
gsoap:x86-windows = skip

View File

@ -2370,7 +2370,7 @@
},
"gdal": {
"baseline": "3.4.0",
"port-version": 4
"port-version": 5
},
"gdcm": {
"baseline": "3.0.7",
@ -2670,7 +2670,7 @@
},
"hdf5": {
"baseline": "1.12.1",
"port-version": 1
"port-version": 3
},
"healpix": {
"baseline": "1.12.10",

View File

@ -1,5 +1,10 @@
{
"versions": [
{
"git-tree": "519ec20e4d9e0fc541320ca88b51521180c570da",
"version-semver": "3.4.0",
"port-version": 5
},
{
"git-tree": "78bf53bfc83afb261c9eaa60cf2ef9487031b4b1",
"version-semver": "3.4.0",

View File

@ -1,5 +1,10 @@
{
"versions": [
{
"git-tree": "c12760535a18d9f3ac5497103dc76a961bac991e",
"version": "1.12.1",
"port-version": 3
},
{
"git-tree": "b3c8c63454b3e098a9e03ea654eef206769e31c1",
"version": "1.12.1",