test building AdTree on Windows, Ubuntu, and macOS #1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
############################################################################## | |
# GitHub Actions Workflow to test building AdTree on Windows, Ubuntu, and macOS. | |
# | |
# Copyright (C) 2022 Liangliang Nan <[email protected]> | |
# | |
# Licensed under GNU LGPL.3, see LICENCE file | |
############################################################################## | |
name: Test Build AdTree | |
on: [push, pull_request] | |
jobs: | |
build: | |
name: "Build on ${{ matrix.platform }} with ${{ matrix.compiler }}" | |
strategy: | |
fail-fast: false | |
matrix: | |
platform: [windows-latest, ubuntu-latest, macos-latest] | |
compiler: [gcc, clang, msvc] | |
runs-on: ${{ matrix.platform }} | |
steps: | |
# Checkout the code | |
- uses: actions/checkout@v3 | |
# Install dependencies for Ubuntu | |
- name: Install Dependencies (Linux) | |
if: runner.os == 'Linux' | |
run: | | |
sudo apt-get update || true | |
sudo apt-get install -y \ | |
build-essential \ | |
${{ matrix.compiler }} \ | |
libglu1-mesa-dev mesa-common-dev \ | |
libxrandr-dev libxinerama-dev libxcursor-dev libxi-dev libboost-all-dev | |
# Install dependencies for macOS | |
- name: Install Dependencies (macOS) | |
if: runner.os == 'macOS' | |
run: | | |
brew update || true | |
brew install cmake boost | |
# Set up Miniconda on Windows | |
- name: Set up Conda (Windows) | |
if: runner.os == 'Windows' | |
uses: conda-incubator/setup-miniconda@v3 | |
with: | |
architecture: x64 | |
auto-activate-base: true | |
channels: conda-forge,defaults | |
# Install dependencies for Windows using Conda | |
- name: Install Dependencies (Windows) | |
if: runner.os == 'Windows' | |
run: | | |
conda install -y ninja boost | |
# Configure the project | |
- name: Configure (Linux & macOS) | |
if: runner.os != 'Windows' | |
run: | | |
mkdir -p build && cd build | |
cmake .. \ | |
-DCMAKE_BUILD_TYPE=Release \ | |
-DCMAKE_CXX_COMPILER=$([[ ${{ matrix.platform }} == "ubuntu-latest" ]] && echo ${{ matrix.compiler }} || echo "clang++") | |
- name: Configure (Windows) | |
if: runner.os == 'Windows' | |
run: | | |
mkdir -p build && cd build | |
cmake .. \ | |
-G "Visual Studio 17 2022" \ | |
-A x64 \ | |
-DCMAKE_BUILD_TYPE=Release | |
# Build the project | |
- name: Build (Linux & macOS) | |
if: runner.os != 'Windows' | |
run: | | |
cmake --build build -- -j$(nproc) | |
- name: Build (Windows) | |
if: runner.os == 'Windows' | |
run: cmake --build build --config Release |