mirror of
https://github.com/fish-shell/fish-shell
synced 2025-01-14 22:14:53 +00:00
Detect when running out of cmake build directory
Load fish docs and configuration out of the source and/or build directories rather from the installed paths when running directly out of the cmake build directory. Closes #5255.
This commit is contained in:
parent
f212518d3e
commit
6bc59db721
2 changed files with 18 additions and 0 deletions
|
@ -94,6 +94,10 @@ ADD_DEFINITIONS(-D_UNICODE=1
|
||||||
# This defines the FBVF variable.
|
# This defines the FBVF variable.
|
||||||
INCLUDE(Version)
|
INCLUDE(Version)
|
||||||
|
|
||||||
|
# Let fish pick up when we're running out of the build directory without installing
|
||||||
|
ADD_DEFINITIONS(-DCMAKE_BINARY_DIR="${CMAKE_BINARY_DIR}")
|
||||||
|
ADD_DEFINITIONS(-DCMAKE_SOURCE_DIR="${CMAKE_SOURCE_DIR}")
|
||||||
|
|
||||||
# Teach fish_version.o to rebuild when FBVF changes.
|
# Teach fish_version.o to rebuild when FBVF changes.
|
||||||
# The standard C++ include detection machinery misses this.
|
# The standard C++ include detection machinery misses this.
|
||||||
SET_SOURCE_FILES_PROPERTIES(src/fish_version.cpp
|
SET_SOURCE_FILES_PROPERTIES(src/fish_version.cpp
|
||||||
|
|
14
src/fish.cpp
14
src/fish.cpp
|
@ -95,6 +95,20 @@ static struct config_paths_t determine_config_directory_paths(const char *argv0)
|
||||||
std::string exec_path = get_executable_path(argv0);
|
std::string exec_path = get_executable_path(argv0);
|
||||||
if (get_realpath(exec_path)) {
|
if (get_realpath(exec_path)) {
|
||||||
debug(2, L"exec_path: '%s'", exec_path.c_str());
|
debug(2, L"exec_path: '%s'", exec_path.c_str());
|
||||||
|
|
||||||
|
#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");
|
||||||
|
|
||||||
|
done = true;
|
||||||
|
paths.data = wcstring{L"" CMAKE_SOURCE_DIR} + L"/share";
|
||||||
|
paths.sysconf = L"" SYSCONFDIR "/fish";
|
||||||
|
paths.doc = L"" DOCDIR;
|
||||||
|
paths.bin = L"" BINDIR;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
if (!done) {
|
if (!done) {
|
||||||
// The next check is that we are in a reloctable directory tree
|
// The next check is that we are in a reloctable directory tree
|
||||||
const char *installed_suffix = "/bin/fish";
|
const char *installed_suffix = "/bin/fish";
|
||||||
|
|
Loading…
Reference in a new issue