Hi,
this diff enforces C++11 and adds some patches from upstream to let
gdcm build with poppler->=0.58.
Tests with the (old) poppler-0.57 we still have in the ports tree
are as welcome as comments and oks (U've only tested it with
poppler-0.59 in my tree).
Ciao,
Kili
Index: Makefile
===================================================================
RCS file: /cvs/ports/graphics/gdcm/Makefile,v
retrieving revision 1.1.1.1
diff -u -p -r1.1.1.1 Makefile
--- Makefile 1 Aug 2017 16:38:46 -0000 1.1.1.1
+++ Makefile 20 Sep 2017 21:20:09 -0000
@@ -28,6 +28,10 @@ MASTER_SITES = ${MASTER_SITE_SOURCEFOR
MODULES = devel/cmake
+# c++-11
+COMPILER = base-clang ports-gcc
+CXXFLAGS += -std=c++11
+
WANTLIB += ${COMPILER_LIBCXX} c crypto expat json-c m openjp2
WANTLIB += poppler ssl uuid xml2 z
Index: patches/patch-Applications_Cxx_CMakeLists_txt
===================================================================
RCS file: patches/patch-Applications_Cxx_CMakeLists_txt
diff -N patches/patch-Applications_Cxx_CMakeLists_txt
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ patches/patch-Applications_Cxx_CMakeLists_txt 20 Sep 2017 21:20:09
-0000
@@ -0,0 +1,21 @@
+$OpenBSD$
+
+Fix build with poppler->=0.58.
+From upstream commit 8854c50aaa135dd81350247dd6e803f10cbd6abc.
+
+Index: Applications/Cxx/CMakeLists.txt
+--- Applications/Cxx/CMakeLists.txt.orig
++++ Applications/Cxx/CMakeLists.txt
+@@ -84,6 +84,12 @@ if(GDCM_USE_SYSTEM_POPPLER)
+ if(LIBPOPPLER_CATALOG_HAS_STRUCTTREEROOT)
+ list(APPEND libpoppler_flags -DLIBPOPPLER_CATALOG_HAS_STRUCTTREEROOT)
+ endif()
++ CHECK_CXX_SOURCE_COMPILES(
++ "\#include <poppler/Object.h>\nint main() { Object o(42); }"
++ LIBPOPPLER_NEW_OBJECT_API)
++if(LIBPOPPLER_NEW_OBJECT_API)
++ list(APPEND libpoppler_flags -DLIBPOPPLER_NEW_OBJECT_API)
++ endif()
+ if(libpoppler_flags)
+ string(REPLACE ";" " " libpoppler_flags_string "${libpoppler_flags}")
+ set_source_files_properties(
Index: patches/patch-Applications_Cxx_gdcminfo_cxx
===================================================================
RCS file: patches/patch-Applications_Cxx_gdcminfo_cxx
diff -N patches/patch-Applications_Cxx_gdcminfo_cxx
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ patches/patch-Applications_Cxx_gdcminfo_cxx 20 Sep 2017 21:20:09 -0000
@@ -0,0 +1,86 @@
+$OpenBSD$
+
+Fix build with poppler->=0.58.
+From upstream commit 8854c50aaa135dd81350247dd6e803f10cbd6abc.
+
+Index: Applications/Cxx/gdcminfo.cxx
+--- Applications/Cxx/gdcminfo.cxx.orig
++++ Applications/Cxx/gdcminfo.cxx
+@@ -194,7 +194,11 @@ static std::string getInfoDate(Dict *infoDict, const c
+ //char buf[256];
+ std::string out;
+
++#ifdef LIBPOPPLER_NEW_OBJECT_API
++ if ((obj = infoDict->lookup((char*)key)).isString())
++#else
+ if (infoDict->lookup((char*)key, &obj)->isString())
++#endif
+ {
+ s = obj.getString()->getCString();
+ if (s[0] == 'D' && s[1] == ':')
+@@ -242,7 +246,9 @@ static std::string getInfoDate(Dict *infoDict, const c
+ out = date;
+ }
+ }
++#ifndef LIBPOPPLER_NEW_OBJECT_API
+ obj.free();
++#endif
+ return out;
+ }
+
+@@ -256,7 +262,11 @@ static std::string getInfoString(Dict *infoDict, const
+ int i, n;
+ std::string out;
+
++#ifdef LIBPOPPLER_NEW_OBJECT_API
++ if ((obj = infoDict->lookup((char*)key)).isString())
++#else
+ if (infoDict->lookup((char*)key, &obj)->isString())
++#endif
+ {
+ s1 = obj.getString();
+ if ((s1->getChar(0) & 0xff) == 0xfe &&
+@@ -288,7 +298,9 @@ static std::string getInfoString(Dict *infoDict, const
+ out.append( std::string(buf, n) );
+ }
+ }
++#ifndef LIBPOPPLER_NEW_OBJECT_API
+ obj.free();
++#endif
+ return out;
+ }
+ #endif
+@@ -452,7 +464,11 @@ static int ProcessOneFile( std::string const & filenam
+ MemStream *appearStream;
+
+ appearStream = new MemStream((char*)bv->GetPointer(), 0,
++#ifdef LIBPOPPLER_NEW_OBJECT_API
++ bv->GetLength(), std::move(appearDict));
++#else
+ bv->GetLength(), &appearDict);
++#endif
+ GooString *ownerPW, *userPW;
+ ownerPW = NULL;
+ userPW = NULL;
+@@ -480,7 +496,11 @@ static int ProcessOneFile( std::string const & filenam
+ Object info;
+ if (doc->isOk())
+ {
++#ifdef LIBPOPPLER_NEW_OBJECT_API
++ info = doc->getDocInfo();
++#else
+ doc->getDocInfo(&info);
++#endif
+ if (info.isDict())
+ {
+ title = getInfoString(info.getDict(), "Title", uMap);
+@@ -491,7 +511,9 @@ static int ProcessOneFile( std::string const & filenam
+ producer = getInfoString(info.getDict(), "Producer", uMap);
+ creationdate = getInfoDate( info.getDict(), "CreationDate" );
+ moddate = getInfoDate( info.getDict(), "ModDate" );
++#ifndef LIBPOPPLER_NEW_OBJECT_API
+ info.free();
++#endif
+ }
+ #ifdef LIBPOPPLER_CATALOG_HAS_STRUCTTREEROOT
+ const char *tagged = doc->getStructTreeRoot() ? "yes" : "no";
Index: patches/patch-Applications_Cxx_gdcmpdf_cxx
===================================================================
RCS file: patches/patch-Applications_Cxx_gdcmpdf_cxx
diff -N patches/patch-Applications_Cxx_gdcmpdf_cxx
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ patches/patch-Applications_Cxx_gdcmpdf_cxx 20 Sep 2017 21:20:09 -0000
@@ -0,0 +1,84 @@
+$OpenBSD$
+
+Fix build with poppler->=0.58.
+From upstream commit 8854c50aaa135dd81350247dd6e803f10cbd6abc.
+
+Index: Applications/Cxx/gdcmpdf.cxx
+--- Applications/Cxx/gdcmpdf.cxx.orig
++++ Applications/Cxx/gdcmpdf.cxx
+@@ -43,7 +43,11 @@ static std::string getInfoDate(Dict *infoDict, const c
+ //char buf[256];
+ std::string out;
+
++#ifdef LIBPOPPLER_NEW_OBJECT_API
++ if ((obj = infoDict->lookup((char*)key)).isString())
++#else
+ if (infoDict->lookup((char*)key, &obj)->isString())
++#endif
+ {
+ s = obj.getString()->getCString();
+ if (s[0] == 'D' && s[1] == ':')
+@@ -91,7 +95,9 @@ static std::string getInfoDate(Dict *infoDict, const c
+ out = date;
+ }
+ }
++#ifndef LIBPOPPLER_NEW_OBJECT_API
+ obj.free();
++#endif
+ return out;
+ }
+
+@@ -105,7 +111,11 @@ static std::string getInfoString(Dict *infoDict, const
+ int i, n;
+ std::string out;
+
++#ifdef LIBPOPPLER_NEW_OBJECT_API
++ if ((obj = infoDict->lookup((char*)key)).isString())
++#else
+ if (infoDict->lookup((char*)key, &obj)->isString())
++#endif
+ {
+ s1 = obj.getString();
+ if ((s1->getChar(0) & 0xff) == 0xfe &&
+@@ -137,7 +147,9 @@ static std::string getInfoString(Dict *infoDict, const
+ out.append( std::string(buf, n) );
+ }
+ }
++#ifndef LIBPOPPLER_NEW_OBJECT_API
+ obj.free();
++#endif
+ unicode = unicode || isUnicode;
+ return out;
+ }
+@@ -340,7 +352,9 @@ int main (int argc, char *argv[])
+ //ownerPW = new GooString( "toto" );
+ Object obj;
+
++#ifndef LIBPOPPLER_NEW_OBJECT_API
+ obj.initNull();
++#endif
+ doc = new PDFDoc(fileName, ownerPW, userPW);
+
+ if (doc->isEncrypted())
+@@ -386,7 +400,11 @@ http://msdn.microsoft.com/en-us/library/078sfkak(VS.80
+ GBool isUnicode = gFalse;
+ if (doc->isOk())
+ {
++#ifdef LIBPOPPLER_NEW_OBJECT_API
++ info = doc->getDocInfo();
++#else
+ doc->getDocInfo(&info);
++#endif
+ if (info.isDict())
+ {
+ title = getInfoString(info.getDict(), "Title", uMap,
isUnicode);
+@@ -397,7 +415,9 @@ http://msdn.microsoft.com/en-us/library/078sfkak(VS.80
+ producer = getInfoString(info.getDict(), "Producer", uMap,
isUnicode);
+ creationdate = getInfoDate( info.getDict(), "CreationDate" );
+ moddate = getInfoDate( info.getDict(), "ModDate" );
++#ifndef LIBPOPPLER_NEW_OBJECT_API
+ info.free();
++#endif
+ }
+ }
+