Skip to content

Commit

Permalink
Create cmake-multi-platform.yml
Browse files Browse the repository at this point in the history
  • Loading branch information
djowel authored Nov 25, 2023
1 parent 44dcea2 commit f47bdb3
Showing 1 changed file with 83 additions and 0 deletions.
83 changes: 83 additions & 0 deletions .github/workflows/cmake-multi-platform.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
name: Build and Test

on: [push, pull_request]

jobs:
build:
runs-on: ${{ matrix.os }}

strategy:
# Set fail-fast to false to ensure that feedback is delivered for all matrix combinations. Consider changing this to true when your workflow is stable.
fail-fast: false

# Set up a matrix
matrix:
os: [ubuntu-latest, windows-latest]
build_type: [Release]
c_compiler: [gcc, clang, cl]
include:
- os: windows-latest
c_compiler: cl
cpp_compiler: cl
environment_script: "C:/Program Files/Microsoft Visual Studio/2022/Enterprise/VC/Auxiliary/Build/vcvars64.bat"
- os: ubuntu-latest
c_compiler: gcc
cpp_compiler: g++
- os: ubuntu-latest
c_compiler: clang
cpp_compiler: clang++
- os: macos-latest
c_compiler: "clang"
cpp_compiler: "clang++"
exclude:
- os: windows-latest
c_compiler: gcc
- os: windows-latest
c_compiler: clang
- os: ubuntu-latest
c_compiler: cl
- os: macos-latest
c_compiler: cl
c_compiler: g++

steps:
- uses: actions/checkout@v3
with:
submodules: 'recursive'

- name: Install package dependencies
id: cmake_and_ninja
shell: cmake -P {0}
run: |
if ("${{ runner.os }}" STREQUAL "Windows")
execute_process(COMMAND choco install ninja)
elseif ("${{ runner.os }}" STREQUAL "Linux")
execute_process(COMMAND sudo apt-get update)
execute_process(COMMAND sudo apt-get install libharfbuzz-dev)
execute_process(COMMAND sudo apt-get install libunibreak-dev)
execute_process(COMMAND sudo apt-get install fontconfig)
execute_process(COMMAND sudo apt-get install libgtkglext1-dev)
execute_process(COMMAND sudo apt-get install libgtk-3-devv)
elseif ("${{ runner.os }}" STREQUAL "macOS")
execute_process(COMMAND brew install fontconfig)
endif()
- name: Configure CMake
# Configure CMake in a 'build' subdirectory. `CMAKE_BUILD_TYPE` is only required if you are using a single-configuration generator such as make.
# See https://cmake.org/cmake/help/latest/variable/CMAKE_BUILD_TYPE.html?highlight=cmake_build_type
run: >
cmake -B ${{ steps.strings.outputs.build-output-dir }}
-DCMAKE_CXX_COMPILER=${{ matrix.cpp_compiler }}
-DCMAKE_C_COMPILER=${{ matrix.c_compiler }}
-DCMAKE_BUILD_TYPE=${{ matrix.build_type }}
-S ${{ github.workspace }}
- name: Build
# Build your program with the given configuration. Note that --config is needed because the default Windows generator is a multi-config generator (Visual Studio generator).
run: cmake --build ${{ steps.strings.outputs.build-output-dir }} --config ${{ matrix.build_type }}

- name: Test
working-directory: ${{ steps.strings.outputs.build-output-dir }}
# Execute tests defined by the CMake configuration. Note that --build-config is needed because the default Windows generator is a multi-config generator (Visual Studio generator).
# See https://cmake.org/cmake/help/latest/manual/ctest.1.html for more detail
run: ctest --build-config ${{ matrix.build_type }}

0 comments on commit f47bdb3

Please sign in to comment.