From 89893b671ad0cc9dc36237fab19bd4685ee93695 Mon Sep 17 00:00:00 2001 From: Kai Pastor Date: Sat, 1 May 2021 15:05:49 +0200 Subject: [PATCH 1/9] Provide geos-config, and fix dynamic builds on Unix --- ports/geos/CONTROL | 4 ---- ports/geos/portfile.cmake | 31 ++++++++++++++++++++----------- ports/geos/vcpkg.json | 7 +++++++ 3 files changed, 27 insertions(+), 15 deletions(-) delete mode 100644 ports/geos/CONTROL create mode 100644 ports/geos/vcpkg.json diff --git a/ports/geos/CONTROL b/ports/geos/CONTROL deleted file mode 100644 index c3ed21e0f5d4e8..00000000000000 --- a/ports/geos/CONTROL +++ /dev/null @@ -1,4 +0,0 @@ -Source: geos -Version: 3.9.1 -Homepage: https://www.osgeo.org/projects/geos/ -Description: Geometry Engine Open Source diff --git a/ports/geos/portfile.cmake b/ports/geos/portfile.cmake index f5b9c21ac2f6af..2258130dafbcf1 100644 --- a/ports/geos/portfile.cmake +++ b/ports/geos/portfile.cmake @@ -7,7 +7,7 @@ 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 @@ -24,7 +24,7 @@ else() endif() vcpkg_configure_cmake( - SOURCE_PATH ${SOURCE_PATH} + SOURCE_PATH "${SOURCE_PATH}" PREFER_NINJA OPTIONS -DCMAKE_DEBUG_POSTFIX=d @@ -34,19 +34,28 @@ vcpkg_configure_cmake( vcpkg_install_cmake() vcpkg_fixup_cmake_targets(CONFIG_PATH lib/cmake/GEOS) -if(VCPKG_LIBRARY_LINKAGE STREQUAL static) - file(REMOVE_RECURSE ${CURRENT_PACKAGES_DIR}/bin ${CURRENT_PACKAGES_DIR}/debug/bin) +if(EXISTS "${CURRENT_PACKAGES_DIR}/bin/geos-config") + file(READ "${CURRENT_PACKAGES_DIR}/bin/geos-config" GEOS_CONFIG) + string(REGEX REPLACE "(\nprefix=)[^\n]*" [[\1$(CDPATH= cd -- "$(dirname -- "$0")"/../.. && pwd -P)]] GEOS_CONFIG "${GEOS_CONFIG}") + file(WRITE "${CURRENT_PACKAGES_DIR}/bin/geos-config" "${GEOS_CONFIG}") + file(MAKE_DIRECTORY ${CURRENT_PACKAGES_DIR}/share/${PORT}) + file(RENAME ${CURRENT_PACKAGES_DIR}/bin/geos-config ${CURRENT_PACKAGES_DIR}/share/${PORT}/geos-config) +endif() +if(EXISTS ${CURRENT_PACKAGES_DIR}/debug/bin/geos-config) + file(READ "${CURRENT_PACKAGES_DIR}/debug/bin/geos-config" GEOS_CONFIG) + string(REGEX REPLACE "(\nprefix=)[^\n]*" [[\1$(CDPATH= cd -- "$(dirname -- "$0")"/../.. && pwd -P)]] GEOS_CONFIG "${GEOS_CONFIG}") + string(REGEX REPLACE "(-lgeos(_c)?d?)( |\n)" "\\1d\\3" GEOS_CONFIG "${GEOS_CONFIG}") + file(WRITE "${CURRENT_PACKAGES_DIR}/debug/bin/geos-config" "${GEOS_CONFIG}") + file(MAKE_DIRECTORY ${CURRENT_PACKAGES_DIR}/share/${PORT}) + file(RENAME ${CURRENT_PACKAGES_DIR}/debug/bin/geos-config ${CURRENT_PACKAGES_DIR}/share/${PORT}/geos-config-debug) endif() -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") +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() diff --git a/ports/geos/vcpkg.json b/ports/geos/vcpkg.json new file mode 100644 index 00000000000000..e377113b8e1b95 --- /dev/null +++ b/ports/geos/vcpkg.json @@ -0,0 +1,7 @@ +{ + "name": "geos", + "version": "3.9.1", + "port-version": 1, + "description": "Geometry Engine Open Source", + "homepage": "https://www.osgeo.org/projects/geos/" +} From 9a238b59bdddcfc088c32422b1f7578f598ae3a4 Mon Sep 17 00:00:00 2001 From: Kai Pastor Date: Sat, 1 May 2021 17:26:20 +0200 Subject: [PATCH 2/9] x-add-version --- versions/baseline.json | 2 +- versions/g-/geos.json | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/versions/baseline.json b/versions/baseline.json index 3ab2d2b600ca52..051e4e264ef590 100644 --- a/versions/baseline.json +++ b/versions/baseline.json @@ -2198,7 +2198,7 @@ }, "geos": { "baseline": "3.9.1", - "port-version": 0 + "port-version": 1 }, "geotrans": { "baseline": "3.8", diff --git a/versions/g-/geos.json b/versions/g-/geos.json index 09e59a000bc404..2a91115f05eb52 100644 --- a/versions/g-/geos.json +++ b/versions/g-/geos.json @@ -1,5 +1,10 @@ { "versions": [ + { + "git-tree": "b14dbb117b14e89f2a9072ff3c4f3603431ab118", + "version": "3.9.1", + "port-version": 1 + }, { "git-tree": "97c3e5f08174b7f7b4634064f4f2ae6da4351e97", "version-string": "3.9.1", From 8f8e29b91aa8affbc397490b407065d47a34d6fd Mon Sep 17 00:00:00 2001 From: Kai Pastor Date: Mon, 3 May 2021 19:11:23 +0200 Subject: [PATCH 3/9] Fix debug suffix handling --- ports/geos/portfile.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ports/geos/portfile.cmake b/ports/geos/portfile.cmake index 2258130dafbcf1..f65878bf84a39e 100644 --- a/ports/geos/portfile.cmake +++ b/ports/geos/portfile.cmake @@ -44,7 +44,7 @@ endif() if(EXISTS ${CURRENT_PACKAGES_DIR}/debug/bin/geos-config) file(READ "${CURRENT_PACKAGES_DIR}/debug/bin/geos-config" GEOS_CONFIG) string(REGEX REPLACE "(\nprefix=)[^\n]*" [[\1$(CDPATH= cd -- "$(dirname -- "$0")"/../.. && pwd -P)]] GEOS_CONFIG "${GEOS_CONFIG}") - string(REGEX REPLACE "(-lgeos(_c)?d?)( |\n)" "\\1d\\3" GEOS_CONFIG "${GEOS_CONFIG}") + string(REGEX REPLACE "(-lgeos(_c)?)d?( |\n)" "\\1d\\3" GEOS_CONFIG "${GEOS_CONFIG}") file(WRITE "${CURRENT_PACKAGES_DIR}/debug/bin/geos-config" "${GEOS_CONFIG}") file(MAKE_DIRECTORY ${CURRENT_PACKAGES_DIR}/share/${PORT}) file(RENAME ${CURRENT_PACKAGES_DIR}/debug/bin/geos-config ${CURRENT_PACKAGES_DIR}/share/${PORT}/geos-config-debug) From 0fbdfa8f12f7a5d91c11a298dce9eca58dad501f Mon Sep 17 00:00:00 2001 From: Kai Pastor Date: Mon, 3 May 2021 19:12:32 +0200 Subject: [PATCH 4/9] Update git-tree --- versions/g-/geos.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/versions/g-/geos.json b/versions/g-/geos.json index 2a91115f05eb52..3278daa5f5c453 100644 --- a/versions/g-/geos.json +++ b/versions/g-/geos.json @@ -1,7 +1,7 @@ { "versions": [ { - "git-tree": "b14dbb117b14e89f2a9072ff3c4f3603431ab118", + "git-tree": "4827098f4cb8dad529b0b1b9a4d0b6db203acaa0", "version": "3.9.1", "port-version": 1 }, From d222d85319ed24de8259a6832b016f9fbf5477b0 Mon Sep 17 00:00:00 2001 From: Kai Pastor Date: Sat, 22 May 2021 07:30:15 +0200 Subject: [PATCH 5/9] Don't build benchmarks --- ports/geos/portfile.cmake | 1 + 1 file changed, 1 insertion(+) diff --git a/ports/geos/portfile.cmake b/ports/geos/portfile.cmake index f65878bf84a39e..a137c478f57119 100644 --- a/ports/geos/portfile.cmake +++ b/ports/geos/portfile.cmake @@ -29,6 +29,7 @@ vcpkg_configure_cmake( OPTIONS -DCMAKE_DEBUG_POSTFIX=d -DBUILD_TESTING=OFF + -DBUILD_BENCHMARKS=OFF ${_CMAKE_EXTRA_OPTIONS} ) vcpkg_install_cmake() From 6c2680b914d1934cdc371547cee521798af82070 Mon Sep 17 00:00:00 2001 From: Kai Pastor Date: Sat, 22 May 2021 10:26:57 +0200 Subject: [PATCH 6/9] Revise pc file and geos-config handling Fixup pc files. Add -lgeos to Libs.private to satisfy common usage requirement (already present in geos-config). Install executable geos-config into tools. Rewrite geos-config relocatability as patch. --- ports/geos/make-geos-config-relocatable.patch | 16 ++++++++++ ports/geos/pc-file-libs-private.patch | 12 ++++++++ ports/geos/portfile.cmake | 29 +++++++++++-------- 3 files changed, 45 insertions(+), 12 deletions(-) create mode 100644 ports/geos/make-geos-config-relocatable.patch create mode 100644 ports/geos/pc-file-libs-private.patch diff --git a/ports/geos/make-geos-config-relocatable.patch b/ports/geos/make-geos-config-relocatable.patch new file mode 100644 index 00000000000000..f3d97b6c2cdfe9 --- /dev/null +++ b/ports/geos/make-geos-config-relocatable.patch @@ -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() + { diff --git a/ports/geos/pc-file-libs-private.patch b/ports/geos/pc-file-libs-private.patch new file mode 100644 index 00000000000000..51302aeb1ad4f4 --- /dev/null +++ b/ports/geos/pc-file-libs-private.patch @@ -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 + diff --git a/ports/geos/portfile.cmake b/ports/geos/portfile.cmake index a137c478f57119..ee1a010c5fa0c4 100644 --- a/ports/geos/portfile.cmake +++ b/ports/geos/portfile.cmake @@ -12,6 +12,8 @@ vcpkg_extract_source_archive_ex( 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 @@ -34,21 +36,24 @@ vcpkg_configure_cmake( ) vcpkg_install_cmake() vcpkg_fixup_cmake_targets(CONFIG_PATH lib/cmake/GEOS) +vcpkg_fixup_pkgconfig() +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(READ "${CURRENT_PACKAGES_DIR}/bin/geos-config" GEOS_CONFIG) - string(REGEX REPLACE "(\nprefix=)[^\n]*" [[\1$(CDPATH= cd -- "$(dirname -- "$0")"/../.. && pwd -P)]] GEOS_CONFIG "${GEOS_CONFIG}") - file(WRITE "${CURRENT_PACKAGES_DIR}/bin/geos-config" "${GEOS_CONFIG}") - file(MAKE_DIRECTORY ${CURRENT_PACKAGES_DIR}/share/${PORT}) - file(RENAME ${CURRENT_PACKAGES_DIR}/bin/geos-config ${CURRENT_PACKAGES_DIR}/share/${PORT}/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(READ "${CURRENT_PACKAGES_DIR}/debug/bin/geos-config" GEOS_CONFIG) - string(REGEX REPLACE "(\nprefix=)[^\n]*" [[\1$(CDPATH= cd -- "$(dirname -- "$0")"/../.. && pwd -P)]] GEOS_CONFIG "${GEOS_CONFIG}") - string(REGEX REPLACE "(-lgeos(_c)?)d?( |\n)" "\\1d\\3" GEOS_CONFIG "${GEOS_CONFIG}") - file(WRITE "${CURRENT_PACKAGES_DIR}/debug/bin/geos-config" "${GEOS_CONFIG}") - file(MAKE_DIRECTORY ${CURRENT_PACKAGES_DIR}/share/${PORT}) - file(RENAME ${CURRENT_PACKAGES_DIR}/debug/bin/geos-config ${CURRENT_PACKAGES_DIR}/share/${PORT}/geos-config-debug) +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() file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/include") From 9751a28a644835d8c20c9349d198ee55c8625cdb Mon Sep 17 00:00:00 2001 From: Kai Pastor Date: Sat, 22 May 2021 14:25:26 +0200 Subject: [PATCH 7/9] Port to non-deprecated cmake functions --- ports/geos/portfile.cmake | 7 ++++--- ports/geos/vcpkg.json | 12 +++++++++++- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/ports/geos/portfile.cmake b/ports/geos/portfile.cmake index ee1a010c5fa0c4..a98b3fb9fe567c 100644 --- a/ports/geos/portfile.cmake +++ b/ports/geos/portfile.cmake @@ -25,7 +25,7 @@ else() set(_CMAKE_EXTRA_OPTIONS "") endif() -vcpkg_configure_cmake( +vcpkg_cmake_configure( SOURCE_PATH "${SOURCE_PATH}" PREFER_NINJA OPTIONS @@ -34,8 +34,8 @@ vcpkg_configure_cmake( -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() function(geos_add_debug_postfix config_file) @@ -57,6 +57,7 @@ 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() diff --git a/ports/geos/vcpkg.json b/ports/geos/vcpkg.json index e377113b8e1b95..f22f385585d463 100644 --- a/ports/geos/vcpkg.json +++ b/ports/geos/vcpkg.json @@ -3,5 +3,15 @@ "version": "3.9.1", "port-version": 1, "description": "Geometry Engine Open Source", - "homepage": "https://www.osgeo.org/projects/geos/" + "homepage": "https://www.osgeo.org/projects/geos/", + "dependencies": [ + { + "name": "vcpkg-cmake", + "host": true + }, + { + "name": "vcpkg-cmake-config", + "host": true + } + ] } From ab8c1d38aaca8dcbc52e5a60e585aa1a1b582964 Mon Sep 17 00:00:00 2001 From: Kai Pastor Date: Sat, 22 May 2021 15:18:07 +0200 Subject: [PATCH 8/9] Add usage --- ports/geos/portfile.cmake | 1 + ports/geos/usage | 10 ++++++++++ 2 files changed, 11 insertions(+) create mode 100644 ports/geos/usage diff --git a/ports/geos/portfile.cmake b/ports/geos/portfile.cmake index a98b3fb9fe567c..a2793f94cfbb2e 100644 --- a/ports/geos/portfile.cmake +++ b/ports/geos/portfile.cmake @@ -66,3 +66,4 @@ endif() 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}") diff --git a/ports/geos/usage b/ports/geos/usage new file mode 100644 index 00000000000000..139e40dd27eb92 --- /dev/null +++ b/ports/geos/usage @@ -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) + From f90497f37e34fd12739490c870f8d6efb583f697 Mon Sep 17 00:00:00 2001 From: Kai Pastor Date: Sat, 22 May 2021 15:19:00 +0200 Subject: [PATCH 9/9] Update git-tree --- versions/g-/geos.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/versions/g-/geos.json b/versions/g-/geos.json index 3278daa5f5c453..84f1396ed284ee 100644 --- a/versions/g-/geos.json +++ b/versions/g-/geos.json @@ -1,7 +1,7 @@ { "versions": [ { - "git-tree": "4827098f4cb8dad529b0b1b9a4d0b6db203acaa0", + "git-tree": "19ac6640378da611cbee774dae84e8e2f18cfe82", "version": "3.9.1", "port-version": 1 },