libyuv: fix libyuv.so underlinking

When `libyuv` is built with `jpeg` support it does not directly link
`libjpeg` in any form. As a result dynamic loading of the library
fails as:

    >>> import pillow_avif._avif
    Traceback (most recent call last):
      File "<stdin>", line 1, in <module>
    ImportError: /usr/lib/libyuv.so: undefined symbol: jpeg_resync_to_restart

We can reproduce the same problem at build time if we build `libyuv` with
`LDFLAGS=-Wl,--no-undefined`:

    [ 99%] Linking CXX executable yuvconstants
    ld: CMakeFiles/yuv_shared.dir/source/mjpeg_decoder.cc.o: in function `libyuv::MJpegDecoder::MJpegDecoder()':
    mjpeg_decoder.cc:(.text+0xfc): undefined reference to `jpeg_resync_to_restart'
    ld: mjpeg_decoder.cc:(.text+0x136): undefined reference to `jpeg_std_error'
    ld: mjpeg_decoder.cc:(.text+0x194): undefined reference to `jpeg_CreateDecompress'

The change links `libgpeg` against `libyuv` itself to make it a
self-contained library. This fixes both loading if the library
itself and fixes linking of the library against other binaries
without explicit need for passing `-ljpeg`.

Change-Id: I044acb3799920e1536bdb3388442a40d4839348b
Reviewed-on: https://chromium-review.googlesource.com/c/libyuv/libyuv/+/4050883
Reviewed-by: Frank Barchard <fbarchard@chromium.org>
Reviewed-by: Mirko Bonadei <mbonadei@chromium.org>
Commit-Queue: Frank Barchard <fbarchard@chromium.org>
This commit is contained in:
Sergei Trofimovich 2022-11-23 07:41:10 +00:00 committed by Frank Barchard
parent cf7c3a1ba7
commit f428a642e3

View File

@ -48,7 +48,7 @@ TARGET_LINK_LIBRARIES ( yuvconstants ${ly_lib_static} )
find_package ( JPEG ) find_package ( JPEG )
if (JPEG_FOUND) if (JPEG_FOUND)
include_directories( ${JPEG_INCLUDE_DIR} ) include_directories( ${JPEG_INCLUDE_DIR} )
target_link_libraries( yuvconvert ${JPEG_LIBRARY} ) target_link_libraries( ${ly_lib_shared} ${JPEG_LIBRARY} )
add_definitions( -DHAVE_JPEG ) add_definitions( -DHAVE_JPEG )
endif() endif()