build: Add CMake build #81
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# inspired by "build GDAL library and to run test with CMake" | |
# from https://github.com/OSGeo/gdal/blob/master/.github/workflows/cmake_builds.yml | |
--- | |
name: CMake | |
on: | |
push: | |
paths-ignore: | |
- 'doc/**' | |
branches: | |
- main | |
- releasebranch_* | |
pull_request: | |
paths-ignore: | |
- 'doc/**' | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.head_ref || github.ref }} | |
cancel-in-progress: true | |
env: | |
CMAKE_UNITY_BUILD: OFF | |
permissions: | |
contents: read # to fetch code (actions/checkout) | |
jobs: | |
build-cmake: | |
runs-on: ubuntu-20.04 | |
env: | |
CMAKE_OPTIONS: -DPython_LOOKUP_VERSION=3.8 -DUSE_CCACHE=ON | |
cache-name: cmake-ubuntu-20.04 | |
steps: | |
- name: Checkout GRASS | |
uses: actions/checkout@v4.1.1 | |
- name: Setup cache | |
uses: actions/cache@v4.0.2 | |
id: cache | |
with: | |
path: ${{ github.workspace }}/.ccache | |
key: "${{ env.cache-name }}-${{ runner.os }}-${{ github.base_ref }}\ | |
${{ github.ref_name }}-${{ github.run_id }}" | |
restore-keys: | | |
${{ env.cache-name }}-${{ runner.os }}-${{ github.base_ref }} | |
${{ env.cache-name }}-${{ runner.os }} | |
- name: Install CMake 3.16.0 | |
run: | | |
cd ${GITHUB_WORKSPACE} | |
wget https://github.com/Kitware/CMake/releases/download/v3.16.0/cmake-3.16.0-Linux-x86_64.tar.gz | |
tar xzf cmake-3.16.0-Linux-x86_64.tar.gz | |
echo "CMAKE_DIR=$GITHUB_WORKSPACE/cmake-3.16.0-Linux-x86_64/bin" >> $GITHUB_ENV | |
echo "$GITHUB_WORKSPACE/cmake-3.16.0-Linux-x86_64/bin" >> $GITHUB_PATH | |
- run: | | |
cmake --version | |
- name: Install dependencies | |
run: | | |
sudo add-apt-repository -y ppa:ubuntugis/ubuntugis-unstable | |
sudo apt-get update | |
sudo apt-get install -y -q build-essential \ | |
flex make bison gcc libgcc1 g++ ccache \ | |
python3 python3-dev \ | |
python3-opengl python3-wxgtk4.0 \ | |
python3-dateutil libgsl-dev python3-numpy \ | |
wx3.0-headers wx-common libwxgtk3.0-gtk3-dev \ | |
libwxbase3.0-dev libbz2-dev zlib1g-dev gettext \ | |
libtiff5-dev libpnglite-dev libcairo2 libcairo2-dev \ | |
sqlite3 libsqlite3-dev \ | |
libpq-dev libreadline6-dev libfreetype6-dev \ | |
libfftw3-3 libfftw3-dev \ | |
libboost-thread-dev libboost-program-options-dev libpdal-dev\ | |
subversion libzstd-dev checkinstall \ | |
libglu1-mesa-dev libxmu-dev \ | |
ghostscript wget -y make ccache g++ | |
- run: python -m pip install ninja | |
- name: Configure ccache | |
run: | | |
echo CCACHE_BASEDIR=$PWD >> ${GITHUB_ENV} | |
echo CCACHE_DIR=$PWD/.ccache >> ${GITHUB_ENV} | |
echo CCACHE_MAXSIZE=250M >> ${GITHUB_ENV} | |
ccache -z | |
working-directory: ${{ github.workspace }} | |
- name: Print build environment variables | |
shell: bash -el {0} | |
run: | | |
printenv | sort | |
gcc --version | |
ldd --version | |
- name: Create installation directory | |
run: | | |
mkdir $HOME/install | |
- name: Configure | |
run: | | |
cmake ${CMAKE_OPTIONS} -S $GITHUB_WORKSPACE -B $GITHUB_WORKSPACE/build -G Ninja \ | |
-DCMAKE_INSTALL_PREFIX=$HOME/install -DWITH_NLS=OFF \ | |
-DCMAKE_C_FLAGS="-I/usr/include -I/usr/include/gdal" \ | |
-DCMAKE_CXX_FLAGS="-I/usr/include -I/usr/include/gdal" | |
- name: Print CMakeCache.txt | |
shell: bash -el {0} | |
run: | | |
cat ${GITHUB_WORKSPACE}/build/CMakeCache.txt | |
- name: Build | |
run: | | |
cmake --build build --verbose -j$(nproc) | |
- name: Install | |
run: | | |
cmake --install $GITHUB_WORKSPACE/build --verbose | |
- name: Add the bin directory to PATH | |
run: | | |
echo "$HOME/install/bin" >> $GITHUB_PATH | |
- name: Print installed versions | |
if: always() | |
run: .github/workflows/print_versions.sh | |
- name: Test executing of the grass command | |
run: .github/workflows/test_simple.sh | |
- name: Run tests | |
run: .github/workflows/test_thorough.sh --config .gunittest.cfg | |
- name: ccache statistics | |
run: ccache -s |