Skip to content

Enhance CMake build process for Clang by specifying individual targets #6

Enhance CMake build process for Clang by specifying individual targets

Enhance CMake build process for Clang by specifying individual targets #6

Workflow file for this run

name: Build Matrix
on:
push:
branches: [ main, develop ]
pull_request:
branches: [ main, develop ]
jobs:
build:
name: Build on ${{ matrix.os }} with ${{ matrix.compiler }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest]
compiler: [gcc, clang]
build_type: [Release, Debug]
exclude:
# Skip some combinations to save CI time
- os: macos-latest
build_type: Debug
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Install dependencies (Ubuntu)
if: runner.os == 'Linux'
run: |
sudo apt-get update
sudo apt-get install -y cmake build-essential clang
- name: Install dependencies (macOS)
if: runner.os == 'macOS'
run: |
brew install cmake
- name: Configure build
env:
CC: ${{ matrix.compiler }}
CXX: ${{ matrix.compiler == 'gcc' && 'g++' || 'clang++' }}
run: |
mkdir -p build
cd build
EXTRA_FLAGS=""
if [ "${{ matrix.compiler }}" = "clang" ]; then
EXTRA_FLAGS="-DCMAKE_CXX_FLAGS=-fpermissive -Wno-writable-strings -Wno-pointer-arith"
fi
cmake -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} $EXTRA_FLAGS ..
- name: Build
run: |
cd build
if [ "${{ matrix.compiler }}" = "clang" ]; then
cmake --build . --target libcsv --parallel --config ${{ matrix.build_type }}
cmake --build . --target csvcpp --parallel --config ${{ matrix.build_type }}
cmake --build . --target csvtest --parallel --config ${{ matrix.build_type }}
cmake --build . --target csvinfo --parallel --config ${{ matrix.build_type }}
cmake --build . --target csvfix --parallel --config ${{ matrix.build_type }}
cmake --build . --target csvvalid --parallel --config ${{ matrix.build_type }}
else
cmake --build . --parallel --config ${{ matrix.build_type }}
fi
- name: Run tests
if: ${{ matrix.compiler != 'clang' }}
run: |
cd build
cmake --build . --target test_parity --parallel
./tests/test_parity
- name: Build examples
run: |
cd build
cmake --build . --target csvtest --parallel
cmake --build . --target csvinfo --parallel
cmake --build . --target csvfix --parallel
cmake --build . --target csvvalid --parallel
summary:
name: Build Summary
runs-on: ubuntu-latest
needs: build
if: always()
steps:
- name: ✅ Build Matrix Successful
if: ${{ needs.build.result == 'success' }}
run: echo "All builds passed on all platforms!"
- name: ❌ Build Matrix Failed
if: ${{ needs.build.result == 'failure' }}
run: exit 1