From d05618350220d505de43f3a35c7de90157d71ad0 Mon Sep 17 00:00:00 2001 From: Jesse Talavera-Greenberg Date: Tue, 10 Oct 2023 20:24:57 -0400 Subject: [PATCH] Get the core to build for Switch, minus networking --- cmake/ConfigureFeatures.cmake | 5 +++++ cmake/libretro-common.cmake | 2 ++ src/libretro/config/config.cpp | 3 ++- src/libretro/platform/lan.cpp | 2 ++ 4 files changed, 11 insertions(+), 1 deletion(-) diff --git a/cmake/ConfigureFeatures.cmake b/cmake/ConfigureFeatures.cmake index b7e8d81..f36917d 100644 --- a/cmake/ConfigureFeatures.cmake +++ b/cmake/ConfigureFeatures.cmake @@ -129,6 +129,7 @@ endif () if (NINTENDO_SWITCH OR (${CMAKE_SYSTEM_NAME} STREQUAL "NintendoSwitch")) set(HAVE_LIBNX ON) + set(SWITCH ON) message(STATUS "Building for Nintendo Switch") endif() @@ -240,6 +241,10 @@ function(add_common_definitions TARGET) if (HAVE_ZLIB) target_compile_definitions(${TARGET} PUBLIC HAVE_ZLIB) endif () + + if (SWITCH) + target_compile_definitions(${TARGET} PUBLIC SWITCH __SWITCH__) + endif () endfunction() # TODO: Detect if SSL is available; if so, define HAVE_SSL \ No newline at end of file diff --git a/cmake/libretro-common.cmake b/cmake/libretro-common.cmake index 4252529..0fd11b3 100644 --- a/cmake/libretro-common.cmake +++ b/cmake/libretro-common.cmake @@ -135,6 +135,8 @@ if (HAVE_ZLIB) ${libretro-common_SOURCE_DIR}/streams/trans_stream_zlib.c ) target_link_libraries(libretro-common PUBLIC zlibstatic) + target_include_directories(libretro-common SYSTEM PUBLIC ${zlib_SOURCE_DIR}) + target_include_directories(libretro-common PUBLIC ${zlib_BINARY_DIR}) endif () set_target_properties(libretro-common PROPERTIES PREFIX "" OUTPUT_NAME "libretro-common") \ No newline at end of file diff --git a/src/libretro/config/config.cpp b/src/libretro/config/config.cpp index f123891..af10ead 100644 --- a/src/libretro/config/config.cpp +++ b/src/libretro/config/config.cpp @@ -884,7 +884,7 @@ static void melonds::config::parse_audio_options() noexcept { } } - +#ifdef HAVE_NETWORKING static void melonds::config::parse_network_options() noexcept { ZoneScopedN("melonds::config::parse_network_options"); using retro::get_variable; @@ -896,6 +896,7 @@ static void melonds::config::parse_network_options() noexcept { net::_networkMode = NetworkMode::Indirect; } } +#endif static bool melonds::config::parse_video_options(bool initializing) noexcept { ZoneScopedN("melonds::config::parse_video_options"); diff --git a/src/libretro/platform/lan.cpp b/src/libretro/platform/lan.cpp index 0436ad9..19f1a47 100644 --- a/src/libretro/platform/lan.cpp +++ b/src/libretro/platform/lan.cpp @@ -101,6 +101,7 @@ int Platform::LAN_RecvPacket(u8 *data) { } } +#ifdef HAVE_DYLIB Platform::DynamicLibrary *Platform::DynamicLibrary_Load(const char *lib) { ZoneScopedN("Platform::DynamicLibrary_Load"); return static_cast(dylib_load(lib)); @@ -115,3 +116,4 @@ void *Platform::DynamicLibrary_LoadFunction(Platform::DynamicLibrary *lib, const ZoneScopedN("Platform::DynamicLibrary_LoadFunction"); return reinterpret_cast(dylib_proc(lib, name)); } +#endif \ No newline at end of file