From b4a01dfb5c370982b0fb6e8c9ae11fa77fa21f30 Mon Sep 17 00:00:00 2001 From: Ghabry Date: Mon, 29 Oct 2018 15:16:15 +0100 Subject: [PATCH] libretro: Add libretro-common submodule & Cmake file, update Readme --- .gitmodules | 3 +++ CMakeLists.txt | 4 ++++ README.md | 21 +++++++++++++++++++-- builds/libretro/CMakeLists.txt | 22 ++++++++++++++++++++++ builds/libretro/libretro-common | 1 + 5 files changed, 49 insertions(+), 2 deletions(-) create mode 100644 .gitmodules create mode 100644 builds/libretro/CMakeLists.txt create mode 160000 builds/libretro/libretro-common diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000000..ae73a2ecec --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "builds/libretro/libretro-common"] + path = builds/libretro/libretro-common + url = https://github.com/libretro/libretro-common diff --git a/CMakeLists.txt b/CMakeLists.txt index a492c4bfb7..7f36e4ff2a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -384,7 +384,11 @@ elseif(${PLAYER_TARGET_PLATFORM} STREQUAL "libretro") src/libretro_wrapper.cpp) target_compile_definitions(${PROJECT_NAME} PUBLIC USE_LIBRETRO=1) set(PLAYER_BUILD_EXECUTABLE OFF) + set_target_properties(${PROJECT_NAME} PROPERTIES PREFIX "") set_target_properties(${PROJECT_NAME} PROPERTIES OUTPUT_NAME "easyrpg_libretro") + + add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/builds/libretro) + target_link_libraries(${PROJECT_NAME} retro_common) else() message(FATAL_ERROR "Invalid target platform") endif() diff --git a/README.md b/README.md index 6f7112d9b5..ae4cd7ec71 100644 --- a/README.md +++ b/README.md @@ -94,8 +94,8 @@ https://wiki.easyrpg.org/development/compiling/player/autotools Building requirements: -- pkg-config (Not on Windows) -- CMake +- pkg-config (only on Linux) +- CMake 3.7 or newer Step-by-step instructions: @@ -112,6 +112,23 @@ https://wiki.easyrpg.org/development/compiling/player/cmake CMake is the only supported way to build liblcf for Windows. All dependencies must be installed with [vcpkg]. +### Building a libretro core: + +Building for libretro is based on the CMake method. + +Additional commands required before building: + + git submodule init # Init submodules + git submodule update # Clone libretro-common submodule + +Invoke CMake with these additional parameters: + + cmake . -DPLAYER_TARGET_PLATFORM=libretro -DBUILD_SHARED_LIBS=ON|OFF + +Set shared libs to ON or OFF depending on which type of libraries RetroArch +uses on the platform you are targeting. + + ## Running EasyRPG Player Run the `easyrpg-player` executable from a RPG Maker 2000 or 2003 game diff --git a/builds/libretro/CMakeLists.txt b/builds/libretro/CMakeLists.txt new file mode 100644 index 0000000000..7548871de9 --- /dev/null +++ b/builds/libretro/CMakeLists.txt @@ -0,0 +1,22 @@ +cmake_minimum_required(VERSION 3.7) + +project(retro_common VERSION 1.0 LANGUAGES C) + +# Check availability of libretro-common submodule +file(GLOB RETRO_COMMON_DIR ${CMAKE_CURRENT_SOURCE_DIR}/libretro-common/*) +list(LENGTH RETRO_COMMON_DIR RETRO_COMMON_DIR_LEN) +if(RETRO_COMMON_DIR_LEN EQUAL 0) + message(FATAL_ERROR "libretro-common is empty. Run \"git submodule update --init\" and try again.") +endif() + +add_library(retro_common STATIC + libretro-common/rthreads/rthreads.c +) + +target_include_directories(retro_common PUBLIC + libretro-common/include) + +# FIXME: Likely won't work on all platforms +target_link_libraries(retro_common "pthread") + +mark_as_advanced(RETRO_COMMON_DIR RETRO_COMMON_DIR_LEN) diff --git a/builds/libretro/libretro-common b/builds/libretro/libretro-common new file mode 160000 index 0000000000..5cd072170d --- /dev/null +++ b/builds/libretro/libretro-common @@ -0,0 +1 @@ +Subproject commit 5cd072170d50714b28b997538076658583d70119