sdl12-compat: CMake: set dylib compatibility and current version numbers

From 1cf88a18c43eacae308015c54fd3594c108b0ba8 Mon Sep 17 00:00:00 2001
From: Ozkan Sezer <[EMAIL REDACTED]>
Date: Fri, 12 Mar 2021 14:50:02 +0300
Subject: [PATCH] CMake: set dylib compatibility and current version numbers

Fixes: https://github.com/libsdl-org/sdl12-compat/issues/37
---
 CMakeLists.txt | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 6399321..abb30ed 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -8,6 +8,9 @@ project(sdl12_compat)
 if(APPLE)
   set(OSX_SRCS "src/SDL12_compat_objc.m")
   set_source_files_properties(${OSX_SRCS} PROPERTIES LANGUAGE C)
+  # the following matches SDL-1.2 Xcode project file
+  set(DYLIB_COMPAT_VERSION 1.0.0)
+  set(DYLIB_CURRENT_VERSION 12.50.0)
 endif()
 if(WIN32)
   set(WIN32_SRCS "src/version.rc")
@@ -35,10 +38,9 @@ if(UNIX AND NOT APPLE)
 endif()
 if(APPLE)
     set_target_properties(SDL PROPERTIES COMPILE_DEFINITIONS "_THREAD_SAFE")
+    set_target_properties(SDL PROPERTIES LINK_FLAGS
+            "-Wl,-compatibility_version,${DYLIB_COMPAT_VERSION} -Wl,-current_version,${DYLIB_CURRENT_VERSION}")
     target_link_libraries(SDL PRIVATE "-framework AppKit")
-endif()
-
-if(APPLE)
     set_target_properties(SDL PROPERTIES
         MACOSX_RPATH 1
         OUTPUT_NAME "SDL-1.2.0"