From 3bcf99583276bcb414844ab6b1dae7ca3294e73c Mon Sep 17 00:00:00 2001 From: Jonas Kulla Date: Sat, 2 Aug 2014 09:30:17 +0200 Subject: [PATCH] Add option to turn off switching into executable dir on startup --- CMakeLists.txt | 7 +++++++ README.md | 4 +++- src/main.cpp | 2 ++ 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index ca3a09d..0f38c37 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -5,6 +5,7 @@ Project(mkxp) option(RGSS2 "Enable RGSS2" OFF) option(MIDI "Enable midi support" ON) +option(WORKDIR_CURRENT "Keep current directory on startup" OFF) option(FORCE32 "Force 32bit compile on 64bit OS" OFF) set(BINDING "MRI" CACHE STRING "The Binding Type (MRI, MRUBY, NULL)") set(EXTERNAL_LIB_PATH "" CACHE PATH "External precompiled lib prefix") @@ -19,6 +20,12 @@ IF("${CMAKE_SYSTEM}" MATCHES "Linux") SET(LINUX ON) ENDIF() +IF(WORKDIR_CURRENT) + list(APPEND DEFINES + WORKDIR_CURRENT + ) +ENDIF() + IF(FORCE32) if(APPLE) SET(CMAKE_OSX_ARCHITECTURES "i386") diff --git a/README.md b/README.md index 37cbd1d..5efef96 100644 --- a/README.md +++ b/README.md @@ -53,6 +53,8 @@ The exception is boost, which is weird in that it still hasn't managed to pull o Midi support is enabled by default; you can disable it via `qmake CONFIG+=DISABLE_MIDI`, in which case the fluidsynth dependency is dropped. When building fluidsynth yourself, you can disable almost all options (audio drivers etc.) as they are not used. Note that upstream fluidsynth has support for sharing soundfont data between synthesizers (mkxp uses multiple synths), so if your memory usage is very high, you might want to try compiling fluidsynth from git master. +By default, mkxp switches into the directory where its binary is contained and then starts reading the configuration and resolving relative paths. In case this is undesired (eg. when the binary is to be installed to a system global, read-only location), it can be turned off by adding `DEFINES+=WORKDIR_CURRENT` to qmake's arguments. + **MRI-Binding**: pkg-config will look for `ruby-2.1.pc`, but you can modify mkxp.pro to use 2.0 instead. This is the default binding, so no arguments to qmake needed (`BINDING=MRI` to be explicit). **MRuby-Binding**: place the "mruby" folder into the project folder and build it first. Add `BINDING=MRUBY` to qmake's arguments. @@ -66,7 +68,7 @@ To run mkxp, you should have a graphics card capable of at least **OpenGL (ES) 2 ## Configuration -mkxp reads configuration data from the file "mkxp.conf" contained in the current directory. The format is ini-style. Do *not* use quotes around file paths (spaces won't break). Lines starting with '#' are comments. See 'mkxp.conf.sample' for a list of accepted entries. +mkxp reads configuration data from the file "mkxp.conf". The format is ini-style. Do *not* use quotes around file paths (spaces won't break). Lines starting with '#' are comments. See 'mkxp.conf.sample' for a list of accepted entries. ## Midi music (*ALPHA STATUS*) diff --git a/src/main.cpp b/src/main.cpp index 187e6b3..e2d4772 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -175,6 +175,7 @@ int main(int argc, char *argv[]) return 0; } +#ifndef WORKDIR_CURRENT /* set working directory */ char *dataDir = SDL_GetBasePath(); if (dataDir) @@ -183,6 +184,7 @@ int main(int argc, char *argv[]) (void)result; SDL_free(dataDir); } +#endif /* now we load the config */ Config conf;