Skip to content

Testing XIII

Testing XIII #25

name: CMake Cross-Platform Build
on:
push:
pull_request:
jobs:
build:
name: Build on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
steps:
- name: Checkout source
uses: actions/checkout@v2
- name: Check compiler availability
if: matrix.os == 'ubuntu-latest'
run: |
if command -v g++ >/dev/null 2>&1; then
echo "GNU C++ is available."
else
echo "GNU C++ is not available. Installing."
apt install -y build-essentials
fi
- name: Check compiler availability
if: matrix.os == 'macos-latest'
run: |
if command -v clang++ >/dev/null 2>&1; then
echo "Clang/LLVM is available."
else
echo "Clang/LLVM is not available. Install via XCode."
xcode-select --install
fi
- name: Set up MinGW for Windows
if: matrix.os == 'windows-latest'
run: |
choco install msys2 -y
echo "::add-path::C:\\tools\\msys64\\usr\\bin"
echo "::add-path::C:\\tools\\msys64\\mingw32\\bin"
- name: Create build directory
run: mkdir build
working-directory: .
- name: Run CMake on Ubuntu
run: cmake .. -DCMAKE_BUILD_TYPE=Release
working-directory: build
if: matrix.os == 'ubuntu-latest'
- name: Run CMake on macOS
run: cmake .. -DCMAKE_BUILD_TYPE=Release
working-directory: build
if: matrix.os == 'macos-latest'
- name: Run CMake on Windows
run: cmake .. -G "MinGW Makefiles" -DCMAKE_BUILD_TYPE=Release
working-directory: build
if: matrix.os == 'windows-latest'
- name: Build on Ubuntu and macOS
run: cmake --build .
working-directory: build
if: matrix.os == 'ubuntu-latest' || matrix.os == 'macos-latest'
- name: Build on Windows
run: mingw32-make
working-directory: build
if: matrix.os == 'windows-latest'