2020.12.26 19:47 "[Tiff] Wrong information about request and avalability of external codecs", by Miguel Medalha

2020.12.26 20:23 "Re: [Tiff] Wrong information about request and avalability of external codecs", by Roger Leigh

How come availability is dependent upon request? Why bother presenting the information if it's not to be accurate?

The CMake logic is a direct copy of the Autoconf configure.ac logic. I think in this case we could improve it a bit. The root cause of the problems is that we only check for a library if specifically requested. For example:

option(zlib "use zlib (required for Deflate compression)" ON)
if (zlib)
  find_package(ZLIB)
endif()
set(ZLIB_SUPPORT 0)
if(ZLIB_FOUND)
  set(ZLIB_SUPPORT 1)
endif()
set(ZIP_SUPPORT ${ZLIB_SUPPORT})

We are not unconditionally checking with find_package unless support is specifically requested. That’s why the (availability) was unset.

We could just unconditionally check for everything which would always mean the summary is correct, and enable if both "FOUND and requested”.

We could also fail if a request could not be satisfied even when explicitly requested; right now we just carry on regardless and leave it disabled.

For reference, this is the corresponding configure.ac logic:

HAVE_ZLIB=no

AC_ARG_ENABLE(zlib,
              AS_HELP_STRING([--disable-zlib],
                             [disable Zlib usage (required for Deflate compression, enabled by default)]),,)
AC_ARG_WITH(zlib-include-dir,
            AS_HELP_STRING([--with-zlib-include-dir=DIR],
                           [location of Zlib headers]),,)
AC_ARG_WITH(zlib-lib-dir,
            AS_HELP_STRING([--with-zlib-lib-dir=DIR],
                           [location of Zlib library binary]),,)

if test "x$enable_zlib" != "xno" ; then

  if test "x$with_zlib_lib_dir" != "x" ; then
    LDFLAGS="-L$with_zlib_lib_dir $LDFLAGS"
  fi


  AC_CHECK_LIB(z, inflateEnd, [zlib_lib=yes], [zlib_lib=no],)
  if test "$zlib_lib" = "no" -a "x$with_zlib_lib_dir" != "x"; then
    AC_MSG_ERROR([Zlib library not found at $with_zlib_lib_dir])
  fi


  if test "x$with_zlib_include_dir" != "x" ; then
    CPPFLAGS="-I$with_zlib_include_dir $CPPFLAGS"
  fi
  AC_CHECK_HEADER(zlib.h, [zlib_h=yes], [zlib_h=no])
  if test "$zlib_h" = "no" -a "x$with_zlib_include_dir" != "x" ; then
    AC_MSG_ERROR([Zlib headers not found at $with_zlib_include_dir])
  fi

  if test "$zlib_lib" = "yes" -a "$zlib_h" = "yes" ; then
    HAVE_ZLIB=yes
  fi

fi

if test "$HAVE_ZLIB" = "yes" ; then
  AC_DEFINE(ZIP_SUPPORT,1,[Support Deflate compression])
  LIBS="-lz $LIBS"
  tiff_libs_private="-lz ${tiff_libs_private}"

  if test "$HAVE_RPATH" = "yes" -a "x$with_zlib_lib_dir" != "x" ; then
    LIBDIR="-R $with_zlib_lib_dir $LIBDIR"
  fi

fi

You can see we only check for zlib inside the conditional.

Also, LZMA demands the location of libraries and include files to be specified in the format '-DLIBLZMA_LIBRARY:PATH' and 'DLIBLZMA_INCLUDE_DIR:PATH' instead of '-DLZMA_LIBRARY:PATH' and 'DLZMA_INCLUDE_DIR:PATH' like the other codecs. Shouldn't this be consistent instead of casuistic, for the sake of conservation of mental energy?

Yes. Unfortunately that’s not something under our control. It’s likely because “lzma” is both a library and a tool name and this was to differentiate between the two.

Regards,

Roger