libsdl-org / SDL_ttf

Support for TrueType (.ttf) font files with Simple Directmedia Layer.
zlib License
343 stars 116 forks source link

On macOS CMake config file IMPORTED_SONAME refers to full name of the library (including the minor number) instead to libSDL2_ttf-2.0.so.0 #347

Open traversaro opened 3 months ago

traversaro commented 3 months ago

Hello everyone, thanks a lot for all the work on SDL libraries!

I opening this issue to report a different behavior between Linux and macOS for what regards the generation of CMake config files.

Using the 2.22.0 release as an example, in Linux, the IMPORTED_SONAME_RELEASE (i.e. the name of the library actually used to link in downstream projects that consume sdl_ttf) is libSDL2_ttf-2.0.so.0. That means that any library or executable that links with it, is able to also work with any following 2.* version of SDL_ttf . Instead, on macOS the IMPORTED_SONAME_RELEASE used is libSDL2_ttf-2.0.2201.0.0.dylib, meaning that any downstream library that links that library, strictly requires sdl_ttf 2.22.0 to run, and it can work on following version of sdl_ttf.

Is this difference between Linux and macOS intentional? The related code is https://github.com/libsdl-org/SDL_ttf/blob/SDL2/CMakeLists.txt#L122-L133, and before https://github.com/libsdl-org/SDL_ttf/pull/213 (by @madebr) the behavior between Linux and macOS was the same.

At a first glance, it seems that the same issue is present in SDL_image (see https://github.com/libsdl-org/SDL_image/blob/SDL2/CMakeLists.txt#L261-L272) and other SDL_* libraries, while the logic in the main SDL library is different, at least for SDL2 .

Thanks a lot in advance, and sorry for referencing mainly to SDL2 while SDL3 is in the work, as this problem emerged in the conda-forge distribution of SDL (see https://github.com/conda-forge/sdl2_ttf-feedstock/issues/18) we are currently mostly focused on the currently released version of SDL.

traversaro commented 3 months ago

(I edited the previous message to fix a link).

madebr commented 3 months ago

Can you try https://github.com/libsdl-org/SDL_ttf/pull/349?

traversaro commented 3 months ago

Can you try #349?

Thanks, today I was able to test the patch on a macos arm64 and it is working fine!