Does GitHub Actions override my compilation options?

When I added -Wall -Wextra -pedantic -Werror compile options for GCC and /W4 /WX on my project obviously my code didn’t work anymore and I need to fix all the warnings but before to fixed them I pushed just the modification on CMakeList.txt the GitHub Actions of my project passed with GCC and MSVC.
Weird ? I check several time… right branch, right workflow, all seems right.
Does GitHub Actions override my compilation options ?

It really shouldn’t, but could you share how the options are set and a workflow log? Maybe there is some odd twist. :slightly_smiling_face:

1 Like

Thanks for your answer. I just discovered that my ‘windows’ run on Microsoft Windows Server 2019 but compile with GNU 8.1.0. How is it possible ? GNU is only Linux compiler, no ?
This is my workflow:

unit_tests.yml

name: Unit tests Linux/Windows

on: [push]

jobs:
  unit-tests:
    name: Build and run unit tests
    runs-on: ${{ matrix.os }}
    strategy:
      matrix:
        os: [ubuntu-latest, windows-latest]

    steps:
    - name: Checkout
      uses: actions/checkout@v2
    - name: CMake
      run: |
        cd ./build
        cmake -G"Unix Makefiles" ./..
    - name: Make
      run: |
        cd ./build
        make
    - name: Execute unit tests
      run: |
        cd ./build
        ./tests/unit_tests/UnitTests.out --gtest_also_run_disabled_tests

How can I change my workflow to compile with MSVC on Windows and with GCC on Linux ?

GCC is available for many platforms, including Windows. Using it would explain why MSVC compiler options are ignored. :slightly_smiling_face: Or does the Linux build seem to ignore the options, too?

Your workflow doesn’t seem to explicitly configure a specific compiler, so I assume you should check how to configure a preference in CMake.

1 Like

Thanks for information. Do I need to configure a preference in CMake or just configure the compiler in the workflow ? I will check it soon as possible.
Also for compile GCC on windows GitHub must use something like MinGW or Cywin ?

I’m not sure about CMake specifically, but a common thing on Linux is to set the C compiler via the CC environment variable, so setting that in the CMake run might be worth a try.

The current version of the windows-2019 environment description lists Mingw-w64, so I assume that’s what it is. :wink:

1 Like