Skip to content

CMake build system

CMake build system #15

Workflow file for this run

name: CMake Build
on:
push:
branches: [main]
pull_request:
branches: [main]
workflow_dispatch:
inputs:
cmake_flags:
description: Extra flags to pass to CMake
required: false
default: ''
ctest_flags:
description: Extra flags to pass to CTest
required: false
default: ''
make_flags:
description: Extra flags to pass to make
required: false
default: ''
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
env:
# Customize the CMake build type here (Release, Debug, RelWithDebInfo, etc.)
BUILD_TYPE: RelWithDebInfo
INSTALL_PREFIX: /tmp/libasdf
jobs:
build_matrix:
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-14]
gcc: [12, 14]
cmake_options: ["", "-DENABLE_ASAN=ON"]
exclude:
- os: macos-14
cmake_options: "-DENABLE_ASAN=ON"
- os: macos-14
gcc: 14
- os: ubuntu-latest
gcc: 14
runs-on: ${{ matrix.os }}
steps:
- name: Checkout code
uses: actions/checkout@v3
with:
submodules: true
- name: Linux dependencies
if: startsWith(matrix.os, 'ubuntu')
run: |
sudo apt update
sudo apt install -y \
build-essential \
libfyaml-dev
- name: MacOS dependencies
if: startsWith(matrix.os, 'macos')
run: |
brew update
brew install \
gcc@${{ matrix.gcc }} \
argp-standalone \
libfyaml
- name: Linux build
if: startsWith(matrix.os, 'ubuntu')
run: |
mkdir -p build
cd build
cmake .. \
-DCMAKE_BUILD_TYPE=${{ env.BUILD_TYPE }} \
-DCMAKE_INSTALL_PREFIX=${{ env.INSTALL_PREFIX }} \
-DENABLE_TESTING=YES \
-DENABLE_TESTING_SHELL=YES \
${{ matrix.cmake_options }} \
${{ github.event.inputs.cmake_flags }}
make ${{ github.event.inputs.make_flags }}
- name: MacOS build
if: startsWith(matrix.os, 'macos')
env:
CC: gcc-${{ matrix.gcc }}
CXX: g++-${{ matrix.gcc }}
FC: gfortran-${{ matrix.gcc }}
PKG_CONFIG_PATH: /opt/homebrew/lib/pkgconfig:/usr/local/lib/pkgconfig
run: |
mkdir -p build
cd build
export SDKROOT="$(xcrun --show-sdk-path)"
hbroot=/opt/homebrew
cmake .. \
-DCMAKE_BUILD_TYPE=${{ env.BUILD_TYPE }} \
-DCMAKE_INSTALL_PREFIX=${{ env.INSTALL_PREFIX }} \
-DENABLE_TESTING=YES \
-DENABLE_TESTING_SHELL=YES \
-DARGP_NO_PKGCONFIG=YES \
-DARGP_LIBDIR=${hbroot}/lib \
-DARGP_INCLUDEDIR=${hbroot}/include \
${{ matrix.cmake_options }} \
${{ github.event.inputs.cmake_flags }}
make ${{ github.event.inputs.make_flags }}
- name: Install
run: |
cd build
make install
- name: Generate source archive
run: |
cd build
make package_source
- name: Generate binary archives
run: |
cd build
make package
- name: Test
working-directory: ${{github.workspace}}/build
# Execute tests defined by the CMake configuration.
# See https://cmake.org/cmake/help/latest/manual/ctest.1.html for more detail
run: |
ctest -C ${{env.BUILD_TYPE}} \
${{ github.event.inputs.ctest_flags }}
- name: Output test logs on failure
if: failure()
working-directory: ${{github.workspace}}/build
run: |
logfile=Testing/Temporary/LastTest.log
if ! [ -f "$logfile" ]; then
echo "No log file. Did the tests run at all?"
exit 0
fi
cat "$logfile"
# Test the documentation build if the build passes
docs:
name: 'Build documentation'
runs-on: ubuntu-latest
needs: build_matrix
steps:
- name: Checkout code
uses: actions/checkout@v3
with:
submodules: true
- name: Install documentation dependencies
run: |
sudo apt-get update
sudo apt-get install -y \
build-essential \
libclang-dev \
libfyaml-dev \
llvm \
python3-sphinx \
python3-clang
# Don't use docs/requirements.txt here since we are trying with the
# system packages for sphinx and clang
pip install furo hawkmoth
- name: Set LD_LIBRARY_PATH
run: echo "LD_LIBRARY_PATH=$(llvm-config --libdir):$LD_LIBRARY_PATH" >> $GITHUB_ENV
- name: Configure
run: |
mkdir -p build
cd build
cmake .. \
-DCMAKE_BUILD_TYPE=${{ env.BUILD_TYPE }} \
-DCMAKE_INSTALL_PREFIX=${{ env.INSTALL_PREFIX }} \
-DENABLE_DOCS=YES \
${{ matrix.cmake_options }} \
${{ github.event.inputs.cmake_flags }}
- name: Build Sphinx documentation
run: |
cd build
make docs SPHINX_FLAGS=-W
- name: Install Sphinx documentation
run: |
cd build
make install