How to compile GRASS GIS on macOS

# create a temporary directory
test -d ~/tmp || mkdir ~/tmp

# download the Minoconda3 installer
cd ~/tmp
curl https://repo.anaconda.com/miniconda/Miniconda3-latest-MacOSX-arm64.sh -o Miniconda3-latest-MacOSX-arm64.sh

# installer Miniconda3
chmod a+x Miniconda3-latest-MacOSX-arm64.sh
./Miniconda3-latest-MacOSX-arm64.sh -b -u -p ~/usr/local/opt/miniconda3
~/usr/local/opt/miniconda3/bin/conda init zsh
. ~/.zshrc

# add the conda-forge channel at top
conda config --add channels conda-forge
conda config --set channel_priority strict

# create a new environment for GRASS
conda create -n grass
conda activate grass

# install CMake and GitHub CLI
conda install cmake gh

# download GRASS GIS source code
test -d ~/usr/local/src || mkdir -p ~/usr/local/src
cd ~/usr/local/src
git clone git@github.com:OSGeo/grass.git
cd grass

# authorize GitHub CLI for your GitHub access
BROWSER=false gh auth login
# GitHub.com
# SSH
# select your SSH key for GitHub
# GitHub CLI
# Login with a web browser
# Enter
# Go to https://github.com/login/device in your browser
# Type the one-time code and authorize GitHub

# set the default repository
gh repo set-default
# OSGeo/grass

# checkout the CMake PR
gh pr checkout 3621

# install required libraries
conda install proj gdal gettext fftw pdal

# build GRASS
test -d build || mkdir build
cd build
cmake ..
make