SDL_ttf: cmake: On Unix, make the library ABI-compatible with the Autotools build

From 761f195f4a6fd2da38c2916ed37ad9cf0dc546fe Mon Sep 17 00:00:00 2001
From: Simon McVittie <[EMAIL REDACTED]>
Date: Thu, 5 May 2022 19:44:00 +0100
Subject: [PATCH] cmake: On Unix, make the library ABI-compatible with the
 Autotools build

This is not yet implemented for macOS, only for generic Unix (in practice
meaning Linux and *BSD).

Signed-off-by: Simon McVittie <smcv@collabora.com>
---
 CMakeLists.txt | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 97d579b..eca9cef 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -125,6 +125,17 @@ if (NOT TARGET SDL2::SDL2)
     IMPORTED_LOCATION "${SDL2_LIBRARY}")
 endif()
 
+if (APPLE)
+  # TODO: Use DYLIB_COMPATIBILITY_VERSION, DYLIB_CURRENT_VERSION here
+elseif (UNIX AND NOT ANDROID)
+  # This is compatible with the libtool build
+  set_target_properties(SDL2_ttf PROPERTIES
+    VERSION ${LT_VERSION}
+    SOVERSION ${LT_MAJOR}
+    OUTPUT_NAME "SDL2_ttf-${LT_RELEASE}"
+  )
+endif()
+
 if (BUILD_SHARED_LIBS)
   target_link_libraries(SDL2_ttf SDL2::SDL2)
   if (WIN32 OR CYGWIN)