---
runs:
  using: composite
  steps:
    - name: Create `cmake` symbolic link
      run: |
        if ! command -v cmake &> /dev/null && command -v cmake3 &> /dev/null; then
          ln --symbolic cmake3 /usr/bin/cmake
        fi
      shell: bash --noprofile --norc -euxo pipefail {0}

    - name: Prepare `build` directory
      run: |
        cmake -B build -S . \
          -LA \
          -DCMAKE_BUILD_TYPE:STRING=${BUILD_TYPE:-Release} \
          -DCMAKE_INSTALL_PREFIX:PATH=${INSTALL_PREFIX:-/usr/local} \
          -DENABLE_TESTS:BOOL=ON
      shell: bash --noprofile --norc -euxo pipefail {0}

    - name: Build `mod_tile`
      run: |
        export CMAKE_BUILD_PARALLEL_LEVEL=${BUILD_PARALLEL_LEVEL:-$(nproc)}
        cmake --build build
      shell: bash --noprofile --norc -euxo pipefail {0}
