fish.cpp: Dirs relative to CMAKE_SOURCE_DIR, don't assume 'fish'

This was causing problems if "fish" wasn't in exec_path, like
if the binary had been renamed.

I also noticed that even with 'fish' not renamed, only paths.data
was made relative to my source tree. paths.sysconf, paths.doc, and
paths.bin were all relative to /usr/local.
This commit is contained in:
Aaron Gyes
2018-11-25 14:06:32 -08:00
parent 40799d9e95
commit 9e7034c903

View File

@@ -94,18 +94,19 @@ static struct config_paths_t determine_config_directory_paths(const char *argv0)
bool done = false;
std::string exec_path = get_executable_path(argv0);
if (get_realpath(exec_path)) {
debug(2, L"exec_path: '%s'", exec_path.c_str());
debug(2, L"exec_path: '%s', argv[0]: '%s'", exec_path.c_str(), argv0);
// TODO: we should determine program_name from argv0 somewhere in this file
#ifdef CMAKE_BINARY_DIR
// Detect if we're running right out of the CMAKE build directory
if (exec_path == std::string(CMAKE_BINARY_DIR) + "/fish") {
debug(2, "Running out of build directory, falling back to source paths");
if (string_prefixes_string(CMAKE_BINARY_DIR, exec_path.c_str())) {
debug(2, "Running out of build directory, using paths relative to CMAKE_SOURCE_DIR:\n %s", CMAKE_SOURCE_DIR);
done = true;
paths.data = wcstring{L"" CMAKE_SOURCE_DIR} + L"/share";
paths.sysconf = L"" SYSCONFDIR "/fish";
paths.doc = L"" DOCDIR;
paths.bin = L"" BINDIR;
paths.sysconf = wcstring{L"" CMAKE_SOURCE_DIR} + L"/etc";
paths.doc = wcstring{L"" CMAKE_SOURCE_DIR} + L"/user_doc/html";
paths.bin = wcstring{L"" CMAKE_BINARY_DIR};
}
#endif