Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

make install support #618

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@ 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
Expand Down Expand Up @@ -247,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
Expand Down
5 changes: 3 additions & 2 deletions es-app/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
18 changes: 18 additions & 0 deletions es-core/src/resources/ResourceManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
#include "utils/FileSystemUtil.h"
#include <fstream>

#ifndef APPDATANAME
#define APPDATANAME "EmulationStation"
#endif

auto array_deleter = [](unsigned char* p) { delete[] p; };
auto nop_deleter = [](unsigned char* /*p*/) { };

Expand All @@ -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))
Expand Down