From 1f4cbd15968ce914a964e1c73d397525c0941f95 Mon Sep 17 00:00:00 2001 From: Dmitry Marakasov Date: Thu, 22 Dec 2011 20:01:45 +0400 Subject: [PATCH] Pass data directory to the game --- CMakeLists.txt | 2 ++ src/Settings.cpp | 5 +++++ 2 files changed, 7 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index f3a22abb..0e53b208 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -26,6 +26,8 @@ endif() set(BINDIR "games" CACHE STRING "where to install game binary") set(DATADIR "share/games/flare" CACHE STRING "where to install game data") +add_definitions(-DDATA_INSTALL_DIR="${CMAKE_INSTALL_PREFIX}/${DATADIR}") + # Detect missing dependencies Find_Package (SDL REQUIRED) diff --git a/src/Settings.cpp b/src/Settings.cpp index 2f989cd7..42b5af7f 100644 --- a/src/Settings.cpp +++ b/src/Settings.cpp @@ -171,6 +171,11 @@ void setPaths() { pathtest = eatFirstString(pathlist,':'); } } + +#if defined DATA_INSTALL_DIR + PATH_DATA = DATA_INSTALL_DIR "/"; + if (dirExists(PATH_DATA)) return; // NOTE: early exit +#endif // check /usr/local/share/flare/ and /usr/share/flare/ next PATH_DATA = "/usr/local/share/" + engine_folder + "/";