Re-add libretro core

This commit is contained in:
Connor McLaughlin 2021-05-10 13:36:00 +10:00
parent d38a1c9430
commit 1392a64a93
6 changed files with 62 additions and 6 deletions

View file

@ -24,6 +24,7 @@ set(CMAKE_OSX_DEPLOYMENT_TARGET "10.14.0" CACHE STRING "")
if(NOT ANDROID)
option(BUILD_NOGUI_FRONTEND "Build the NoGUI frontend" ON)
option(BUILD_QT_FRONTEND "Build the Qt frontend" ON)
option(BUILD_LIBRETRO_CORE "Build a libretro core" OFF)
option(ENABLE_DISCORD_PRESENCE "Build with Discord Rich Presence support" ON)
option(ENABLE_CHEEVOS "Build with RetroAchievements support" ON)
option(USE_SDL2 "Link with SDL2 for controller support" ON)
@ -40,7 +41,7 @@ endif()
if((LINUX OR FREEBSD) OR ANDROID)
option(USE_EGL "Support EGL OpenGL context creation" ON)
endif()
if((LINUX OR FREEBSD) AND NOT ANDROID)
if((LINUX OR FREEBSD) AND NOT ANDROID AND NOT BUILD_LIBRETRO_CORE)
option(USE_DRMKMS "Support DRM/KMS OpenGL contexts" OFF)
option(USE_FBDEV "Support FBDev OpenGL contexts" OFF)
option(USE_EVDEV "Support EVDev controller interface" ON)
@ -80,6 +81,40 @@ if(ANDROID)
endif()
# Disable platform integration when building for libretro.
if(BUILD_LIBRETRO_CORE)
message("Building libretro core, disabling platform integration.")
if(USE_EGL)
set(USE_EGL OFF)
endif()
if(BUILD_NOGUI_FRONTEND)
set(BUILD_NOGUI_FRONTEND OFF)
endif()
if(BUILD_QT_FRONTEND)
set(BUILD_QT_FRONTEND OFF)
endif()
if(ENABLE_DISCORD_PRESENCE)
set(ENABLE_DISCORD_PRESENCE OFF)
endif()
if(ENABLE_CHEEVOS)
set(ENABLE_CHEEVOS OFF)
endif()
if(USE_SDL2)
set(USE_SDL2 OFF)
endif()
if(USE_X11)
set(USE_X11 OFF)
endif()
if(USE_WAYLAND)
set(USE_WAYLAND OFF)
endif()
# Force PIC when compiling a libretro core.
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
endif()
# Common include/library directories on Windows.
if(WIN32 AND USE_SDL2)
set(SDL2_FOUND TRUE)
@ -235,7 +270,7 @@ endif()
# Write binaries to a seperate directory.
if(WIN32)
if(WIN32 AND NOT BUILD_LIBRETRO_CORE)
# For Windows, use the source directory, except for libretro.
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/bin/${CPU_ARCH}")
else()
@ -263,6 +298,6 @@ enable_testing()
add_subdirectory(dep)
add_subdirectory(src)
if(ANDROID)
if(ANDROID AND NOT BUILD_LIBRETRO_CORE)
add_subdirectory(android/app/src/cpp)
endif()

View file

@ -27,6 +27,10 @@ if(ENABLE_CHEEVOS)
add_subdirectory(rcheevos)
endif()
if(BUILD_LIBRETRO_CORE)
add_subdirectory(libretro-common)
endif()
if(${CPU_ARCH} STREQUAL "aarch32" OR ${CPU_ARCH} STREQUAL "aarch64")
add_subdirectory(vixl)
endif()

View file

@ -1,10 +1,16 @@
if(BUILD_LIBRETRO_CORE)
add_definitions("-DLIBRETRO=1")
endif()
add_subdirectory(common)
add_subdirectory(core)
add_subdirectory(scmversion)
add_subdirectory(common-tests)
if(WIN32)
add_subdirectory(updater)
if(NOT BUILD_LIBRETRO_CORE)
add_subdirectory(common-tests)
if(WIN32)
add_subdirectory(updater)
endif()
endif()
add_subdirectory(frontend-common)
@ -16,3 +22,8 @@ endif()
if(BUILD_QT_FRONTEND)
add_subdirectory(duckstation-qt)
endif()
if(BUILD_LIBRETRO_CORE)
add_subdirectory(duckstation-libretro)
endif()

View file

@ -222,6 +222,9 @@ endif()
if(APPLE)
# Needed for Vulkan Swap Chain.
target_link_libraries(common PRIVATE "objc")
endif()
if(APPLE AND NOT BUILD_LIBRETRO_CORE)
target_sources(common PRIVATE
gl/context_agl.mm
gl/context_agl.h

View file

@ -124,7 +124,9 @@ bool InitializeGlslang()
return false;
}
#ifndef LIBRETRO
std::atexit([]() { glslang::FinalizeProcess(); });
#endif
glslang_initialized = true;
return true;

View file

@ -13,6 +13,7 @@ struct WindowInfo
MacOS,
Android,
Display,
Libretro,
};
enum class SurfaceFormat