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

From 82aba550b8359dcdc6ed912169a61eabf0ad8f3f Mon Sep 17 00:00:00 2001
From: Simon McVittie <[EMAIL REDACTED]>
Date: Thu, 5 May 2022 13:20:11 +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 | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 23d3689..6029408 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -83,8 +83,18 @@ endif()
 
 add_library(SDL2_image)
 
+if (UNIX AND NOT APPLE AND NOT ANDROID)
+	# This is compatible with the libtool build
+	set_target_properties(SDL2_image PROPERTIES
+		VERSION ${LT_VERSION}
+		SOVERSION ${LT_MAJOR}
+		OUTPUT_NAME "SDL2_image-${LT_RELEASE}"
+	)
+endif()
+
 set(IMAGEIO_SOURCES)
 if (APPLE)
+	# TODO: Use DYLIB_COMPATIBILITY_VERSION, DYLIB_CURRENT_VERSION here
 	if (ENABLE_APPLE_IMAGEIO)
 		target_link_options(SDL2_image PRIVATE -Wl,-framework,ApplicationServices)
 		target_link_libraries(SDL2_image PRIVATE objc)