diff --git a/CMakeLists.txt b/CMakeLists.txt index 267e7e662e..088f37d2cb 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -107,10 +107,6 @@ if(NOT IOS) list(APPEND CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake/sdl) endif() -if(MACOSX AND NOT USE_SYSTEM_LIBSDL2) - set(SDL2_LIBRARY ${CMAKE_SOURCE_DIR}/SDL/macOS/SDL2.framework) -endif() - include(ccache) include(GNUInstallDirs) @@ -161,7 +157,7 @@ option(USE_ARMIPS "Build with armips support in API/debugger" ON) option(USE_SYSTEM_SNAPPY "Dynamically link against system snappy" ${USE_SYSTEM_SNAPPY}) option(USE_SYSTEM_FFMPEG "Dynamically link against system FFMPEG" ${USE_SYSTEM_FFMPEG}) option(USE_SYSTEM_LIBZIP "Dynamically link against system libzip" ${USE_SYSTEM_LIBZIP}) -option(USE_SYSTEM_LIBSDL2 "Dynamically link against system SDL2" ON) +option(USE_SYSTEM_LIBSDL2 "Dynamically link against system SDL2" ON) # Ignored on Mac option(USE_SYSTEM_LIBPNG "Dynamically link against system libpng" ON) option(USE_SYSTEM_ZSTD "Dynamically link against system zstd" ${USE_SYSTEM_ZSTD}) option(USE_SYSTEM_MINIUPNPC "Dynamically link against system miniUPnPc" ${USE_SYSTEM_MINIUPNPC}) @@ -241,9 +237,16 @@ if(USING_EGL) set(OPENGL_LIBRARIES ${OPENGL_LIBRARIES} ${EGL_LIBRARIES}) endif() -if(NOT LIBRETRO AND NOT IOS) +if(NOT LIBRETRO AND NOT IOS AND NOT MACOSX) find_package(SDL2) endif() + +if(MACOSX AND NOT IOS) + find_library(SDL2Fwk SDL2 REQUIRED PATHS SDL/macOS) + message(STATUS "found SDL2Fwk=${SDL2Fwk}") + add_definitions(-DHAVE_SYSCTLBYNAME) +endif() + include(FindThreads) if(APPLE) @@ -1252,7 +1255,8 @@ elseif(WIN32) else() link_directories(dx9sdk/Lib/x86) endif() -elseif(TARGET SDL2::SDL2) +elseif(LIBRETRO) +else() set(TargetBin PPSSPPSDL) # Require SDL add_definitions(-DSDL) @@ -1267,7 +1271,6 @@ elseif(TARGET SDL2::SDL2) SDL/SDLVulkanGraphicsContext.cpp ) endif() - set(nativeExtraLibs ${nativeExtraLibs} SDL2::SDL2) if(APPLE) set(nativeExtra ${nativeExtra} SDL/SDLMain.h @@ -1290,11 +1293,12 @@ elseif(TARGET SDL2::SDL2) set_source_files_properties(SDL/PPSSPPAboutViewController.m PROPERTIES COMPILE_FLAGS -fobjc-arc) set_source_files_properties(Common/Battery/AppleBatteryClient.m PROPERTIES COMPILE_FLAGS -fobjc-arc) set(nativeExtraLibs ${nativeExtraLibs} ${COCOA_LIBRARY} ${QUARTZ_CORE_LIBRARY} ${IOKIT_LIBRARY}) + set(nativeExtraLibs ${nativeExtraLibs} ${SDL2Fwk}) elseif(USING_EGL) - set(nativeExtraLibs ${nativeExtraLibs} pthread) + set(nativeExtraLibs ${nativeExtraLibs} pthread SDL2::SDL2) + else() + set(nativeExtraLibs ${nativeExtraLibs} SDL2::SDL2) endif() -elseif(NOT LIBRETRO) - message(FATAL_ERROR "Could not find SDL2. Failing.") endif() if(WIN32) @@ -2547,10 +2551,10 @@ if(TargetBin) else() add_executable(${TargetBin} MACOSX_BUNDLE ${ICON_PATH_ABS} ${NativeAssets} ${BigFontAssets} ${SHADER_FILES} ${THEME_FILE} ${DEBUGGER_FILES} ${FLASH0_FILES} ${LANG_FILES} ${NativeAppSource}) file(INSTALL "${CMAKE_SOURCE_DIR}/ext/vulkan/macOS/Frameworks/libMoltenVK.dylib" DESTINATION "${CMAKE_BINARY_DIR}/PPSSPPSDL.app/Contents/Frameworks/") - if(TARGET SDL2::SDL2 AND NOT USING_QT_UI) - add_custom_command(TARGET ${TargetBin} POST_BUILD COMMAND /bin/bash "${CMAKE_SOURCE_DIR}/SDL/macbundle.sh" "${CMAKE_BINARY_DIR}/PPSSPPSDL.app") - elseif(USING_QT_UI) + if(USING_QT_UI) add_custom_command(TARGET ${TargetBin} POST_BUILD COMMAND /bin/bash "${CMAKE_SOURCE_DIR}/Qt/macbundle.sh" "${CMAKE_BINARY_DIR}/PPSSPPQt.app") + else() + 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) diff --git a/SDL/SDLGLGraphicsContext.h b/SDL/SDLGLGraphicsContext.h index 06832470a7..95d627deda 100644 --- a/SDL/SDLGLGraphicsContext.h +++ b/SDL/SDLGLGraphicsContext.h @@ -1,5 +1,11 @@ -#include "SDL_syswm.h" +#include "ppsspp_config.h" +#if PPSSPP_PLATFORM(MAC) +#include "SDL2/SDL.h" +#include "SDL2/SDL_syswm.h" +#else #include "SDL.h" +#include "SDL_syswm.h" +#endif #include "Common/GPU/OpenGL/GLRenderManager.h" #include "Common/GPU/OpenGL/GLCommon.h" diff --git a/SDL/SDLJoystick.h b/SDL/SDLJoystick.h index 4ab237ae12..d7494f8296 100644 --- a/SDL/SDLJoystick.h +++ b/SDL/SDLJoystick.h @@ -1,10 +1,12 @@ #pragma once #ifdef _MSC_VER #include "SDL/SDL.h" -#include "SDL/SDL_thread.h" +#else +#if PPSSPP_PLATFORM(MAC) +#include "SDL2/SDL.h" #else #include "SDL.h" -#include "SDL_thread.h" +#endif #endif #include diff --git a/SDL/SDLMain.cpp b/SDL/SDLMain.cpp index 8a690407aa..ce35297811 100644 --- a/SDL/SDLMain.cpp +++ b/SDL/SDLMain.cpp @@ -7,7 +7,13 @@ #include #include "ppsspp_config.h" +#if PPSSPP_PLATFORM(MAC) +#include "SDL2/SDL.h" +#include "SDL2/SDL_syswm.h" +#else #include "SDL.h" +#include "SDL_syswm.h" +#endif #include "SDL/SDLJoystick.h" SDLJoystick *joystick = NULL; @@ -35,8 +41,6 @@ SDLJoystick *joystick = NULL; #include "Common/GPU/OpenGL/GLRenderManager.h" #include "Common/Profiler/Profiler.h" -#include "SDL_syswm.h" - #if defined(VK_USE_PLATFORM_XLIB_KHR) #include #include diff --git a/SDL/SDLMain.mm b/SDL/SDLMain.mm index 4709e8f5f8..a53ccc3752 100644 --- a/SDL/SDLMain.mm +++ b/SDL/SDLMain.mm @@ -5,7 +5,12 @@ Feel free to customize this file to suit your needs */ +#include "ppsspp_config.h" +#if PPSSPP_PLATFORM(MAC) +#include "SDL2/SDL.h" +#else #include "SDL.h" +#endif #include "SDLMain.h" #include "Common/Profiler/Profiler.h" #include diff --git a/SDL/SDLVulkanGraphicsContext.cpp b/SDL/SDLVulkanGraphicsContext.cpp index 608ad3dbbd..b46858068f 100644 --- a/SDL/SDLVulkanGraphicsContext.cpp +++ b/SDL/SDLVulkanGraphicsContext.cpp @@ -10,7 +10,11 @@ #include "Common/Data/Text/Parsers.h" #include "Core/System.h" +#if PPSSPP_PLATFORM(MAC) +#include "SDL2/SDL_vulkan.h" +#else #include "SDL_vulkan.h" +#endif #include "SDLVulkanGraphicsContext.h" #if defined(VK_USE_PLATFORM_METAL_EXT) diff --git a/SDL/SDLVulkanGraphicsContext.h b/SDL/SDLVulkanGraphicsContext.h index f97b528764..d309e685d5 100644 --- a/SDL/SDLVulkanGraphicsContext.h +++ b/SDL/SDLVulkanGraphicsContext.h @@ -1,5 +1,11 @@ +#include "ppsspp_config.h" +#if PPSSPP_PLATFORM(MAC) +#include "SDL2/SDL.h" +#include "SDL2/SDL_syswm.h" +#else #include "SDL.h" #include "SDL_syswm.h" +#endif #include "Common/GraphicsContext.h" #include "Common/GPU/Vulkan/VulkanContext.h" diff --git a/SDL/macOS b/SDL/macOS index f19a1d54b8..c387d93ab5 160000 --- a/SDL/macOS +++ b/SDL/macOS @@ -1 +1 @@ -Subproject commit f19a1d54b8a5af6cc378ea307e0ec676922eb4cc +Subproject commit c387d93ab5910b5a6be78b4840a5bbbc452f3ac8 diff --git a/SDL/macbundle.sh b/SDL/macbundle.sh index d54a0517ae..b1ab6d5c81 100755 --- a/SDL/macbundle.sh +++ b/SDL/macbundle.sh @@ -3,39 +3,25 @@ PPSSPP="${1}" PPSSPPSDL="${PPSSPP}/Contents/MacOS/PPSSPPSDL" +ls ${PPSSPPSDL} + if [ ! -f "${PPSSPPSDL}" ]; then echo "No such file: ${PPSSPPSDL}!" exit 0 fi -SDL=$(otool -L "${PPSSPPSDL}" | grep -v @executable_path | grep -Eo /.+libSDL.+dylib) -if [ "${SDL}" != "" ]; then - if [ ! -f "${SDL}" ]; then - echo "Cannot locate SDL: ${SDL}!" - exit 0 - fi +# We only support using the local SDL framework. +# All the old detection code has been eliminated. +SDL=../SDL/macOS/SDL2.framework - echo "Installing SDL from ${SDL}..." +echo "Copying SDL2.framework..." - SDLNAME=$(basename "${SDL}") - mkdir -p "${PPSSPP}/Contents/Frameworks" || exit 0 - cp -r "$SDL" "${PPSSPP}/Contents/Frameworks" || exit 0 - install_name_tool -change "${SDL}" "@executable_path/../Frameworks/${SDLNAME}" "${PPSSPPSDL}" || exit 0 -elif [ "$(otool -L "${PPSSPPSDL}" | grep @rpath/SDL)" != "" ]; then - cd "$(dirname "$0")" - RPATH="$(pwd)/macOS" - cd - - SDL="${RPATH}/SDL2.framework" - if [ ! -d "${SDL}" ]; then - echo "Cannot locate SDL.framework: ${SDL}!" - exit 0 - fi +mkdir -p "${PPSSPP}/Contents/Frameworks" || exit 0 +cp -r "$SDL" "${PPSSPP}/Contents/Frameworks" || exit 0 - rm -rf "${PPSSPP}/Contents/Frameworks/SDL2.framework" || exit 0 - mkdir -p "${PPSSPP}/Contents/Frameworks" || exit 0 - cp -a "$SDL" "${PPSSPP}/Contents/Frameworks" || exit 0 - install_name_tool -rpath "${RPATH}" "@executable_path/../Frameworks" "${PPSSPPSDL}" || echo "Already patched." -fi +install_name_tool -change "${SDL}" "@executable_path/../Frameworks/${SDLNAME}" "${PPSSPPSDL}" || exit 0 + +echo "Done." GIT_VERSION_LINE=$(grep "PPSSPP_GIT_VERSION = " "$(dirname "${0}")/../git-version.cpp") echo "Setting version to '${GIT_VERSION_LINE}'..." @@ -50,4 +36,5 @@ else fi # AdHoc codesign is required for Apple Silicon. -codesign -fs - --deep "${PPSSPP}" || exit 1 +echo "Signing..." +#codesign -fs - --deep "${PPSSPP}" || exit 1 diff --git a/headless/SDLHeadlessHost.cpp b/headless/SDLHeadlessHost.cpp index 8aa0741782..7333e46460 100644 --- a/headless/SDLHeadlessHost.cpp +++ b/headless/SDLHeadlessHost.cpp @@ -18,7 +18,13 @@ #ifdef SDL #include -#include + +#include "ppsspp_config.h" +#if PPSSPP_PLATFORM(MAC) +#include "SDL2/SDL.h" +#else +#include "SDL.h" +#endif #include "headless/SDLHeadlessHost.h" #include "Common/GPU/OpenGL/GLCommon.h"