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

From ee22e8bb3aa1b6060f6826126246d60b73f128c6 Mon Sep 17 00:00:00 2001
From: Simon McVittie <[EMAIL REDACTED]>
Date: Thu, 5 May 2022 17:29:25 +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 87367b54..c17ea201 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -84,6 +84,17 @@ include_directories(include src src/codecs)
 add_library(SDL2_mixer)
 add_library(SDL2::mixer ALIAS SDL2_mixer)
 
+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_mixer PROPERTIES
+           VERSION ${LT_VERSION}
+           SOVERSION ${LT_MAJOR}
+           OUTPUT_NAME "SDL2_mixer-${LT_RELEASE}"
+    )
+endif()
+
 target_sources(SDL2_mixer PRIVATE
         src/effect_position.c src/effects_internal.c src/effect_stereoreverse.c
         src/mixer.c src/music.c src/utils.c