From a4c3f116fa18a4ca42f47652e937e070507b49e5 Mon Sep 17 00:00:00 2001
From: Connor Broyles <cbroyles94@gmail.com>
Date: Wed, 24 May 2023 15:14:06 -0400
Subject: [PATCH] [osgearth] Update to version 3.4 (#31569)

* [osgearth] Update to version 3.4

* Fix patch indentation

* Add missing dependency

* Fix tool installation
---
 ports/osgearth/find-package.patch        | 18 ++---
 ports/osgearth/fix-osgearth-config.patch | 86 ------------------------
 ports/osgearth/portfile.cmake            | 10 +--
 ports/osgearth/remove-lerc-gltf.patch    | 18 +++--
 ports/osgearth/vcpkg.json                |  4 +-
 versions/baseline.json                   |  4 +-
 versions/o-/osgearth.json                |  5 ++
 7 files changed, 31 insertions(+), 114 deletions(-)
 delete mode 100644 ports/osgearth/fix-osgearth-config.patch

diff --git a/ports/osgearth/find-package.patch b/ports/osgearth/find-package.patch
index 5b0de3e10a9da0..135b1447705ba8 100644
--- a/ports/osgearth/find-package.patch
+++ b/ports/osgearth/find-package.patch
@@ -1,8 +1,8 @@
 diff --git a/CMakeLists.txt b/CMakeLists.txt
-index 36ea6c81f..8ed39eb24 100755
+index cf8245b8b..233390a5f 100755
 --- a/CMakeLists.txt
 +++ b/CMakeLists.txt
-@@ -124,9 +124,9 @@ option(OSGEARTH_ENABLE_GEOCODER "Enable the geocoder (GDAL/OGR must be built wit
+@@ -127,9 +127,9 @@ mark_as_advanced(OSGEARTH_ASSUME_SINGLE_GL_CONTEXT)
  
  # Mobile/GLES:
  IF (OSGEARTH_USE_GLES)
@@ -14,7 +14,7 @@ index 36ea6c81f..8ed39eb24 100755
  ENDIF (OSGEARTH_USE_GLES)
  
  
-@@ -144,35 +144,54 @@ if(GIT_FOUND AND EXISTS "${PROJECT_SOURCE_DIR}/.git")
+@@ -147,35 +147,54 @@ if(GIT_FOUND AND EXISTS "${PROJECT_SOURCE_DIR}/.git")
  endif()
  
  # required
@@ -44,7 +44,7 @@ index 36ea6c81f..8ed39eb24 100755
 -find_package(Protobuf)
 -find_package(WEBP)
 -find_package(Blend2D)
--find_package(blosc)
+-find_package(Blosc)
 +find_package(GEOS CONFIG REQUIRED)
 +set(GEOS_LIBRARY GEOS::geos_c)
 +find_package(SQLITE3 NAMES unofficial-sqlite3 REQUIRED)
@@ -67,8 +67,8 @@ index 36ea6c81f..8ed39eb24 100755
  endif()
  
  if(OSGEARTH_BUILD_ZIP_PLUGIN)
--    find_package(LIBZIP)
-+    find_package(LIBZIP CONFIG REQUIRED)
+-    find_package(LibZip)
++    find_package(libzip CONFIG REQUIRED)
 +    set(LIBZIP_LIBRARY libzip::zip)
  endif()
  
@@ -83,7 +83,7 @@ index 36ea6c81f..8ed39eb24 100755
  endif()
  
  # Sqlite enables the MBTiles format:
-@@ -214,7 +233,7 @@ SET (PROTOBUF_USE_DLLS FALSE CACHE BOOL "Set this to true if Protobuf is compile
+@@ -221,7 +240,7 @@ SET (PROTOBUF_USE_DLLS FALSE CACHE BOOL "Set this to true if Protobuf is compile
  # Duktape is the JavaScript interpreter
  SET (WITH_EXTERNAL_DUKTAPE FALSE CACHE BOOL "Use bundled or system wide version of Duktape")
  IF (WITH_EXTERNAL_DUKTAPE)
@@ -92,7 +92,7 @@ index 36ea6c81f..8ed39eb24 100755
  ENDIF (WITH_EXTERNAL_DUKTAPE)
  
  # Whether to install shaders (glsl files).
-@@ -225,7 +244,8 @@ OPTION(OSGEARTH_INSTALL_SHADERS "Whether to deploy GLSL shaders when doing a Mak
+@@ -232,7 +251,8 @@ OPTION(OSGEARTH_INSTALL_SHADERS "Whether to deploy GLSL shaders when doing a Mak
  # TinyXML is an XML parsing library
  SET (WITH_EXTERNAL_TINYXML FALSE CACHE BOOL "Use bundled or system wide version of TinyXML")
  IF (WITH_EXTERNAL_TINYXML)
@@ -102,7 +102,7 @@ index 36ea6c81f..8ed39eb24 100755
  ENDIF (WITH_EXTERNAL_TINYXML)
  
  # postfix settings for various configs
-@@ -300,6 +320,7 @@ IF(OSGEARTH_BUILD_SHARED_LIBS)
+@@ -307,6 +327,7 @@ IF(OSGEARTH_BUILD_SHARED_LIBS)
      SET(OSGEARTH_DYNAMIC_OR_STATIC "SHARED")
  ELSE()
      SET(OSGEARTH_DYNAMIC_OR_STATIC "STATIC")
diff --git a/ports/osgearth/fix-osgearth-config.patch b/ports/osgearth/fix-osgearth-config.patch
deleted file mode 100644
index 1da0de4568f2e6..00000000000000
--- a/ports/osgearth/fix-osgearth-config.patch
+++ /dev/null
@@ -1,86 +0,0 @@
-diff --git a/osgEarthConfig.cmake.in b/osgEarthConfig.cmake.in
-index 3f27dffe9..c787e7668 100644
---- a/osgEarthConfig.cmake.in
-+++ b/osgEarthConfig.cmake.in
-@@ -6,52 +6,54 @@ set(XPREFIX OSGEARTH)
- 
- 
- 
--if (osgearth_USE_STATIC_LIBS)
-+if (osgEarth_USE_STATIC_LIBS)
-     set(XPREFIX ${XPREFIX}_STATIC)
- endif()
- 
--set(osgearth_DEFINITIONS ${${XPREFIX}_CFLAGS})
-+set(osgEarth_DEFINITIONS ${${XPREFIX}_CFLAGS})
- 
--find_path(osgearth_INCLUDE_DIR
--    NAMES OSGEARTH/RTREE.H
-+find_path(osgEarth_INCLUDE_DIR
-+    NAMES osgEarth/rtree.h
-     HINTS ${${XPREFIX}_INCLUDE_DIRS}
- )
- 
--set(OSGEARTH_NAMES osgearth)
-+set(OSGEARTH_NAMES osgEarth)
- 
--find_library(osgearth_LIBRARY
-+find_library(osgEarth_LIBRARY
-     NAMES ${OSGEARTH_NAMES}
-     HINTS ${${XPREFIX}_LIBRARY_DIRS}
- )
- 
--set(osgearth_LIBRARIES    ${osgearth_LIBRARY})
--set(osgearth_LIBRARY_DIRS ${${XPREFIX}_LIBRARY_DIRS})
--set(osgearth_LIBRARY_DIR  ${osgearth_LIBRARY_DIRS})
--set(osgearth_INCLUDE_DIRS ${osgearth_INCLUDE_DIR})
--set(osgearth_LDFLAGS      ${${XPREFIX}_LDFLAGS})
-+set(osgEarth_LIBRARIES    ${osgEarth_LIBRARY})
-+set(osgEarth_LIBRARY_DIRS ${${XPREFIX}_LIBRARY_DIRS})
-+set(osgEarth_LIBRARY_DIR  ${osgEarth_LIBRARY_DIRS})
-+set(osgEarth_INCLUDE_DIRS ${osgEarth_INCLUDE_DIR})
-+set(osgEarth_LDFLAGS      ${${XPREFIX}_LDFLAGS})
- 
- include(FindPackageHandleStandardArgs)
--find_package_handle_standard_args(osgearth DEFAULT_MSG
--    osgearth_LIBRARY
--    osgearth_INCLUDE_DIR
-+find_package_handle_standard_args(osgEarth DEFAULT_MSG
-+    osgEarth_LIBRARY
-+    osgEarth_INCLUDE_DIR
- )
- 
--string (REPLACE ";" " " osgearth_LDFLAGS "${osgearth_LDFLAGS}")
-+string (REPLACE ";" " " osgEarth_LDFLAGS "${osgEarth_LDFLAGS}")
- 
--set_target_properties(osgearth
-+add_library(osgEarth UNKNOWN IMPORTED)
-+
-+set_target_properties(osgEarth
-   PROPERTIES
--  IMPORTED_LOCATION             "${osgearth_LIBRARIES}"
--  INTERFACE_INCLUDE_DIRECTORIES "${osgearth_INCLUDE_DIRS}"
--  INTERFACE_LINK_LIBRARIES      "${osgearth_LDFLAGS}"
--  INTERFACE_COMPILE_OPTIONS     "${osgearth_DEFINITIONS}"
-+  IMPORTED_LOCATION             "${osgEarth_LIBRARIES}"
-+  INTERFACE_INCLUDE_DIRECTORIES "${osgEarth_INCLUDE_DIRS}"
-+  INTERFACE_LINK_LIBRARIES      "${osgEarth_LDFLAGS}"
-+  INTERFACE_COMPILE_OPTIONS     "${osgEarth_DEFINITIONS}"
- )
- 
--  message(STATUS "osgearth_FOUND: ${osgearth_FOUND}")
--  message(STATUS "osgearth_INCLUDE_DIRS: ${osgearth_INCLUDE_DIRS}")
--  message(STATUS "osgearth_LIBRARIES: ${osgearth_LIBRARIES}")
--  message(STATUS "osgearth_LDFLAGS: ${osgearth_LDFLAGS}")
--  message(STATUS "osgearth_DEFINITIONS: ${osgearth_DEFINITIONS}")
-+  message(STATUS "osgEarth_FOUND: ${osgEarth_FOUND}")
-+  message(STATUS "osgEarth_INCLUDE_DIRS: ${osgEarth_INCLUDE_DIRS}")
-+  message(STATUS "osgEarth_LIBRARIES: ${osgEarth_LIBRARIES}")
-+  message(STATUS "osgEarth_LDFLAGS: ${osgEarth_LDFLAGS}")
-+  message(STATUS "osgEarth_DEFINITIONS: ${osgEarth_DEFINITIONS}")
- 
- 
- 
--check_required_components(osgearth)
-\ No newline at end of file
-+check_required_components(osgEarth)
diff --git a/ports/osgearth/portfile.cmake b/ports/osgearth/portfile.cmake
index e74a4bd5203004..f38385cd4b1143 100644
--- a/ports/osgearth/portfile.cmake
+++ b/ports/osgearth/portfile.cmake
@@ -1,15 +1,14 @@
 vcpkg_from_github(
     OUT_SOURCE_PATH SOURCE_PATH
     REPO gwaldron/osgearth
-    REF 6b5fb806a9190f7425c32db65d3ea905a55a9c16 #version 3.3
-    SHA512 fe79ce6c73341f83d4aee8cb4da5341dead56a92f998212f7898079b79725f46b2209d64e68fe3b4d99d3c5c25775a8efd1bf3c3b3a049d4f609d3e30172d3bf
+    REF "osgearth-${VERSION}"
+    SHA512 f65c31922bebcbf722474a047dc29c8c1ceec9c037b0704811af2627fc2d0a124b6e95888e7d3b9b0e5acc146a88ebf8669e3f864a75a91751c3a4571d05a630
     HEAD_REF master
     PATCHES
         link-libraries.patch
         find-package.patch
         remove-tool-debug-suffix.patch
 		remove-lerc-gltf.patch
-		fix-osgearth-config.patch
 		export-plugins.patch
 )
 
@@ -86,11 +85,12 @@ if("tools" IN_LIST FEATURES)
             file(INSTALL ${osg_plugins} DESTINATION "${CURRENT_PACKAGES_DIR}/tools/${PORT}/debug/${osg_plugins_subdir}")
         endif()
     endif()
-    vcpkg_copy_tools(TOOL_NAMES osgearth_3pv osgearth_atlas osgearth_boundarygen osgearth_clamp
-        osgearth_conv osgearth_imgui osgearth_tfs osgearth_toc osgearth_version osgearth_viewer
+    vcpkg_copy_tools(TOOL_NAMES osgearth_3pv osgearth_atlas osgearth_bakefeaturetiles osgearth_boundarygen
+        osgearth_clamp osgearth_conv osgearth_imgui osgearth_tfs osgearth_toc osgearth_version osgearth_viewer
 		osgearth_createtile osgearth_mvtindex
         AUTO_CLEAN
     )
+	file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/tools/${PORT}/debug")
 endif()
 
 file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/include")
diff --git a/ports/osgearth/remove-lerc-gltf.patch b/ports/osgearth/remove-lerc-gltf.patch
index 4c6f0fdb26989f..e39fbfab6a4dd2 100644
--- a/ports/osgearth/remove-lerc-gltf.patch
+++ b/ports/osgearth/remove-lerc-gltf.patch
@@ -1,8 +1,8 @@
 diff --git a/src/osgEarthDrivers/CMakeLists.txt b/src/osgEarthDrivers/CMakeLists.txt
-index d178f951b..010896310 100644
+index 79acbe9c4..89e28b141 100644
 --- a/src/osgEarthDrivers/CMakeLists.txt
 +++ b/src/osgEarthDrivers/CMakeLists.txt
-@@ -30,7 +30,6 @@ add_subdirectory(earth)
+@@ -31,7 +31,6 @@ add_subdirectory(earth)
  add_subdirectory(engine_rex)
  add_subdirectory(featurefilter_intersect)
  add_subdirectory(featurefilter_join)
@@ -10,11 +10,9 @@ index d178f951b..010896310 100644
  add_subdirectory(kml)
  add_subdirectory(mapinspector)
  add_subdirectory(monitor)
-@@ -40,7 +39,6 @@ add_subdirectory(sky_simple)
- add_subdirectory(template)
- add_subdirectory(terrainshader)
- add_subdirectory(webp)
--add_subdirectory(lerc)
- add_subdirectory(vdatum_egm2008)
- add_subdirectory(vdatum_egm84)
- add_subdirectory(vdatum_egm96)
+@@ -61,5 +60,4 @@ endif()
+ 
+ IF(NOT APPLE AND NOT ANDROID)
+     add_subdirectory(fastdxt)
+-    add_subdirectory(lerc)
+ ENDIF()
diff --git a/ports/osgearth/vcpkg.json b/ports/osgearth/vcpkg.json
index 86d921ec2c3dac..36d07a1f686268 100644
--- a/ports/osgearth/vcpkg.json
+++ b/ports/osgearth/vcpkg.json
@@ -1,13 +1,13 @@
 {
   "name": "osgearth",
-  "version": "3.3",
-  "port-version": 7,
+  "version": "3.4",
   "description": "osgEarth - Dynamic map generation toolkit for OpenSceneGraph Copyright 2021 Pelican Mapping.",
   "homepage": "https://github.com/gwaldron/osgearth",
   "license": "LGPL-3.0-or-later",
   "supports": "!(arm | x86 | wasm32)",
   "dependencies": [
     "basisu",
+    "blosc",
     "cfitsio",
     "draco",
     "geos",
diff --git a/versions/baseline.json b/versions/baseline.json
index 6e102a0b0bd76f..1048e7662afffb 100644
--- a/versions/baseline.json
+++ b/versions/baseline.json
@@ -6065,8 +6065,8 @@
       "port-version": 3
     },
     "osgearth": {
-      "baseline": "3.3",
-      "port-version": 7
+      "baseline": "3.4",
+      "port-version": 0
     },
     "osi": {
       "baseline": "0.108.6",
diff --git a/versions/o-/osgearth.json b/versions/o-/osgearth.json
index 50486c76689f06..c438f5d8e839b2 100644
--- a/versions/o-/osgearth.json
+++ b/versions/o-/osgearth.json
@@ -1,5 +1,10 @@
 {
   "versions": [
+    {
+      "git-tree": "765cddcfc821c355b20c1fed7a43f181f8eb0817",
+      "version": "3.4",
+      "port-version": 0
+    },
     {
       "git-tree": "c39e21352cff6e65fe8f6315ee9b7828143e0eb8",
       "version": "3.3",