[poppler] CMakeLists.txt config.h.cmake configure.ac poppler/Stream.cc
Albert Astals Cid
aacid at kemper.freedesktop.org
Sun May 21 16:59:29 UTC 2017
CMakeLists.txt | 30 +++++++++++++++++++++++++++---
config.h.cmake | 3 +++
configure.ac | 29 +++++++++++++++++++++++++----
poppler/Stream.cc | 5 +++++
4 files changed, 60 insertions(+), 7 deletions(-)
New commits:
commit 65c5a5266462244130f110599ac5d1011a04216e
Author: Albert Astals Cid <aacid at kde.org>
Date: Sun May 21 18:42:15 2017 +0200
Fail by default if libopenjpeg2/1 is not available
You can "force" to use the unmaintained JPX decoder or none at all
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 15e01222..58952e47 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -37,7 +37,7 @@ option(BUILD_CPP_TESTS "Whether compile the CPP test programs." ON)
option(ENABLE_SPLASH "Build the Splash graphics backend." ON)
option(ENABLE_UTILS "Compile poppler command line utils." ON)
option(ENABLE_CPP "Compile poppler cpp wrapper." ON)
-set(ENABLE_LIBOPENJPEG "auto" CACHE STRING "Use libopenjpeg for JPX streams. Possible values: auto, openjpeg1, openjpeg2. 'auto' prefers openjpeg2 over openjpeg1 if both are available. Unset to not use openjpeg.")
+set(ENABLE_LIBOPENJPEG "auto" CACHE STRING "Use libopenjpeg for JPX streams. Possible values: auto, openjpeg1, openjpeg2, unmaintained, none. 'auto' prefers openjpeg2 over openjpeg1 if both are available. 'unmaintained' gives you the internal unmaintained decoder. Use at your own risk. 'none' compiles no JPX decoder at all. Default: auto")
set(ENABLE_CMS "auto" CACHE STRING "Use color management system. Possible values: auto, lcms1, lcms2. 'auto' prefers lcms2 over lcms1 if both are available. Unset to disable color management system.")
set(ENABLE_DCTDECODER "libjpeg" CACHE STRING "Use libjpeg for DCT streams. Possible values: libjpeg, unmaintained, none. will use libjpeg if available or fail if not. 'unmaintained' gives you the internal unmaintained decoder. Use at your own risk. 'none' compiles no DCT decoder at all. Default: libjpeg")
option(ENABLE_LIBCURL "Build libcurl based HTTP support." OFF)
@@ -191,15 +191,35 @@ if(ENABLE_LIBOPENJPEG STREQUAL "auto")
find_package(LIBOPENJPEG)
set(USE_OPENJPEG1 ${LIBOPENJPEG_FOUND})
set(WITH_OPENJPEG ${LIBOPENJPEG_FOUND})
+ if(NOT LIBOPENJPEG_FOUND)
+ message(FATAL_ERROR "Install libopenjpeg2 or libopenjpeg1 before trying to build poppler. You can also decide to use the internal unmaintained JPX decoder or none at all.")
+ endif()
endif()
+ set(HAVE_JPX_DECODER ON)
elseif(ENABLE_LIBOPENJPEG STREQUAL "openjpeg1")
find_package(LIBOPENJPEG)
set(USE_OPENJPEG1 ${LIBOPENJPEG_FOUND})
set(WITH_OPENJPEG ${LIBOPENJPEG_FOUND})
+ if(NOT LIBOPENJPEG_FOUND)
+ message(FATAL_ERROR "Install libopenjpeg1 before trying to build poppler. You can also decide to use the internal unmaintained JPX decoder or none at all.")
+ endif()
+ set(HAVE_JPX_DECODER ON)
elseif(ENABLE_LIBOPENJPEG STREQUAL "openjpeg2")
find_package(LIBOPENJPEG2)
set(USE_OPENJPEG2 ${LIBOPENJPEG2_FOUND})
set(WITH_OPENJPEG ${LIBOPENJPEG2_FOUND})
+ if(NOT LIBOPENJPEG2_FOUND)
+ message(FATAL_ERROR "Install libopenjpeg2 before trying to build poppler. You can also decide to use the internal unmaintained JPX decoder or none at all.")
+ endif()
+ set(HAVE_JPX_DECODER ON)
+elseif(ENABLE_LIBOPENJPEG STREQUAL "unmaintained")
+ set(WITH_OPENJPEG OFF)
+ set(HAVE_JPX_DECODER ON)
+elseif(ENABLE_LIBOPENJPEG STREQUAL "none")
+ set(WITH_OPENJPEG OFF)
+ set(HAVE_JPX_DECODER OFF)
+else()
+ message(FATAL_ERROR "Invalid ENABLE_LIBOPENJPEG value: ${ENABLE_LIBOPENJPEG}")
endif()
set(ENABLE_LIBOPENJPEG "${WITH_OPENJPEG}")
if(ENABLE_CMS STREQUAL "auto")
@@ -797,6 +817,10 @@ if(ENABLE_ZLIB_UNCOMPRESS)
message("Warning: Using zlib is not totally safe")
endif(ENABLE_ZLIB_UNCOMPRESS)
-if(NOT WITH_OPENJPEG)
+if(NOT WITH_OPENJPEG AND HAVE_JPX_DECODER)
message("Warning: Using libopenjpeg2 is recommended. The internal JPX decoder is unmaintained.")
-endif(NOT WITH_OPENJPEG)
+endif()
+
+if(NOT HAVE_JPX_DECODER)
+ message("Warning: You're not compiling any JPX decoder. Some files will fail to display properly.")
+endif()
diff --git a/config.h.cmake b/config.h.cmake
index db7bfcb3..4a4da624 100644
--- a/config.h.cmake
+++ b/config.h.cmake
@@ -33,6 +33,9 @@
/* Do we have any DCT decoder?. */
#cmakedefine HAVE_DCT_DECODER 1
+/* Do we have any JPX decoder?. */
+#cmakedefine HAVE_JPX_DECODER 1
+
/* Define to 1 if you have the <dirent.h> header file, and it defines `DIR'.
*/
#cmakedefine HAVE_DIRENT_H 1
diff --git a/configure.ac b/configure.ac
index 899c45dc..a2cb046d 100644
--- a/configure.ac
+++ b/configure.ac
@@ -201,8 +201,8 @@ dnl ##### Test for libopenjpeg. Versions prior to 1.4 do not provide a pkgconfig
openjpeg1="no"
openjpeg2="no"
AC_ARG_ENABLE(libopenjpeg,
- AC_HELP_STRING([--enable-libopenjpeg=@<:@auto/openjpeg1/openjpeg2/none@:>@],
- [Use openjpeg for JPEG2000 images. 'auto' prefers openjpeg2 over openjpeg1 if both are available [[default=auto]]]),
+ AC_HELP_STRING([--enable-libopenjpeg=@<:@auto/openjpeg1/openjpeg2/unmaintained/none@:>@],
+ [Use openjpeg for JPEG2000 images. 'auto' prefers openjpeg2 over openjpeg1 if both are available. 'unmaintained' gives you the internal unmaintained decoder. Use at your own risk. 'none' compiles no JPX decoder at all. [[default=auto]]]),
[enable_libopenjpeg=$enableval],
[enable_libopenjpeg="auto"])
@@ -258,10 +258,27 @@ if test x$openjpeg1 = xyes || test x$openjpeg2 = xyes; then
[AC_DEFINE(WITH_OPENJPEG_IGNORE_PCLR_CMAP_CDEF_FLAG, 1, [OpenJPEG with the OPJ_DPARAMETERS_IGNORE_PCLR_CMAP_CDEF_FLAG flag.])],
[])
])
+ have_jpx_decoder=yes
+ AC_DEFINE(HAVE_JPX_DECODER)
else
- enable_libopenjpeg=no
+ if test x$enable_libopenjpeg = xunmaintained; then
+ enable_libopenjpeg=no
+ have_jpx_decoder=yes
+ AC_DEFINE(HAVE_JPX_DECODER)
+ elif test x$enable_libopenjpeg = xnone; then
+ enable_libopenjpeg=no
+ have_jpx_decoder=no
+ else
+ if test x$enable_libopenjpeg = xopenjpeg2 || test x$enable_libopenjpeg = xopenjpeg1 || test x$enable_libopenjpeg = xauto; then
+ AC_MSG_ERROR([Install libopenjpeg2 or libopenjpeg1 before trying to build poppler. You can also decide to use the internal unmaintained JPX decoder or none at all. See --help.])
+ else
+ AC_MSG_ERROR([Invalid --enable-libopenjpeg value. See --help.])
+ fi
+ fi
fi
+AH_TEMPLATE([HAVE_JPX_DECODER], [Do we have any JPX decoder?.])
+
dnl Test for NSS
AC_ARG_ENABLE(libnss,
AC_HELP_STRING([--disable-libnss],
@@ -1108,6 +1125,10 @@ if test x$enable_zlib_uncompress != xno; then
echo " Warning: Using zlib for decompression is not totally safe"
fi
-if test x$enable_libopenjpeg != xyes; then
+if test x$enable_libopenjpeg != xyes -a x$have_jpx_decoder = xyes; then
echo " Warning: Using libopenjpeg2 is recommended. The internal JPX decoder is unmaintained."
fi
+
+if test x$have_jpx_decoder = xno; then
+ echo " Warning: You're not compiling any JPX decoder. Some files will fail to display properly."
+fi
diff --git a/poppler/Stream.cc b/poppler/Stream.cc
index d1abf3ff..4ac91078 100644
--- a/poppler/Stream.cc
+++ b/poppler/Stream.cc
@@ -353,7 +353,12 @@ Stream *Stream::makeFilter(char *name, Stream *str, Object *params, int recursio
globals.free();
obj.free();
} else if (!strcmp(name, "JPXDecode")) {
+#ifdef HAVE_JPX_DECODER
str = new JPXStream(str);
+#else
+ error(errSyntaxError, getPos(), "Unknown filter '{0:s}'", name);
+ str = new EOFStream(str);
+#endif
} else if (!strcmp(name, "Crypt")) {
if (str->getKind() == strCrypt) {
str = str->getBaseStream();
More information about the poppler
mailing list