Hi Matthias,
Matthias Kilian wrote on Mon, Oct 23, 2017 at 10:27:01PM +0200:
> tiff export still doesn't work).
That's strange, it just works for me with the patch as you sent it,
both for a small text-only PDF and for a large graphics-heavy PDF.
> For printing (using DXPDFWIDGET_PRINTING=true), the cmake magic
> fails to add -L${LOCALBASE}/lib when linking the xpdf executable.
> I really need some help from a cmake expert here (CMAKE_LIBRARY_PATH
> doesn't help).
As far as i understand, CMAKE_LIBRARY_PATH only tells commands like
find_library() to search such places when detecting libraries, but
doesn't by itself pass any options to the linker.
The problem is here:
c++ [...] -o xpdf-qt/xpdf -L/usr/local/lib/qt5/. -L/usr/X11R6/lib \
-Wl,-rpath,/usr/local/lib/qt5/.:/usr/X11R6/lib: \
-lQt5PrintSupport -lcups -lcups -lfreetype -lpthread \
-lQt5Widgets -lQt5Gui -lQt5Core \
-Wl,-rpath-link,/usr/X11R6/lib:/usr/local/lib
The path /usr/local/lib is already mentioned, but too late, after -lcups.
I poked around quite a bit but still have no idea why cmake screws
up the order of the arguments so badly.
Yet i got a bit further. With the dirty patch below, to be applied
on top of what you sent, i got the port to build, package, pass
lib-depends-check, run, and display a "Print" menu item and dialogue.
But it is not yet useful. The only "Printer Name" that dialogue
offers is "Print to file (PDF)", no default printer, even though:
schwarze@isnote $ pkg_info | grep cups
cups-libs-2.2.4p1 CUPS libraries and headers
schwarze@isnote $ rcctl check lpd
lpd(ok)
Regarding patch-xpdf-qt_CMakeLists_txt, i found no way to get the
desired effect using find_file(), find_library(), find_package(),
or something similar - everything i tried failed in various ways
for reasons that remain mysterious to me. The only way i found was
hardcoding /usr/local/* for the "xpdf" target.
Regarding patch-xpdf-qt_XpdfWidgetPrint_cc, that looks like a
serious instance of the well-known All-the-world-is-Linux-Syndrom.
Maybe we should just give up and drop printing support from xpdf?
I mean, linking it against a behemoth like cups-libs isn't all that
nice, even if we could get it to work...
Yours,
Ingo
--- Makefile.kili Tue Oct 24 14:46:54 2017
+++ Makefile Tue Oct 24 19:17:35 2017
@@ -15,9 +15,11 @@
MODULES= devel/cmake \
X11/qt5
+LIB_DEPENDS += print/cups,-libs
+
RUN_DEPENDS= print/ghostscript/gnu-fonts
-# Add jpeg, png, tiff as rdep and bdep so cmake always pick them up and
+# Add jpeg, png, tiff as rdep and bdep so cmake always picks them up and
# xpdf is able to export to those formats. Not strictly needed for jpeg
# and png, because they are pulled in by qt and its dependencies, but
# better be explicit here.
@@ -37,11 +39,12 @@
# XXX
# Doesn't work, neither with -DCMAKE_LIBRARY_PATH=${LOCALBASE}/lib nor
# with CMAKE_LIBRARY_PATH=${LOCALBASE}/lib in the environment.
-# CONFIGURE_ARGS += -DXPDFWIDGET_PRINTING=true
+CONFIGURE_ARGS += -DXPDFWIDGET_PRINTING=true
CXXFLAGS+= -DLOCALBASE=\\\"${LOCALBASE}\\\"
-WANTLIB= Qt5Core Qt5Gui Qt5Widgets freetype c m png pthread \
+WANTLIB= Qt5Core Qt5Gui Qt5PrintSupport Qt5Widgets \
+ c cups freetype m png pthread \
${COMPILER_LIBCXX} z
NO_TEST= Yes
Index: patches/patch-xpdf-qt_CMakeLists_txt
===================================================================
RCS file: patches/patch-xpdf-qt_CMakeLists_txt
diff -N patches/patch-xpdf-qt_CMakeLists_txt
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ patches/patch-xpdf-qt_CMakeLists_txt 24 Oct 2017 17:26:44 -0000
@@ -0,0 +1,23 @@
+$OpenBSD$
+
+Index: xpdf-qt/CMakeLists.txt
+--- xpdf-qt/CMakeLists.txt.orig
++++ xpdf-qt/CMakeLists.txt
+@@ -40,6 +40,7 @@ if ((QT4_FOUND OR Qt5Widgets_FOUND)
+ else ()
+ add_definitions(-DXPDFWIDGET_PRINTING=1)
+ set(XPDFWIDGET_PRINT_MODULES XpdfWidgetPrint.cc)
++ include_directories(/usr/local/include)
+ endif ()
+ else ()
+ set(XPDFWIDGET_PRINT_MODULES "")
+@@ -80,7 +81,8 @@ if ((QT4_FOUND OR Qt5Widgets_FOUND)
+ ${XPDFWIDGET_MOC}
+ ${XPDF_ICONS}
+ )
+- target_link_libraries(xpdf ${QT_LIBRARIES} ${EXTRA_QT_LIBRARIES}
++ target_link_libraries(xpdf -L/usr/local/lib
++ ${QT_LIBRARIES} ${EXTRA_QT_LIBRARIES}
+ ${FREETYPE_LIBRARY} ${FREETYPE_OTHER_LIBS}
+ ${DTYPE_LIBRARY} ${LCMS_LIBRARY}
+ ${CMAKE_THREAD_LIBS_INIT})
Index: patches/patch-xpdf-qt_XpdfWidgetPrint_cc
===================================================================
RCS file: patches/patch-xpdf-qt_XpdfWidgetPrint_cc
diff -N patches/patch-xpdf-qt_XpdfWidgetPrint_cc
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ patches/patch-xpdf-qt_XpdfWidgetPrint_cc 24 Oct 2017 17:26:44 -0000
@@ -0,0 +1,23 @@
+$OpenBSD$
+
+Index: xpdf-qt/XpdfWidgetPrint.cc
+--- xpdf-qt/XpdfWidgetPrint.cc.orig
++++ xpdf-qt/XpdfWidgetPrint.cc
+@@ -21,7 +21,7 @@
+ #elif defined(__APPLE__)
+ # include <CoreFoundation/CoreFoundation.h>
+ # include <ApplicationServices/ApplicationServices.h>
+-#elif defined(__linux__)
++#elif defined(__linux__) || defined(__OpenBSD__)
+ # include "PSOutputDev.h"
+ # include <cups/cups.h>
+ #endif
+@@ -315,7 +315,7 @@ XpdfWidget::ErrorCode printPDF(PDFDoc *doc, QPrinter *
+ // Linux
+ //------------------------------------------------------------------------
+
+-#elif defined(__linux__)
++#elif defined(__linux__) || defined(__OpenBSD__)
+
+ static void fileOut(void *stream, const char *data, int len) {
+ fwrite(data, 1, len, (FILE *)stream);