@@ -230,6 +230,45 @@ endwhile()
230230
231231message (STATUS "Library path fixing complete" )
232232
233+ #
234+ # sdl2-compat: Homebrew's sdl2 formula is now a compatibility layer that loads
235+ # the real SDL3 library at runtime via dlopen. Since SDL3 is not a linker
236+ # dependency, it is invisible to otool and is never picked up by the fixup loop
237+ # above. Detect sdl2-compat and bundle libSDL3 explicitly.
238+ #
239+ set (sdl2_compat_lib "${framework_path} /libSDL2-2.0.0.dylib" )
240+ if (EXISTS "${sdl2_compat_lib} " )
241+ execute_process (
242+ COMMAND strings -a "${sdl2_compat_lib} "
243+ OUTPUT_VARIABLE sdl2_compat_strings
244+ ERROR_QUIET
245+ OUTPUT_STRIP_TRAILING_WHITESPACE
246+ )
247+ if (sdl2_compat_strings MATCHES "libSDL3\\ .dylib" )
248+ set (sdl3_target "${framework_path} /libSDL3.dylib" )
249+ if (NOT EXISTS "${sdl3_target} " )
250+ set (sdl3_source "" )
251+ foreach (candidate "${brew_lib} /libSDL3.dylib" "${brew_lib} /libSDL3.0.dylib" )
252+ if (EXISTS "${candidate} " )
253+ get_filename_component (sdl3_source "${candidate} " REALPATH )
254+ break ()
255+ endif ()
256+ endforeach ()
257+ if (sdl3_source)
258+ message (STATUS "sdl2-compat detected, bundling SDL3 into ${framework_path} " )
259+ file (COPY "${sdl3_source} " DESTINATION "${framework_path} " )
260+ get_filename_component (sdl3_source_name "${sdl3_source} " NAME )
261+ if (NOT "${sdl3_source_name} " STREQUAL "libSDL3.dylib" )
262+ file (RENAME "${framework_path} /${sdl3_source_name} " "${sdl3_target} " )
263+ endif ()
264+ execute_process (COMMAND install_name_tool -id "@executable_path/../Frameworks/libSDL3.dylib" "${sdl3_target} " ERROR_QUIET )
265+ else ()
266+ message (WARNING "sdl2-compat detected but libSDL3 was not found in ${brew_lib} ; the app will fail at runtime with 'Failed loading SDL3 library.'" )
267+ endif ()
268+ endif ()
269+ endif ()
270+ endif ()
271+
233272# List all bundled libraries for verification
234273file (GLOB final_dylibs "${framework_path} /*.dylib" )
235274message (STATUS "=== Bundled libraries in Frameworks ===" )
0 commit comments