I have a C++ project on GitHub with which I use GitHub CI. My workflow is configured to run on Linux and Windows through the strategy
property:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, windows-latest]
This has worked well for me so far, with Cmake identifying the compiler as GNU 9.3.0
. However, I would now like to use an experimental feature added in GCC 10 in my project, and so my build fails due to the old compiler version.
How can I use a more recent version of GCC from my GitHub CI workflow?
For the linux build you can use the following build step to switch the default gcc to gcc-10.
The first 2 lines in the script should be optional, as gcc-10 is already installed in ubuntu-latest. But it doesn't hurt much to have them there and it might help to make clear what is happening and how to reproduce the build locally. You can check the manpage for update-alternatives if you are interested how this works.
windows-latest uses visual-studio as it's default compiler, but since you only asked about gcc I suppose that it already supports the c++ features you are using?