Index | Thread | Search

From:
Matthias Kilian <kili@outback.escape.de>
Subject:
Re: geo/gdal: fix with new poppler
To:
Landry Breuil <landry@openbsd.org>
Cc:
ports@openbsd.org
Date:
Tue, 7 Apr 2026 22:19:40 +0200

Download raw body.

Thread
Hi,

On Tue, Apr 07, 2026 at 09:58:26AM +0200, Landry Breuil wrote:
> Le Tue, Apr 07, 2026 at 12:07:24AM +0200, Matthias Kilian a écrit :
> > Prepare for the next poppler update.
> > 
> > ok?
> 
> not against it, but i'd prefer https://github.com/OSGeo/gdal/pull/14246
> instead :) (im not sure we need the CMakeLists.txt hunk but who knows..)

Here we go (it still at least compiles).

Ciao,
	Kili

Index: patches/patch-frmts_pdf_CMakeLists_txt
===================================================================
RCS file: patches/patch-frmts_pdf_CMakeLists_txt
diff -N patches/patch-frmts_pdf_CMakeLists_txt
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ patches/patch-frmts_pdf_CMakeLists_txt	7 Apr 2026 20:13:48 -0000
@@ -0,0 +1,23 @@
+Fix build with poppler-26.04.0 (this one is not really required,
+but it was part of the commit).
+
+From upstream commit 4c6443c7b9795d43b15fdf9c47347edae1068dd3.
+
+Index: frmts/pdf/CMakeLists.txt
+--- frmts/pdf/CMakeLists.txt.orig
++++ frmts/pdf/CMakeLists.txt
+@@ -67,11 +67,11 @@ if (GDAL_USE_POPPLER)
+   if ("${Poppler_VERSION_MINOR}" MATCHES "0?[0-9]+")
+     string(REGEX REPLACE "0?([0-9]+)" "\\1" Poppler_VERSION_MINOR ${Poppler_VERSION_MINOR})
+   endif ()
+-  # POPPLER_24_05_OR_LATER used transiently (by fuzzers/build.sh) until 24.05 is actually released
+-  if (Poppler_VERSION_STRING VERSION_GREATER_EQUAL "24.05" OR POPPLER_24_05_OR_LATER)
++  if (Poppler_VERSION_STRING VERSION_GREATER_EQUAL "24.05")
+     target_compile_features(gdal_PDF PRIVATE cxx_std_20)
+   endif ()
+-  target_compile_definitions(gdal_PDF PRIVATE -DHAVE_POPPLER -DPOPPLER_MAJOR_VERSION=${Poppler_VERSION_MAJOR}
++  target_compile_definitions(gdal_PDF PRIVATE -DHAVE_POPPLER
++                                              -DPOPPLER_MAJOR_VERSION=${Poppler_VERSION_MAJOR}
+                                               -DPOPPLER_MINOR_VERSION=${Poppler_VERSION_MINOR})
+ endif ()
+ if (GDAL_USE_PODOFO)
Index: patches/patch-frmts_pdf_pdfobject_cpp
===================================================================
RCS file: patches/patch-frmts_pdf_pdfobject_cpp
diff -N patches/patch-frmts_pdf_pdfobject_cpp
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ patches/patch-frmts_pdf_pdfobject_cpp	7 Apr 2026 20:13:48 -0000
@@ -0,0 +1,42 @@
+Fix build with poppler-26.04.0.
+
+From upstream commit 4c6443c7b9795d43b15fdf9c47347edae1068dd3.
+
+Index: frmts/pdf/pdfobject.cpp
+--- frmts/pdf/pdfobject.cpp.orig
++++ frmts/pdf/pdfobject.cpp
+@@ -20,6 +20,7 @@
+ #include "gdal_pdf.h"
+ 
+ #include <limits>
++#include <type_traits>
+ #include <vector>
+ #include "pdfobject.h"
+ 
+@@ -1122,8 +1123,24 @@ const std::string &GDALPDFObjectPoppler::GetString()
+ {
+     if (GetType() == PDFObjectType_String)
+     {
+-        const GooString *gooString = m_poConst->getString();
+-        const std::string &osStdStr = gooString->toStr();
++        const std::string &osStdStr = *(
++            [](auto &&obj) -> const std::string *
++            {
++                if constexpr (std::is_same_v<decltype(obj),
++                                             const std::string &>)
++                {
++                    // Since Poppler 26.04
++                    return &obj;
++                }
++                else
++                {
++                    static_assert(
++                        std::is_same_v<decltype(obj), const GooString *&&>);
++                    static_assert(std::is_same_v<decltype(obj->toStr()),
++                                                 const std::string &>);
++                    return &(obj->toStr());
++                }
++            }(m_poConst->getString()));
+         const bool bLEUnicodeMarker =
+             osStdStr.size() >= 2 && static_cast<uint8_t>(osStdStr[0]) == 0xFE &&
+             static_cast<uint8_t>(osStdStr[1]) == 0xFF;