Skip to content

Commit

Permalink
Merge pull request #11831 from vit9696/macbuild
Browse files Browse the repository at this point in the history
Bundle libSDL inside app on macOS, fixes #11830
  • Loading branch information
hrydgard authored Feb 23, 2019
2 parents 73d44c4 + 2ccd015 commit 4c83d30
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 0 deletions.
3 changes: 3 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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})
Expand Down
27 changes: 27 additions & 0 deletions SDL/macbundle.sh
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 4c83d30

Please sign in to comment.