Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[geos] Relocatable geos-config; dynamic builds on Unix #17616

Merged
merged 9 commits into from
May 26, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions ports/geos/CONTROL

This file was deleted.

16 changes: 16 additions & 0 deletions ports/geos/make-geos-config-relocatable.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
diff --git a/tools/geos-config.cmake b/tools/geos-config.cmake
index 6730e215..4c546b5c 100644
--- a/tools/geos-config.cmake
+++ b/tools/geos-config.cmake
@@ -1,7 +1,9 @@
#!/bin/sh

-prefix=@ESCAPED_INSTALL_PREFIX@
-libdir=${prefix}/lib
+DIRNAME=$(dirname $0)
+TOOLS=$(dirname $DIRNAME)
+prefix=$(CDPATH= cd -- "${DIRNAME%/tools/geos/*}" && pwd -P)
+libdir=${prefix}${TOOLS##*/geos}/lib

usage()
{
12 changes: 12 additions & 0 deletions ports/geos/pc-file-libs-private.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
diff --git a/tools/geos.pc.cmake b/tools/geos.pc.cmake
index 0a9df7fb..53f43d90 100644
--- a/tools/geos.pc.cmake
+++ b/tools/geos.pc.cmake
@@ -9,3 +9,4 @@ Requires:
Version: @GEOS_VERSION@
Cflags: -I${includedir}
Libs: -L${libdir} -lgeos_c
+Libs.private: -lgeos
--
2.17.1

45 changes: 31 additions & 14 deletions ports/geos/portfile.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,13 @@ vcpkg_download_distfile(ARCHIVE
)
vcpkg_extract_source_archive_ex(
OUT_SOURCE_PATH SOURCE_PATH
ARCHIVE ${ARCHIVE}
ARCHIVE "${ARCHIVE}"
REF ${GEOS_VERSION}
PATCHES
dont-build-docs.patch
dont-build-astyle.patch
pc-file-libs-private.patch
make-geos-config-relocatable.patch
)

# NOTE: GEOS provides CMake as optional build configuration, it might not be actively
Expand All @@ -23,30 +25,45 @@ else()
set(_CMAKE_EXTRA_OPTIONS "")
endif()

vcpkg_configure_cmake(
SOURCE_PATH ${SOURCE_PATH}
vcpkg_cmake_configure(
SOURCE_PATH "${SOURCE_PATH}"
PREFER_NINJA
OPTIONS
-DCMAKE_DEBUG_POSTFIX=d
-DBUILD_TESTING=OFF
-DBUILD_BENCHMARKS=OFF
${_CMAKE_EXTRA_OPTIONS}
)
vcpkg_install_cmake()
vcpkg_fixup_cmake_targets(CONFIG_PATH lib/cmake/GEOS)
vcpkg_cmake_install()
vcpkg_cmake_config_fixup(CONFIG_PATH lib/cmake/GEOS)
vcpkg_fixup_pkgconfig()

if(VCPKG_LIBRARY_LINKAGE STREQUAL static)
file(REMOVE_RECURSE ${CURRENT_PACKAGES_DIR}/bin ${CURRENT_PACKAGES_DIR}/debug/bin)
function(geos_add_debug_postfix config_file)
file(READ "${config_file}" contents)
string(REGEX REPLACE "(-lgeos(_c)?)d?([^-_d])" "\\1d\\3" fixed_contents "${contents}")
file(WRITE "${config_file}" "${fixed_contents}")
endfunction()
if(EXISTS "${CURRENT_PACKAGES_DIR}/debug/lib/pkgconfig/geos.pc")
geos_add_debug_postfix("${CURRENT_PACKAGES_DIR}/debug/lib/pkgconfig/geos.pc")
endif()
if(EXISTS "${CURRENT_PACKAGES_DIR}/bin/geos-config")
file(MAKE_DIRECTORY "${CURRENT_PACKAGES_DIR}/tools/${PORT}/bin")
file(RENAME "${CURRENT_PACKAGES_DIR}/bin/geos-config" "${CURRENT_PACKAGES_DIR}/tools/${PORT}/bin/geos-config")
endif()
if(EXISTS "${CURRENT_PACKAGES_DIR}/debug/bin/geos-config")
file(MAKE_DIRECTORY "${CURRENT_PACKAGES_DIR}/tools/${PORT}/debug/bin")
file(RENAME "${CURRENT_PACKAGES_DIR}/debug/bin/geos-config" "${CURRENT_PACKAGES_DIR}/tools/${PORT}/debug/bin/geos-config")
geos_add_debug_postfix("${CURRENT_PACKAGES_DIR}/tools/${PORT}/debug/bin/geos-config")
endif()
JackBoosY marked this conversation as resolved.
Show resolved Hide resolved

file(REMOVE_RECURSE ${CURRENT_PACKAGES_DIR}/debug/include)

if(EXISTS ${CURRENT_PACKAGES_DIR}/bin/geos-config)
file(MAKE_DIRECTORY ${CURRENT_PACKAGES_DIR}/share/geos)
file(RENAME ${CURRENT_PACKAGES_DIR}/bin/geos-config ${CURRENT_PACKAGES_DIR}/share/geos/geos-config)
file(REMOVE ${CURRENT_PACKAGES_DIR}/debug/bin/geos-config)
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()

# Handle copyright
configure_file(${SOURCE_PATH}/COPYING ${CURRENT_PACKAGES_DIR}/share/geos/copyright COPYONLY)
configure_file("${SOURCE_PATH}/COPYING" "${CURRENT_PACKAGES_DIR}/share/geos/copyright" COPYONLY)

vcpkg_copy_pdbs()
file(INSTALL "${CMAKE_CURRENT_LIST_DIR}/usage" DESTINATION "${CURRENT_PACKAGES_DIR}/share/${PORT}")
10 changes: 10 additions & 0 deletions ports/geos/usage
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
The package geos provides CMake targets:

# C API (provides long-term ABI stability)
find_package(GEOS CONFIG REQUIRED)
target_link_libraries(main PRIVATE GEOS::geos_c)

# C++ API (will likely change across versions)
find_package(GEOS CONFIG REQUIRED)
target_link_libraries(main PRIVATE GEOS::geos)

17 changes: 17 additions & 0 deletions ports/geos/vcpkg.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"name": "geos",
"version": "3.9.1",
"port-version": 1,
"description": "Geometry Engine Open Source",
"homepage": "https://www.osgeo.org/projects/geos/",
"dependencies": [
{
"name": "vcpkg-cmake",
"host": true
},
{
"name": "vcpkg-cmake-config",
"host": true
}
]
}
2 changes: 1 addition & 1 deletion versions/baseline.json
Original file line number Diff line number Diff line change
Expand Up @@ -2198,7 +2198,7 @@
},
"geos": {
"baseline": "3.9.1",
"port-version": 0
"port-version": 1
},
"geotrans": {
"baseline": "3.8",
Expand Down
5 changes: 5 additions & 0 deletions versions/g-/geos.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
{
"versions": [
{
"git-tree": "19ac6640378da611cbee774dae84e8e2f18cfe82",
"version": "3.9.1",
"port-version": 1
},
{
"git-tree": "97c3e5f08174b7f7b4634064f4f2ae6da4351e97",
"version-string": "3.9.1",
Expand Down