libsdl-org / SDL_image

Image decoding for many popular formats for Simple Directmedia Layer.
zlib License
513 stars 174 forks source link

cmake build: SDL2IMAGE_DEPS_SHARED option doesn't work #422

Closed Soapux closed 5 months ago

Soapux commented 5 months ago

When setting SDL2IMAGE_DEPS_SHARED=OFF, it doesn't directly link to the image libraries like it should.

madebr commented 5 months ago

The (current) default configuration of SDL2_image is to not need any 3rd party dependencies. If you configure with e.g. -DSDL2IMAGE_TIF=ON, then it will link to libtiff.

After configuring and building SDL2_image using the following commands:

cmake -S /path/to/SDL_image -B /tmp/SDL_image-build -GNinja -DSDL2IMAGE_DEPS_SHARED=OFF -DSDL2IMAGE_TIFF=ON
cmake --build /tmp/SDL_image-build/

objdump -x /tmp/SDL_image-build/libSDL2_image.so | grep NEEDED prints:

  NEEDED               libSDL2-2.0.so.0
  NEEDED               libtiff.so.5
  NEEDED               libc.so.6
Soapux commented 5 months ago

You're right, it does work. I see what was tripping me up now. In the autotools build tiff, avif, webp are default to on, whereas in the cmake build they are off. So I just assumed they were on and when I turned off dynamic loading I expected them be show in the NEEDED section. Maybe the cmake build should match the autotools build in that respect. I'll close this. Thanks.

madebr commented 5 months ago

This is "fixed" in SDL3, and will also be backported for SDL2: https://github.com/libsdl-org/SDL_image/issues/421