Skip to content

Commit 7ca0c08

Browse files
committed
fix mingw
1 parent 31c1cce commit 7ca0c08

File tree

1 file changed

+55
-61
lines changed

1 file changed

+55
-61
lines changed
Lines changed: 55 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -1,93 +1,87 @@
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
31
name: CMake on multiple platforms
42

53
on:
64
push:
7-
branches: [ "master"]
5+
branches: [ "master" ]
86
pull_request:
9-
branches: [ "master"]
7+
branches: [ "master" ]
108

119
jobs:
1210
build:
1311
runs-on: ${{ matrix.os }}
1412

1513
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.
1714
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.
2515
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+
2925
include:
3026
- os: windows-latest
3127
c_compiler: cl
3228
cpp_compiler: cl
29+
exe_suffix: .exe
30+
3331
- os: ubuntu-latest
3432
c_compiler: gcc
3533
cpp_compiler: g++
34+
3635
- os: ubuntu-latest
3736
c_compiler: clang
3837
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+
3945
exclude:
4046
- os: windows-latest
4147
c_compiler: gcc
4248
- os: windows-latest
4349
c_compiler: clang
50+
- os: windows-latest
51+
c_compiler: x86_64-w64-mingw32-gcc
4452
- os: ubuntu-latest
4553
c_compiler: cl
46-
- os: windows-latest
47-
c_compiler: mingw
4854

4955
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

Comments
 (0)