name: "Linux gcc9 Build"
on:
  push:
    branches: [ v1.x ]
  pull_request:
    # branches: [ master ]

jobs:
  build_libmatroska:
    name: libmatroska for Linux gcc10
    runs-on: ubuntu-22.04
    env:
      CMAKE_MATROSKA_OPTIONS: -DBUILD_EXAMPLES=ON
      CC:  gcc-10
      CXX: g++-10
    steps:
      - name: list compilers
        run: dpkg --list | grep compiler

      - name: Get pushed code
        uses: actions/checkout@v7

      - name: Checkout libebml
        uses: actions/checkout@v7
        with:
          repository: Matroska-Org/libebml
          path: libebml
          ref: v1.x

      - name: Configure libebml
        run: cmake -S libebml -B libebml/_build

      - name: Build libebml
        run: cmake --build libebml/_build --parallel

      - name: Install libebml
        run: cmake --install libebml/_build --prefix ${GITHUB_WORKSPACE}/_built

      - name: Configure CMake
        run: cmake -S . -B _build ${{ env.CMAKE_MATROSKA_OPTIONS }} -DEBML_DIR="${GITHUB_WORKSPACE}/_built/lib/cmake/EBML"

      - name: Build with CMake
        run: cmake --build _build --parallel

      - name: Test installation
        run: cmake --install _build --prefix ${GITHUB_WORKSPACE}/_built
