libsdl-org / SDL_image

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

Fix SDL2IMAGE_TIF_SHARED=ON and SDL2IMAGE_TIF_VENDORED=OFF when using CMake >= 3.28 #439

Closed traversaro closed 6 months ago

traversaro commented 6 months ago

When using CMake >= 3.28, the build on Windows can fail with the following error:

-- Found TIFF: D:/bld/sdl2_image_1711371034934/_h_env/Library/lib/cmake/tiff (found version "4.6.0")
CMake Error at cmake/PrivateSdlFunctions.cmake:247 (message):
  TIFF::TIFF is not a shared library, but has type=INTERFACE_LIBRARY
-- Dynamic libtiff: $<TARGET_FILE_NAME:TIFF::TIFF>
Call Stack (most recent call first):
-- SDL2_image: Using system libwebp

The error is due to https://gitlab.kitware.com/cmake/cmake/-/merge_requests/8803, that changed TIFF::TIFF to be an interface library that just acts as a sort of alias to TIFF::tiff. This PR fixes this problem by using TIFF::tiff if it is defined, and just use TIFF::TIFF if TIFF::tiff is not defined.

traversaro commented 6 months ago

Sorry for the noise, there was a typo in the CMake, not it should be fixed.

sezero commented 6 months ago

Looks good to me, and possibly needed in all active branches. @madebr ?

madebr commented 6 months ago

Looks great. Too bad upstream didn't go with an ALIAS library, but that could probably break backwards compatibility.

sezero commented 6 months ago

Is this needed in SDL3 and/or release-2.8.x ?

madebr commented 6 months ago

Oh yes, all branches.

sezero commented 6 months ago

Leaving to your care ;)

madebr commented 6 months ago

Done. I had to fix SDL2 slightly in b9694685952ac6cc287c9e30c03305860496baf6

SDL3: 25e816f614dbe4aa9fdaf89c248ae283f20038f9 2.8.x: 02c81284c92e2097a6559a46e188f27f2039e2fd