Commit 65c5a526 authored by Albert Astals Cid's avatar Albert Astals Cid

Fail by default if libopenjpeg2/1 is not available

You can "force" to use the unmaintained JPX decoder or none at all
parent ea6d3200
......@@ -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()
......@@ -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
......
......@@ -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
......@@ -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();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment