Rename FISH_BUILD_DIR variable, to assert that CMake is used

It's always the CMake output directory, so call it
FISH_CMAKE_BINARY_DIR. It's possible to set it via some other build
system but if such builds exist, they are likely subtly broken, or
at least with the following commit which adds the assumption that
"share/__fish_build_paths.fish.in" exists in this directory.

We could even call it CMAKE_BINARY_DIR but let's namespace it to make
our use more obvious. Also, stop using the $CMAKE environment variable,
it's not in our namespace.
This commit is contained in:
Johannes Altmanninger
2025-10-27 08:29:32 +01:00
parent 3b0fa95870
commit bae735740c
4 changed files with 4 additions and 9 deletions

View File

@@ -81,6 +81,7 @@ fn detect_cfgs(target: &mut Target) {
("", &(|_: &Target| false) as &dyn Fn(&Target) -> bool),
("apple", &detect_apple),
("bsd", &detect_bsd),
("using_cmake", &|_| option_env!("FISH_CMAKE_BINARY_DIR").is_some()),
("cygwin", &detect_cygwin),
("small_main_stack", &has_small_stack),
// See if libc supports the thread-safe localeconv_l(3) alternative to localeconv(3).

View File

@@ -31,10 +31,8 @@ list(JOIN FISH_CARGO_FEATURES_LIST , FISH_CARGO_FEATURES)
# Tell Cargo where our build directory is so it can find Cargo.toml.
set(VARS_FOR_CARGO
"FISH_BUILD_DIR=${CMAKE_BINARY_DIR}"
"FISH_CMAKE_BINARY_DIR=${CMAKE_BINARY_DIR}"
"PREFIX=${CMAKE_INSTALL_PREFIX}"
# Cheesy so we can tell cmake was used to build
"CMAKE=1"
"DOCDIR=${CMAKE_INSTALL_FULL_DOCDIR}"
"DATADIR=${CMAKE_INSTALL_FULL_DATADIR}"
"SYSCONFDIR=${CMAKE_INSTALL_FULL_SYSCONFDIR}"

View File

@@ -29,8 +29,7 @@ fn cargo_target_dir() -> Cow<'static, Path> {
}
pub fn fish_build_dir() -> Cow<'static, Path> {
// This is set if using CMake.
option_env!("FISH_BUILD_DIR")
option_env!("FISH_CMAKE_BINARY_DIR")
.map(|d| Cow::Borrowed(Path::new(d)))
.unwrap_or(cargo_target_dir())
}

View File

@@ -579,10 +579,7 @@ pub fn status(parser: &Parser, streams: &mut IoStreams, args: &mut [&wstr]) -> B
let host = bytes2wcstring(env!("BUILD_HOST_TRIPLE").as_bytes());
let profile = bytes2wcstring(env!("BUILD_PROFILE").as_bytes());
streams.out.append(L!("Build system: "));
let buildsystem = match option_env!("CMAKE") {
Some("1") => "CMake",
_ => "Cargo",
};
let buildsystem = if cfg!(using_cmake) { "CMake" } else { "Cargo" };
streams.out.appendln(bytes2wcstring(buildsystem.as_bytes()));
streams.out.append(L!("Version: "));
streams.out.appendln(version);