diff --git a/CMakeLists.txt b/CMakeLists.txt index 10fb06142387..8ba13db8cfcb 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1991,6 +1991,9 @@ if(TargetBin) add_executable(${TargetBin} MACOSX_BUNDLE ${ICON_PATH_ABS} ${NativeAssets} ${SHADER_FILES} ${FLASH0_FILES} ${LANG_FILES} ${NativeAppSource} "ios/Launch Screen.storyboard") else() add_executable(${TargetBin} MACOSX_BUNDLE ${ICON_PATH_ABS} ${NativeAssets} ${SHADER_FILES} ${FLASH0_FILES} ${LANG_FILES} ${NativeAppSource}) + if(TARGET SDL2::SDL2) + add_custom_command(TARGET ${TargetBin} POST_BUILD COMMAND /bin/bash "${CMAKE_SOURCE_DIR}/SDL/macbundle.sh" "${CMAKE_BINARY_DIR}/PPSSPPSDL.app") + endif() endif() elseif(WIN32) add_executable(${TargetBin} WIN32 ${NativeAppSource}) diff --git a/SDL/macbundle.sh b/SDL/macbundle.sh new file mode 100755 index 000000000000..53bf39ce9089 --- /dev/null +++ b/SDL/macbundle.sh @@ -0,0 +1,27 @@ +#!/bin/bash + +PPSSPP="${1}" +PPSSPPSDL="${PPSSPP}/Contents/MacOS/PPSSPPSDL" + +if [ ! -f "${PPSSPPSDL}" ]; then + echo "No such file: ${PPSSPPSDL}!" + exit 1 +fi + +SDL=$(otool -L "${PPSSPPSDL}" | grep -v @executable_path | grep -Eo /.+libSDL.+dylib) +if [ "${SDL}" = "" ]; then + echo "SDL is already bundled/unused." + exit 0 +fi + +if [ ! -f "${SDL}" ]; then + echo "Cannot locate SDL: ${SDL}!" + exit 1 +fi + +echo "Installing SDL from ${SDL}..." + +SDLNAME=$(basename "${SDL}") +mkdir -p "${PPSSPP}/Contents/Frameworks" || exit 1 +cp -r "$SDL" "${PPSSPP}/Contents/Frameworks" || exit 1 +install_name_tool -change "${SDL}" "@executable_path/../Frameworks/${SDLNAME}" "${PPSSPPSDL}" || exit 1