Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions Build/Scripts/HYPRE/build_hypre.bat
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,15 @@ echo ----------------------------------------------------------
echo ----------------------------------------------------------
echo.

echo Running CMake version check...
call %CURDIR%/../check_cmake_version.bat
if errorlevel 1 (
echo Exiting due to CMake version error.
pause
exit /b 1
)
echo Proceeding with build...

echo.
echo ----------------------------------------------------------
echo ----------------------------------------------------------
Expand Down
4 changes: 4 additions & 0 deletions Build/Scripts/HYPRE/build_hypre.sh
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@ echo "Checking for hypre repository..."

if [ -d "$FIREMODELS/hypre" ]; then
echo "Hypre repository exists. Building hypre library."

# Check CMake version.
source ../Scripts/check_cmake_version.sh

cd $FIREMODELS/hypre
# Handle possible corrupted state of repository
if git branch | grep -q "* master"; then
Expand Down
40 changes: 40 additions & 0 deletions Build/Scripts/check_cmake_version.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
@echo off
setlocal enabledelayedexpansion

set REQUIRED_MAJOR=3
set REQUIRED_MINOR=21
set VERSION_STRING=%REQUIRED_MAJOR%.%REQUIRED_MINOR%.0

:: Check if cmake is installed
where cmake >nul 2>nul
if errorlevel 1 (
echo Error: CMake is not installed. Please install CMake version %VERSION_STRING% or newer.
exit /b 1
)

:: Extract the version number
for /f "tokens=3" %%v in ('cmake --version ^| findstr /i "version"') do (
set VERSION=%%v
)

:: Parse version into major, minor, patch
for /f "tokens=1,2,3 delims=." %%a in ("!VERSION!") do (
set MAJOR=%%a
set MINOR=%%b
set PATCH=%%c
)

:: Compare major version
if !MAJOR! LSS %REQUIRED_MAJOR% (
echo Error: Installed CMake version is !VERSION!. Version %VERSION_STRING% or newer is required.
exit /b 1
)

:: Compare minor version if major matches
if !MAJOR! EQU %REQUIRED_MAJOR% if !MINOR! LSS %REQUIRED_MINOR% (
echo Error: Installed CMake version is !VERSION!. Version %VERSION_STRING% or newer is required.
exit /b 1
)

echo CMake version !VERSION! is sufficient.
exit /b 0
26 changes: 26 additions & 0 deletions Build/Scripts/check_cmake_version.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#!/bin/bash

# Required minimum version
REQUIRED_VERSION="3.21.0"

# Function to compare versions
version_ge() {
[ "$(printf '%s\n' "$2" "$1" | sort -V | head -n1)" = "$2" ]
}

# Check if cmake is installed
if ! command -v cmake &> /dev/null; then
echo "Error: CMake is not installed. Please install CMake version $REQUIRED_VERSION or newer."
exit 1
fi

# Get installed cmake version
INSTALLED_VERSION=$(cmake --version | head -n1 | awk '{print $3}')

# Compare versions
if version_ge "$INSTALLED_VERSION" "$REQUIRED_VERSION"; then
echo "CMake version $INSTALLED_VERSION is sufficient."
else
echo "Error: Installed CMake version is $INSTALLED_VERSION. Version $REQUIRED_VERSION or newer is required."
exit 1
fi
Loading