name: "VcpkgDeps"

# Test that a default build when using vcpkg

on:
  workflow_dispatch:
  pull_request:
  push:


jobs:
  build:
    name: VcpkgDeps
    runs-on: ${{ matrix.config.os }}
    strategy:
      fail-fast: false
      matrix:
        config:
          - os: ubuntu-latest
            vcpkg_triplet: x64-linux-release
          - os: macos-latest
            vcpkg_triplet: x64-osx-release
          - os: windows-latest
            vcpkg_triplet: x64-windows-release


    steps:
      - uses: actions/checkout@v4
        with:
          submodules: true

      - name: install glfw & sdl requirements
        if : ${{ matrix.config.os == 'ubuntu-latest' }}
        shell: bash
        run: |
          sudo apt-get update && sudo apt-get install -y libxinerama-dev libxcursor-dev xorg-dev libglu1-mesa-dev pkg-config libx11-dev libxft-dev libxext-dev

      - name: vcpkg install
        uses: johnwason/vcpkg-action@v6
        id: vcpkg
        with:
          triplet: ${{ matrix.config.vcpkg_triplet }}
          cache-key: ${{ matrix.config.os }}
          revision: master
          token: ${{ github.token }}
          github-binarycache: true

#      - name: Setup interactive tmate session
#        uses: mxschmitt/action-tmate@v3

      - name: Build and install
        shell: bash
        # This will read the dependencies from the vcpkg.json file,
        # and the CMake preset from CMakePresets.json
        run: |
          export VCPKG_ROOT=$(pwd)/vcpkg
          mkdir build
          cd build
          cmake .. --preset build_vcpkg_default -DCMAKE_BUILD_TYPE=Release
          cmake --build . -j 3
