From d083efb4ab45275940c02bc72e23d334fe596fe7 Mon Sep 17 00:00:00 2001 From: Justin Kinnaird Date: Sun, 17 Nov 2019 11:35:21 -0600 Subject: [PATCH 1/2] feat: do resource lookups in standard directories For Linux, this includes the following directories: * /.local/share/ * /usr/local/share/ * /usr/share/ --- CMakeLists.txt | 4 ++++ es-core/src/resources/ResourceManager.cpp | 18 ++++++++++++++++++ 2 files changed, 22 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index a167a808fb..640783ae13 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -7,6 +7,10 @@ option(CEC "Set to ON to enable CEC" ${CEC}) project(emulationstation-all) +# program name to be used as a reference when looking up resources +set(AppDataName "EmulationStation" CACHE STRING "Internal program name passed to compiler") +add_definitions(-DAPPDATANAME="${AppDataName}") + #------------------------------------------------------------------------------- #add local find scripts to CMAKE path LIST(APPEND CMAKE_MODULE_PATH diff --git a/es-core/src/resources/ResourceManager.cpp b/es-core/src/resources/ResourceManager.cpp index 9f5014e432..7fd54acea5 100644 --- a/es-core/src/resources/ResourceManager.cpp +++ b/es-core/src/resources/ResourceManager.cpp @@ -3,6 +3,10 @@ #include "utils/FileSystemUtil.h" #include +#ifndef APPDATANAME +#define APPDATANAME "EmulationStation" +#endif + auto array_deleter = [](unsigned char* p) { delete[] p; }; auto nop_deleter = [](unsigned char* /*p*/) { }; @@ -27,6 +31,20 @@ std::string ResourceManager::getResourcePath(const std::string& path) const { std::string test; + // check in standard AppData locations +#if defined(__linux__) + test = Utils::FileSystem::getHomePath() + "/.local/share/" + APPDATANAME + "/resources/" + &path[2]; + if (Utils::FileSystem::exists(test)) + return test; + + test = std::string("/usr/local/share/") + APPDATANAME + "/resources/" + &path[2]; + if (Utils::FileSystem::exists(test)) + return test; + + test = std::string("/usr/share/") + APPDATANAME + "/resources/" + &path[2]; + if (Utils::FileSystem::exists(test)) + return test; +#endif // check in homepath test = Utils::FileSystem::getHomePath() + "/.emulationstation/resources/" + &path[2]; if(Utils::FileSystem::exists(test)) From c930587250a567d34baef7d6bf3a626f9bde6f4b Mon Sep 17 00:00:00 2001 From: Justin Kinnaird Date: Sun, 17 Nov 2019 12:06:58 -0600 Subject: [PATCH 2/2] chore: Add "resources" to make install --- CMakeLists.txt | 4 ++++ es-app/CMakeLists.txt | 5 +++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 640783ae13..05ba66a834 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -7,6 +7,7 @@ option(CEC "Set to ON to enable CEC" ${CEC}) project(emulationstation-all) + # program name to be used as a reference when looking up resources set(AppDataName "EmulationStation" CACHE STRING "Internal program name passed to compiler") add_definitions(-DAPPDATANAME="${AppDataName}") @@ -251,6 +252,9 @@ set(dir ${CMAKE_CURRENT_SOURCE_DIR}) set(EXECUTABLE_OUTPUT_PATH ${dir} CACHE PATH "Build directory" FORCE) set(LIBRARY_OUTPUT_PATH ${dir} CACHE PATH "Build directory" FORCE) +# install rules for resources +include(GNUInstallDirs) +install(DIRECTORY resources DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/${AppDataName}/resources") #------------------------------------------------------------------------------- # add each component diff --git a/es-app/CMakeLists.txt b/es-app/CMakeLists.txt index 4ff4fdcce9..3bb6d6ab69 100644 --- a/es-app/CMakeLists.txt +++ b/es-app/CMakeLists.txt @@ -142,10 +142,11 @@ endif() #------------------------------------------------------------------------------- # set up CPack install stuff so `make install` does something useful - +include(GNUInstallDirs) install(TARGETS emulationstation RUNTIME - DESTINATION bin) + DESTINATION "${CMAKE_INSTALL_BINDIR}") + INCLUDE(InstallRequiredSystemLibraries)