|
1 | | -# This starter workflow is for a CMake project running on multiple platforms. There is a different starter workflow if you just want a single platform. |
2 | | -# See: https://github.com/actions/starter-workflows/blob/main/ci/cmake-single-platform.yml |
3 | 1 | name: CMake on multiple platforms |
4 | 2 |
|
5 | 3 | on: |
6 | 4 | push: |
7 | | - branches: [ "master"] |
| 5 | + branches: [ "master" ] |
8 | 6 | pull_request: |
9 | | - branches: [ "master"] |
| 7 | + branches: [ "master" ] |
10 | 8 |
|
11 | 9 | jobs: |
12 | 10 | build: |
13 | 11 | runs-on: ${{ matrix.os }} |
14 | 12 |
|
15 | 13 | strategy: |
16 | | - # 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. |
17 | 14 | fail-fast: true |
18 | | - |
19 | | - # Set up a matrix to run the following 3 configurations: |
20 | | - # 1. <Windows, Release, latest MSVC compiler toolchain on the default runner image, default generator> |
21 | | - # 2. <Linux, Release, latest GCC compiler toolchain on the default runner image, default generator> |
22 | | - # 3. <Linux, Release, latest Clang compiler toolchain on the default runner image, default generator> |
23 | | - # |
24 | | - # To add more build types (Release, Debug, RelWithDebInfo, etc.) customize the build_type list. |
25 | 15 | matrix: |
26 | | - os: [windows-latest, ubuntu-latest] |
27 | | - build_type: [Release] |
28 | | - c_compiler: [gcc, clang, cl, mingw] |
| 16 | + os: [ubuntu-latest, windows-latest] |
| 17 | + build_type: [Release, Debug] |
| 18 | + c_compiler: [gcc, clang, cl, x86_64-w64-mingw32-gcc] |
| 19 | + |
| 20 | + # Defaults applied to all |
| 21 | + defaults: |
| 22 | + mingw: false |
| 23 | + exe_suffix: "" |
| 24 | + |
29 | 25 | include: |
30 | 26 | - os: windows-latest |
31 | 27 | c_compiler: cl |
32 | 28 | cpp_compiler: cl |
| 29 | + exe_suffix: .exe |
| 30 | + |
33 | 31 | - os: ubuntu-latest |
34 | 32 | c_compiler: gcc |
35 | 33 | cpp_compiler: g++ |
| 34 | + |
36 | 35 | - os: ubuntu-latest |
37 | 36 | c_compiler: clang |
38 | 37 | cpp_compiler: clang++ |
| 38 | + |
| 39 | + - os: ubuntu-latest |
| 40 | + c_compiler: x86_64-w64-mingw32-gcc |
| 41 | + cpp_compiler: x86_64-w64-mingw32-g++ |
| 42 | + mingw: true |
| 43 | + exe_suffix: .exe |
| 44 | + |
39 | 45 | exclude: |
40 | 46 | - os: windows-latest |
41 | 47 | c_compiler: gcc |
42 | 48 | - os: windows-latest |
43 | 49 | c_compiler: clang |
| 50 | + - os: windows-latest |
| 51 | + c_compiler: x86_64-w64-mingw32-gcc |
44 | 52 | - os: ubuntu-latest |
45 | 53 | c_compiler: cl |
46 | | - - os: windows-latest |
47 | | - c_compiler: mingw |
48 | 54 |
|
49 | 55 | steps: |
50 | | - - uses: actions/checkout@v3 |
51 | | - |
52 | | - - name: Git update submodules |
53 | | - run: | |
54 | | - git submodule update --init --recursive --depth 1 |
55 | | -
|
56 | | - - name: Set reusable strings |
57 | | - # Turn repeated input strings (such as the build output directory) into step outputs. These step outputs can be used throughout the workflow file. |
58 | | - id: strings |
59 | | - shell: bash |
60 | | - run: | |
61 | | - echo "build-output-dir=${{ github.workspace }}/build" >> "$GITHUB_OUTPUT" |
62 | | -
|
63 | | - - name: Configure CMake |
64 | | - # Configure CMake in a 'build' subdirectory. `CMAKE_BUILD_TYPE` is only required if you are using a single-configuration generator such as make. |
65 | | - # See https://cmake.org/cmake/help/latest/variable/CMAKE_BUILD_TYPE.html?highlight=cmake_build_type |
66 | | - run: > |
67 | | - cmake -B ${{ steps.strings.outputs.build-output-dir }} |
68 | | - -DCMAKE_CXX_COMPILER=${{ matrix.cpp_compiler }} |
69 | | - -DCMAKE_C_COMPILER=${{ matrix.c_compiler }} |
70 | | - -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} |
71 | | - -S ${{ github.workspace }} |
72 | | -
|
73 | | - - name: Build |
74 | | - # 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). |
75 | | - run: cmake --build ${{ steps.strings.outputs.build-output-dir }} --config ${{ matrix.build_type }} |
76 | | - |
77 | | - - name: Test windows |
78 | | - working-directory: ${{ steps.strings.outputs.build-output-dir }}/Example/Release |
79 | | - if: matrix.os == 'windows-latest' |
80 | | - run: | |
81 | | - ./ImageLoaderExample.exe |
82 | | -
|
83 | | - - name: Test Ubuntu |
84 | | - working-directory: ${{ steps.strings.outputs.build-output-dir }}/Example |
85 | | - if: matrix.os == 'ubuntu-latest' |
86 | | - run: | |
87 | | - ./ImageLoaderExample |
88 | | -
|
89 | | - - name: Test Ubuntu (mingw) |
90 | | - working-directory: ${{ steps.strings.outputs.build-output-dir }}/Example |
91 | | - if: matrix.os == 'ubuntu-latest' |
92 | | - run: | |
93 | | - ./ImageLoaderExample.exe |
| 56 | + - uses: actions/checkout@v3 |
| 57 | + |
| 58 | + - name: Install MinGW (only if mingw is true) |
| 59 | + if: matrix.mingw == true |
| 60 | + run: | |
| 61 | + sudo apt-get update |
| 62 | + sudo apt-get install -y mingw-w64 |
| 63 | +
|
| 64 | + - name: Update submodules |
| 65 | + run: git submodule update --init --recursive --depth 1 |
| 66 | + |
| 67 | + - name: Set build directory |
| 68 | + id: vars |
| 69 | + run: echo "dir=${{ github.workspace }}/build" >> "$GITHUB_OUTPUT" |
| 70 | + |
| 71 | + - name: Configure CMake |
| 72 | + run: > |
| 73 | + cmake -S . -B ${{ steps.vars.outputs.dir }} |
| 74 | + -DCMAKE_C_COMPILER=${{ matrix.c_compiler }} |
| 75 | + -DCMAKE_CXX_COMPILER=${{ matrix.cpp_compiler }} |
| 76 | + -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} |
| 77 | + ${{ matrix.mingw && '-DCMAKE_TOOLCHAIN_FILE=mingw-w64-x86_64.cmake' || '' }} |
| 78 | +
|
| 79 | + - name: Build |
| 80 | + run: cmake --build ${{ steps.vars.outputs.dir }} --config ${{ matrix.build_type }} |
| 81 | + |
| 82 | + - name: Run tests |
| 83 | + working-directory: >- |
| 84 | + ${{ steps.vars.outputs.dir }}/Example${{ |
| 85 | + matrix.os == 'windows-latest' && format('/{0}', matrix.build_type) || '' |
| 86 | + }} |
| 87 | + run: ./ImageLoaderExample${{ matrix.exe_suffix }} |
0 commit comments