diff --git a/changelog b/changelog index 59ce44d14c32..356ac6f41b27 100644 --- a/changelog +++ b/changelog @@ -227,6 +227,9 @@ Version 1.13.0-dev: * Fix an inefficient implementation of unit::invisible, in an effort to address slow performance problems: http://forums.wesnoth.org/viewtopic.php?f=4&t=12139&start=180#p569931 (Also see gfgtdf's commits trying to optimize the minimap loop) + * Made it so /../ (non-Windows) or /../ + (Windows) are also considered possible data directories if they contain a + data/_main.cfg file, intended to help with cmake builds. Version 1.11.11: * Add-ons server: diff --git a/src/wesnoth.cpp b/src/wesnoth.cpp index c3d54b228506..3988c11e5646 100644 --- a/src/wesnoth.cpp +++ b/src/wesnoth.cpp @@ -791,11 +791,28 @@ int main(int argc, char** argv) const time_t t = time(NULL); std::cerr << "Started on " << ctime(&t) << "\n"; - const std::string exe_dir = get_exe_dir(); - if(!exe_dir.empty() && file_exists(exe_dir + "/data/_main.cfg")) { - std::cerr << "Automatically found a possible data directory at " - << exe_dir << '\n'; - game_config::path = exe_dir; + const std::string& exe_dir = get_exe_dir(); + if(!exe_dir.empty()) { + // Try to autodetect the location of the game data dir. Note that + // the root of the source tree currently doubles as the data dir. + std::string auto_dir; + + // scons leaves the resulting binaries at the root of the source + // tree by default. + if(file_exists(exe_dir + "/data/_main.cfg")) { + auto_dir = exe_dir; + } + // cmake encourages creating a subdir at the root of the source + // tree for the build, and the resulting binaries are found in it. + else if(file_exists(exe_dir + "/../data/_main.cfg")) { + auto_dir = normalize_path(exe_dir + "/.."); + } + + if(!auto_dir.empty()) { + std::cerr << "Automatically found a possible data directory at " + << auto_dir << '\n'; + game_config::path = auto_dir; + } } const int res = do_gameloop(argc,argv);