Support building against libjpeg-turbo 2.0. Backport of https://github.com/strukturag/libheif/pull/85 --- a/configure.ac +++ b/configure.ac @@ -95,6 +95,22 @@ AC_CHECK_LIB([jpeg], [jpeg_destroy_compress], [ ], [have_libjpeg="no"]) fi AM_CONDITIONAL([HAVE_LIBJPEG], [test "x$have_libjpeg" = "xyes"]) +if eval "test x$have_libjpeg = xyes"; then +AC_MSG_CHECKING([for jpeg_write_icc_profile]) +AC_LANG_PUSH(C++) +AC_TRY_COMPILE([ + #include + #include + #include +],[ + jpeg_write_icc_profile(NULL, NULL, 0); +],[has_jpeg_write_icc_profile=yes],[has_jpeg_write_icc_profile=no]); +AC_LANG_POP(C++) +AC_MSG_RESULT([$has_jpeg_write_icc_profile]) +if eval "test x$has_jpeg_write_icc_profile = xyes"; then + AC_DEFINE(HAVE_JPEG_WRITE_ICC_PROFILE, 1, [Define to 1 if jpeg_write_icc_profile is available in libjpeg.]) +fi +fi PKG_CHECK_MODULES([libpng], [libpng], [ AC_DEFINE([HAVE_LIBPNG], [1], [Whether libpng was found.]) --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -8,6 +8,24 @@ include (${CMAKE_ROOT}/Modules/FindJPEG.cmake) if(JPEG_FOUND) add_definitions(-DHAVE_LIBJPEG=1) + +include (${CMAKE_ROOT}/Modules/CheckCXXSourceCompiles.cmake) + +set(CMAKE_REQUIRED_LIBRARIES ${JPEG_LIBRARIES}) +check_cxx_source_compiles(" +#include +#include +#include + +int main() { + jpeg_write_icc_profile(NULL, NULL, 0); + return 0; +} +" HAVE_JPEG_WRITE_ICC_PROFILE) +if(HAVE_JPEG_WRITE_ICC_PROFILE) + add_definitions(-DHAVE_JPEG_WRITE_ICC_PROFILE=1) +endif() + set (heif_convert_sources ${heif_convert_sources} encoder_jpeg.cc --- a/examples/encoder_jpeg.cc +++ b/examples/encoder_jpeg.cc @@ -17,6 +17,10 @@ * You should have received a copy of the GNU General Public License * along with convert. If not, see . */ +#if defined(HAVE_CONFIG_H) +#include "config.h" +#endif + #include #include #include --- a/examples/encoder_jpeg.h +++ b/examples/encoder_jpeg.h @@ -24,6 +24,9 @@ #include #include +// Prevent duplicate definition for newer versions of libjpeg-turbo. +#undef HAVE_STDDEF_H +#undef HAVE_STDLIB_H #include #include --- a/examples/heif_enc.cc +++ b/examples/heif_enc.cc @@ -35,6 +35,9 @@ #if HAVE_LIBJPEG extern "C" { +// Prevent duplicate definition for newer versions of libjpeg-turbo. +#undef HAVE_STDDEF_H +#undef HAVE_STDLIB_H #include } #endif