From f033bccd3cfe3aa718c54bfae4568074e585f936 Mon Sep 17 00:00:00 2001 From: Johannes Altmanninger Date: Sun, 4 Aug 2024 10:18:06 +0200 Subject: [PATCH] Move fish build dir canonicalization into build.rs, to lower CMake version --- CMakeLists.txt | 3 +-- build.rs | 2 ++ cmake/Rust.cmake | 5 +---- 3 files changed, 4 insertions(+), 6 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index d8f241bed..e42ec45a7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,5 +1,4 @@ -# CMake 3.19 is needed for file(REAL_PATH) -cmake_minimum_required(VERSION 3.19) +cmake_minimum_required(VERSION 3.5) list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/cmake") diff --git a/build.rs b/build.rs index 6284b7e3e..59fb29179 100644 --- a/build.rs +++ b/build.rs @@ -15,6 +15,8 @@ fn main() { // OUT_DIR is set by Cargo when the build script is running (not compiling) let default_build_dir = env::var("OUT_DIR").unwrap(); let build_dir = option_env!("FISH_BUILD_DIR").unwrap_or(&default_build_dir); + let build_dir = std::fs::canonicalize(build_dir).unwrap(); + let build_dir = build_dir.to_str().unwrap(); rsconf::set_env_value("FISH_BUILD_DIR", build_dir); // We need to canonicalize (i.e. realpath) the manifest dir because we want to be able to // compare it directly as a string at runtime. diff --git a/cmake/Rust.cmake b/cmake/Rust.cmake index 36bc34ea3..057262a41 100644 --- a/cmake/Rust.cmake +++ b/cmake/Rust.cmake @@ -29,9 +29,6 @@ if(DEFINED WITH_GETTEXT AND NOT "${WITH_GETTEXT}") set(CMAKE_WITH_GETTEXT "0") endif() -# CMAKE_BINARY_DIR can include symlinks, since we want to compare this to the dir fish is executed in we need to canonicalize it. -file(REAL_PATH "${CMAKE_BINARY_DIR}" fish_binary_dir) - if(FISH_CRATE_FEATURES) set(FEATURES_ARG ${FISH_CRATE_FEATURES}) list(PREPEND FEATURES_ARG "--features") @@ -44,7 +41,7 @@ get_property( # Tell Cargo where our build directory is so it can find Cargo.toml. set(VARS_FOR_CARGO - "FISH_BUILD_DIR=${fish_binary_dir}" + "FISH_BUILD_DIR=${CMAKE_BINARY_DIR}" "PREFIX=${CMAKE_INSTALL_PREFIX}" # Temporary hack to propogate CMake flags/options to build.rs. "CMAKE_WITH_GETTEXT=${CMAKE_WITH_GETTEXT}"