From ae78c343cde1fad5aad88f0bf59cc7a91dfec0e5 Mon Sep 17 00:00:00 2001 From: Charles Zablit Date: Thu, 19 Nov 2026 13:39:35 +0000 Subject: [PATCH] Honor CMAKE_VERSION in cmake-build.sh by downloading the requested CMake release (#3795) `cmake_tests.yml` has a `cmake_version` input and passes it to `scripts/cmake-build.sh` as `CMAKE_VERSION`, but the script does not use that value, so the CMake from the image's apt is used instead. With this patch, when `CMAKE_VERSION` is set, the script downloads the release from Kitware's GitHub releases on Linux (x86_64/aarch64) and uses it for the build. This lets projects that need a newer CMake than the image's apt provides use the shared workflow by setting `cmake_version`. This is blocking https://github.com/apple/swift-certificates/pull/325. --- scripts/cmake-build.sh | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/scripts/cmake-build.sh b/scripts/cmake-build.sh index 6aad6aee7..7d76d827a 100755 --- a/scripts/cmake-build.sh +++ b/scripts/cmake-build.sh @@ -25,8 +25,24 @@ if [ -z "$target_dir" ]; then fatal "Target directory must be specified." fi +cmake_version="${CMAKE_VERSION:=""}" + CURL_BIN="${CURL_BIN:-$(which curl)}" || fatal "CURL_BIN unset and no curl on PATH" TAR_BIN="${TAR_BIN:-$(which tar)}" || fatal "TAR_BIN unset and no tar on PATH" + +if [ -n "$cmake_version" ]; then + [ "$(uname -s)" = "Linux" ] || fatal "CMAKE_VERSION is only supported on Linux." + cmake_arch="$(uname -m)" + cmake_dist="cmake-${cmake_version}-linux-${cmake_arch}" + cmake_url="https://github.com/Kitware/CMake/releases/download/v${cmake_version}/${cmake_dist}.tar.gz" + cmake_install_dir="$(mktemp -d)" || fatal "Could not create a temporary directory for CMake" + + log "Downloading CMake ${cmake_version} from ${cmake_url}" + "$CURL_BIN" -fsSL --retry 3 "$cmake_url" | "$TAR_BIN" -xz -C "$cmake_install_dir" \ + || fatal "Failed to download or extract CMake ${cmake_version}" + CMAKE_BIN="${cmake_install_dir}/${cmake_dist}/bin/cmake" +fi + CMAKE_BIN="${CMAKE_BIN:-$(which cmake)}" || fatal "CMAKE_BIN unset and no cmake on PATH" NINJA_BIN="${NINJA_BIN:-$(which ninja)}" || fatal "NINJA_BIN unset and no ninja on PATH" ASSEMBLY_COMPILER_BIN="${ASSEMBLY_COMPILER_BIN:-$(which clang)}" || fatal "ASSEMBLY_COMPILER_BIN unset and no clang on PATH"