name: FreeBSD CMake

on:
  push:
    branches: main
    tags-ignore: '*.*'
    paths:
      - '.github/workflows/cmake-freebsd.yml'
      - 'CMakeLists.txt'
      - 'cmake/**'
      - 'include/**'
      - 'src/*pp'
      - 'src/freebsd/*pp'
  pull_request:
    branches: main
    paths:
      - '.github/workflows/cmake-freebsd.yml'
      - 'CMakeLists.txt'
      - 'cmake/**'
      - 'include/**'
      - 'src/*pp'
      - 'src/freebsd/*pp'

jobs:
  build:
    name: freebsd-${{ matrix.version}}-${{ matrix.arch}}
    runs-on: ubuntu-24.04
    concurrency:
      group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}-${{ matrix.arch }}-${{ matrix.version }}
      cancel-in-progress: true
    strategy:
      matrix:
        arch: ['aarch64', 'x86_64']
        version: ['14.2', '15.0']
    steps:
      - uses: actions/checkout@v4

      - name: Compile
        uses: vmactions/freebsd-vm@v1
        with:
          arch: ${{ matrix.arch }}
          release: ${{ matrix.version }}
          usesh: true
          prepare: pkg install -y cmake ninja lowdown
          run: |
            CXX=clang++ cmake -B build -G Ninja -DBTOP_STATIC=ON
            cmake --build build --verbose
