[geos,librttopo] Fix linkage and other quirks (#19492)

* [geos] Minor portfile maintenance

* [geos] Export implicit C++ lib dependencies

* [geos] x-add-version

* [librttopo] New port version, format manifest

* [librttopo] Modernize portfile

* [librttopo] Fix mingw build

* [librttopo] Use geos-config, allow dynamic linkage for non-windows

* [librttopo] Fix pc file

* [librttopo] Use pristine download from osgeo.org

* [librttopo] x-add-version
This commit is contained in:
Kai Pastor 2021-09-03 02:54:14 +02:00 committed by GitHub
parent 76b6e770a8
commit 080bd7537f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
12 changed files with 150 additions and 75 deletions

View File

@ -0,0 +1,68 @@
diff --git a/tools/CMakeLists.txt b/tools/CMakeLists.txt
index 8a81a2a..724a68c 100644
--- a/tools/CMakeLists.txt
+++ b/tools/CMakeLists.txt
@@ -13,6 +13,15 @@
if(NOT MSVC)
+ # C++ libraries needed even for the C API, for geos-config and geos.pc.
+ set(cxx_libs "")
+ foreach(lib IN ITEMS stdc++ c++)
+ if(lib IN_LIST CMAKE_CXX_IMPLICIT_LINK_LIBRARIES)
+ string(APPEND cxx_libs "-l${lib} ")
+ break()
+ endif()
+ endforeach()
+
# Consider CMAKE_INSTALL_PREFIX with spaces
string(REPLACE " " "\\ " ESCAPED_INSTALL_PREFIX ${CMAKE_INSTALL_PREFIX})
configure_file(
diff --git a/tools/geos-config.cmake b/tools/geos-config.cmake
index 4c546b5..4bdbc47 100644
--- a/tools/geos-config.cmake
+++ b/tools/geos-config.cmake
@@ -29,6 +29,12 @@ if test $# -eq 0; then
usage 1 1>&2
fi
+if test "@BUILD_SHARED_LIBS@" = "ON"; then
+ extra_libs=
+else
+ extra_libs="-lgeos -lm @cxx_libs@"
+fi
+
while test $# -gt 0; do
case "$1" in
-*=*) optarg=`echo "$1" | sed 's/[-_a-zA-Z0-9]*=//'` ;;
@@ -47,16 +53,16 @@ while test $# -gt 0; do
echo -L${libdir} -lgeos-@GEOS_VERSION_MAJOR@
;;
--clibs)
- echo -L${libdir} -lgeos_c
+ echo -L${libdir} -lgeos_c ${extra_libs}
;;
--cclibs)
- echo -L${libdir} -lgeos
+ echo -L${libdir} -lgeos ${extra_libs#-lgeos }
;;
--static-clibs)
- echo -L${libdir} -lgeos_c -lgeos -lm
+ echo -L${libdir} -lgeos_c -lgeos -lm @cxx_libs@
;;
--static-cclibs)
- echo -L${libdir} -lgeos -lm
+ echo -L${libdir} -lgeos -lm @cxx_libs@
;;
--cflags)
echo -I${prefix}/include
diff --git a/tools/geos.pc.cmake b/tools/geos.pc.cmake
index 53f43d9..0ebd4d5 100644
--- a/tools/geos.pc.cmake
+++ b/tools/geos.pc.cmake
@@ -9,4 +9,4 @@ Requires:
Version: @GEOS_VERSION@
Cflags: -I${includedir}
Libs: -L${libdir} -lgeos_c
-Libs.private: -lgeos
+Libs.private: -lgeos @cxx_libs@

View File

@ -14,6 +14,7 @@ vcpkg_extract_source_archive_ex(
dont-build-astyle.patch
pc-file-libs-private.patch
make-geos-config-relocatable.patch
fix-static-deps.patch
)
# NOTE: GEOS provides CMake as optional build configuration, it might not be actively
@ -27,7 +28,6 @@ endif()
vcpkg_cmake_configure(
SOURCE_PATH "${SOURCE_PATH}"
PREFER_NINJA
OPTIONS
-DCMAKE_DEBUG_POSTFIX=d
-DBUILD_TESTING=OFF
@ -57,7 +57,6 @@ if(EXISTS "${CURRENT_PACKAGES_DIR}/debug/bin/geos-config")
endif()
file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/include")
file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/share") # vcpkg-cmake-config quirk, cf. GH-18063
if(VCPKG_LIBRARY_LINKAGE STREQUAL "static" OR NOT VCPKG_TARGET_IS_WINDOWS)
file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/bin" "${CURRENT_PACKAGES_DIR}/debug/bin")
endif()

View File

@ -1,7 +1,7 @@
{
"name": "geos",
"version": "3.9.1",
"port-version": 1,
"port-version": 2,
"description": "Geometry Engine Open Source",
"homepage": "https://www.osgeo.org/projects/geos/",
"dependencies": [

View File

@ -1,5 +0,0 @@
Source: librttopo
Version: 1.1.0-3
Homepage: https://git.osgeo.org/gitea/rttopo/librttopo
Description: The RT Topology Library exposes an API to create and manage standard (ISO 13249 aka SQL/MM) topologies using user-provided [data stores] (doc/DATASTORES.md) and released under the GNU GPL license (version 2 or later).
Build-Depends: geos

View File

@ -1,37 +0,0 @@
diff --git a/configure.ac b/configure.ac
index a9561069c..7adef1bf5 100644
--- a/configure.ac
+++ b/configure.ac
@@ -87,6 +87,7 @@ AC_CONFIG_FILES([Makefile \
#-----------------------------------------------------------------------
# --with-geosconfig
#
+if 0; then
AC_ARG_WITH([geosconfig],
[AS_HELP_STRING([--with-geosconfig=FILE], [specify an alternative geos-config file])],
[GEOSCONFIG="$withval"], [GEOSCONFIG=""])
@@ -112,6 +113,7 @@ fi
# Extract the linker and include flags
GEOS_LDFLAGS=`$GEOSCONFIG --ldflags`
GEOS_CFLAGS=-I`$GEOSCONFIG --includes`
+fi
AC_SUBST([GEOS_LDFLAGS])
AC_SUBST([GEOS_CFLAGS])
# Ensure that we can parse geos_c.h
@@ -120,6 +122,7 @@ CPPFLAGS="$GEOS_CFLAGS"
AC_CHECK_HEADERS([geos_c.h],, [AC_MSG_ERROR([could not find geos_c.h - you may need to specify the directory of a geos-config file using --with-geosconfig])])
CPPFLAGS="$CPPFLAGS_SAVE"
# Ensure we can link against libgeos_c
+if 0; then
LIBS_SAVE="$LIBS"
LIBS="$GEOS_LDFLAGS"
AC_SEARCH_LIBS(GEOSContext_setErrorMessageHandler_r,geos_c,,AC_MSG_ERROR([could not find libgeos_c (or obsolete 'libgeos_c' < v.3.5.0 found) - you may need to specify the directory of a geos-config file using --with-geosconfig]))
@@ -127,6 +130,8 @@ LIBS="$LIBS_SAVE"
LIBS="$LIBS $GEOS_LDFLAGS -lgeos_c"
GEOS_MAJOR_VERSION=`$GEOSCONFIG --version | cut -d. -f1 | sed 's/[[^0-9]]//g'`
GEOS_MINOR_VERSION=`$GEOSCONFIG --version | cut -d. -f2 | sed 's/[[^0-9]]//g'`
+fi
+LIBS="$LIBS $GEOS_LDFLAGS"
RTGEOM_GEOS_VERSION="$GEOS_MAJOR_VERSION$GEOS_MINOR_VERSION"
AC_DEFINE_UNQUOTED([RTGEOM_GEOS_VERSION], [$RTGEOM_GEOS_VERSION], [GEOS library version])
AC_SUBST([RTGEOM_GEOS_VERSION])

View File

@ -0,0 +1,9 @@
diff --git a/rttopo.pc.in b/rttopo.pc.in
index 86c71dc..4064506 100644
--- a/rttopo.pc.in
+++ b/rttopo.pc.in
@@ -10,3 +10,4 @@ Description: the RT Topology library
Version: @VERSION@
Libs: -L${libdir} -lrttopo -lm
Cflags: -I${includedir}
+Requires.private: geos

View File

@ -0,0 +1,25 @@
diff --git a/configure.ac b/configure.ac
index a956106..739ee88 100644
--- a/configure.ac
+++ b/configure.ac
@@ -110,7 +110,7 @@ else
fi
fi
# Extract the linker and include flags
-GEOS_LDFLAGS=`$GEOSCONFIG --ldflags`
+GEOS_LDFLAGS=`$GEOSCONFIG --clibs`
GEOS_CFLAGS=-I`$GEOSCONFIG --includes`
AC_SUBST([GEOS_LDFLAGS])
AC_SUBST([GEOS_CFLAGS])
@@ -122,9 +122,9 @@ CPPFLAGS="$CPPFLAGS_SAVE"
# Ensure we can link against libgeos_c
LIBS_SAVE="$LIBS"
LIBS="$GEOS_LDFLAGS"
-AC_SEARCH_LIBS(GEOSContext_setErrorMessageHandler_r,geos_c,,AC_MSG_ERROR([could not find libgeos_c (or obsolete 'libgeos_c' < v.3.5.0 found) - you may need to specify the directory of a geos-config file using --with-geosconfig]))
+AC_SEARCH_LIBS(GEOSContext_setErrorMessageHandler_r,,,AC_MSG_ERROR([could not find libgeos_c (or obsolete 'libgeos_c' < v.3.5.0 found) - you may need to specify the directory of a geos-config file using --with-geosconfig]))
LIBS="$LIBS_SAVE"
-LIBS="$LIBS $GEOS_LDFLAGS -lgeos_c"
+LIBS="$LIBS $GEOS_LDFLAGS"
GEOS_MAJOR_VERSION=`$GEOSCONFIG --version | cut -d. -f1 | sed 's/[[^0-9]]//g'`
GEOS_MINOR_VERSION=`$GEOSCONFIG --version | cut -d. -f2 | sed 's/[[^0-9]]//g'`
RTGEOM_GEOS_VERSION="$GEOS_MAJOR_VERSION$GEOS_MINOR_VERSION"

View File

@ -1,54 +1,50 @@
vcpkg_check_linkage(ONLY_STATIC_LIBRARY)
# NOTE: update the version and checksum for new LIBRTTOPO release
set(LIBRTTOPO_VERSION_STR "1.1.0-2")
set(LIBRTTOPO_PACKAGE_SUM "cc2f646dd9ac3099c77e621984cdd2baa676ed1d8e6aaa9642afe2855e6fdef585603cc052ca09084204a1325e38bb626133072fbb5080e8adc369cc4854c40e")
set(LIBRTTOPO_VERSION_STR "1.1.0")
set(LIBRTTOPO_PACKAGE_SUM "d9c2f4db1261cc942152d348abb7f03e6053a63b6966e081c5381d40bbebd3c7ca1963224487355f384d7562a90287fb24d7af9e7eda4a1e230ee6441cef5de9")
vcpkg_download_distfile(ARCHIVE
URLS "https://salsa.debian.org/debian-gis-team/librttopo/-/archive/debian/${LIBRTTOPO_VERSION_STR}/librttopo-debian-${LIBRTTOPO_VERSION_STR}.tar.gz"
FILENAME "librttopo${LIBRTTOPO_VERSION_STR}.zip"
URLS "https://download.osgeo.org/librttopo/src/librttopo-${LIBRTTOPO_VERSION_STR}.tar.gz"
FILENAME "librttopo-${LIBRTTOPO_VERSION_STR}.tar.gz"
SHA512 ${LIBRTTOPO_PACKAGE_SUM}
)
vcpkg_extract_source_archive_ex(
ARCHIVE ${ARCHIVE}
ARCHIVE "${ARCHIVE}"
OUT_SOURCE_PATH SOURCE_PATH
PATCHES
fix-makefiles.patch
fix-geoconfig.patch
geos-config.patch
fix-pc-file.patch
)
if (VCPKG_TARGET_IS_WINDOWS)
set(SRID_MAX 999999)
set(SRID_USR_MAX 998999)
configure_file(${CMAKE_CURRENT_LIST_DIR}/rttopo_config.h.in ${SOURCE_PATH}/src/rttopo_config.h @ONLY)
configure_file(${SOURCE_PATH}/headers/librttopo_geom.h.in ${SOURCE_PATH}/headers/librttopo_geom.h @ONLY)
if(VCPKG_TARGET_IS_WINDOWS AND NOT VCPKG_TARGET_IS_MINGW)
vcpkg_check_linkage(ONLY_STATIC_LIBRARY)
file(REMOVE "${SOURCE_PATH}/src/rttopo_config.h")
configure_file("${CMAKE_CURRENT_LIST_DIR}/rttopo_config.h.in" "${SOURCE_PATH}/src/rttopo_config.h" @ONLY)
vcpkg_build_nmake(
SOURCE_PATH ${SOURCE_PATH}
SOURCE_PATH "${SOURCE_PATH}"
TARGET librttopo.lib
)
file(GLOB LIBRTTOPO_INCLUDE ${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-rel/headers/*.h)
file(COPY ${LIBRTTOPO_INCLUDE} DESTINATION ${CURRENT_PACKAGES_DIR}/include)
file(GLOB LIBRTTOPO_INCLUDE "${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-rel/headers/*.h")
file(COPY ${LIBRTTOPO_INCLUDE} DESTINATION "${CURRENT_PACKAGES_DIR}/include")
file(COPY ${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-rel/librttopo.lib DESTINATION ${CURRENT_PACKAGES_DIR}/lib)
file(COPY ${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-dbg/librttopo.lib DESTINATION ${CURRENT_PACKAGES_DIR}/debug/lib)
else () # Build in UNIX
file(COPY "${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-rel/librttopo.lib" DESTINATION "${CURRENT_PACKAGES_DIR}/lib")
file(COPY "${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-dbg/librttopo.lib" DESTINATION "${CURRENT_PACKAGES_DIR}/debug/lib")
else() # Build in UNIX
vcpkg_configure_make(
SOURCE_PATH ${SOURCE_PATH}
SOURCE_PATH "${SOURCE_PATH}"
AUTOCONFIG
OPTIONS
"GEOS_MAJOR_VERSION=3"
"GEOS_MINOR_VERSION=8"
OPTIONS_DEBUG
"GEOS_LDFLAGS=-lgeos_cd -lgeosd -lm"
"--with-geosconfig=${CURRENT_INSTALLED_DIR}/tools/geos/debug/bin/geos-config"
OPTIONS_RELEASE
"GEOS_LDFLAGS=-lgeos_c -lgeos -lm"
"--with-geosconfig=${CURRENT_INSTALLED_DIR}/tools/geos/bin/geos-config"
)
vcpkg_install_make()
vcpkg_fixup_pkgconfig()
endif()
# Handle copyright
file(INSTALL ${SOURCE_PATH}/COPYING DESTINATION ${CURRENT_PACKAGES_DIR}/share/${PORT} RENAME copyright)
file(INSTALL "${SOURCE_PATH}/COPYING" DESTINATION "${CURRENT_PACKAGES_DIR}/share/${PORT}" RENAME copyright)

View File

@ -0,0 +1,10 @@
{
"name": "librttopo",
"version": "1.1.0",
"port-version": 4,
"description": "The RT Topology Library exposes an API to create and manage standard (ISO 13249 aka SQL/MM) topologies using user-provided data stores.",
"homepage": "https://git.osgeo.org/gitea/rttopo/librttopo",
"dependencies": [
"geos"
]
}

View File

@ -2266,7 +2266,7 @@
},
"geos": {
"baseline": "3.9.1",
"port-version": 1
"port-version": 2
},
"geotrans": {
"baseline": "3.8",
@ -3597,8 +3597,8 @@
"port-version": 2
},
"librttopo": {
"baseline": "1.1.0-3",
"port-version": 0
"baseline": "1.1.0",
"port-version": 4
},
"libsamplerate": {
"baseline": "0.2.1",

View File

@ -1,5 +1,10 @@
{
"versions": [
{
"git-tree": "149daa68785ac3796019e4489a6d966fb8cc4cc5",
"version": "3.9.1",
"port-version": 2
},
{
"git-tree": "19ac6640378da611cbee774dae84e8e2f18cfe82",
"version": "3.9.1",

View File

@ -1,5 +1,10 @@
{
"versions": [
{
"git-tree": "fae3fefb29d1972caa2643351ebf83ca47f7d04a",
"version": "1.1.0",
"port-version": 4
},
{
"git-tree": "b248b7c998e21a3feaf8581d8418306d54d5edc9",
"version-string": "1.1.0-3",