use clang-cl for Windows (instead of clang) #7
This file contains hidden or 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
name: CI | |
on: | |
pull_request: | |
branches: | |
- master | |
types: [opened, synchronize, labeled] | |
push: | |
branches: | |
- master | |
jobs: | |
clang-format: | |
name: Check clang-format | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Install clang-format | |
run: sudo apt-get update && sudo apt-get install -y clang-format | |
- name: Check formatting | |
run: | | |
git fetch --depth=1 origin master | |
clang-format -style=file -output-replacements-xml $(git ls-files '*.cpp' '*.h' '*.ixx' '*.hpp') | grep "<replacement " && echo "Code is not properly formatted" && exit 1 || echo "All good" | |
build: | |
name: Build project | |
runs-on: ${{ matrix.os }} | |
if: github.event_name == 'push' || (github.event_name == 'pull_request' && contains(github.event.pull_request.labels.*.name, 'run-ci')) | |
strategy: | |
matrix: | |
include: | |
- os: windows-latest | |
compiler: msvc | |
- os: windows-latest | |
compiler: clang | |
- os: ubuntu-latest | |
compiler: clang | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Setup CMake | |
uses: jwlawson/actions-setup-cmake@v2 | |
with: | |
cmake-version: '3.29.0' | |
- name: Install compiler on Ubuntu | |
if: matrix.os == 'ubuntu-latest' | |
run: | | |
sudo apt-get update | |
if [ "${{ matrix.compiler }}" == "clang" ]; then | |
sudo apt-get install -y clang | |
fi | |
shell: bash | |
- name: Configure CMake | |
run: | | |
mkdir build | |
cd build | |
if [ "${{ matrix.os }}" == "ubuntu-latest" ]; then | |
if [ "${{ matrix.compiler }}" == "clang" ]; then | |
cmake -G Ninja -DCMAKE_CXX_COMPILER=clang++ .. | |
fi | |
elif [ "${{ matrix.os }}" == "windows-latest" ]; then | |
if [ "${{ matrix.compiler }}" == "msvc" ]; then | |
# Force the real MSVC toolset (cl.exe) | |
cmake -G "Visual Studio 17 2022" -A x64 .. | |
elif [ "${{ matrix.compiler }}" == "clang" ]; then | |
# Explicit clang-cl on Windows | |
cmake -G Ninja -DCMAKE_CXX_COMPILER=clang-cl .. | |
fi | |
fi | |
shell: bash | |
- name: Build | |
run: | | |
if [ "${{ matrix.os }}" == "windows-latest" ] && [ "${{ matrix.compiler }}" == "msvc" ]; then | |
cmake --build build --config Release | |
else | |
cmake --build build --config Release | |
fi | |
shell: bash |