From 26415d39f7b91eec39f6de929a6873de18b41d04 Mon Sep 17 00:00:00 2001 From: Laura Braun Date: Sun, 18 Aug 2024 18:12:38 +0530 Subject: [PATCH] Meta: Check for CMake version in ladybird.sh CMake reads CMakePresets.json, which is before it reads CMakeLists.txt. This causes CMake Error: Unrecognized "version" field if the version of CMake is older than support for presets, or the version field of presets. The fix is to check CMake version in ladybird.sh before trying to create the build directory. Co-Authored-By: Andrew Kaster --- Meta/ladybird.sh | 1 + Meta/shell_include.sh | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+) diff --git a/Meta/ladybird.sh b/Meta/ladybird.sh index 62a594699bc..b2f043b3149 100755 --- a/Meta/ladybird.sh +++ b/Meta/ladybird.sh @@ -88,6 +88,7 @@ get_top_dir() { } create_build_dir() { + check_program_version_at_least CMake cmake 3.25 || exit 1 cmake --preset "$BUILD_PRESET" "${CMAKE_ARGS[@]}" -S "$LADYBIRD_SOURCE_DIR" -B "$BUILD_DIR" } diff --git a/Meta/shell_include.sh b/Meta/shell_include.sh index 16c72f3f2b2..37162a08f44 100644 --- a/Meta/shell_include.sh +++ b/Meta/shell_include.sh @@ -17,6 +17,24 @@ exit_if_running_as_root() { fi } +# Usage: check_program_version_at_least +check_program_version_at_least() +{ + echo -n "Checking for $1 version at least $3... " + if ! command -v "$2" > /dev/null 2>&1; then + echo "ERROR: Cannot find $2 ($1)" + return 1 + fi + v=$("$2" --version 2>&1 | grep -E -o '[0-9]+\.[0-9\.]+[a-z]*' | head -n1) + if printf '%s\n' "$3" "$v" | sort --version-sort --check &>/dev/null; then + echo "ok, found $v" + return 0; + else + echo "ERROR: found version $v, too old!" + return 1; + fi +} + find_executable() { paths=("/usr/sbin" "/sbin")