run additional-flags-usage job on both GCC and MSVC

This commit is contained in:
Alfi Maulana 2023-01-17 12:46:36 +07:00
parent 657a82ee9f
commit 250f59da81
No known key found for this signature in database
GPG Key ID: 2242A64C2A8DF5A4
2 changed files with 13 additions and 5 deletions

View File

@ -40,7 +40,10 @@ jobs:
run: test ! -d build
additional-flags-usage:
runs-on: ubuntu-latest
runs-on: ${{ matrix.compiler == 'msvc' && 'windows' || 'ubuntu' }}-latest
strategy:
matrix:
compiler: [gcc, msvc]
steps:
- name: Check out this repository
uses: actions/checkout@v3.3.0
@ -50,8 +53,8 @@ jobs:
with:
source-dir: test
targets: test_c test_cpp
c-flags: -Wno-unused-variable
cxx-flags: -Wno-unused-variable
c-flags: ${{ matrix.compiler == 'msvc' && '/w' || '-Wno-unused-variable' }}
cxx-flags: ${{ matrix.compiler == 'msvc' && '/w' || '-Wno-unused-variable' }}
args: -D CHECK_SURPASS_WARNING=ON
- name: Run the build results

View File

@ -5,8 +5,13 @@ option(CHECK_USING_CLANG "check if target is compiled using Clang" OFF)
option(CHECK_SURPASS_WARNING "check if target could surpass a compiler warning" OFF)
if(CHECK_SURPASS_WARNING)
set(CMAKE_C_FLAGS "-Werror -Wunused-variable ${CMAKE_C_FLAGS}")
set(CMAKE_CXX_FLAGS "-Werror -Wunused-variable ${CMAKE_CXX_FLAGS}")
if(MSVC)
set(CMAKE_C_FLAGS "/WX /W4 ${CMAKE_C_FLAGS}")
set(CMAKE_CXX_FLAGS "/WX /W4 ${CMAKE_CXX_FLAGS}")
else()
set(CMAKE_C_FLAGS "-Werror -Wunused-variable ${CMAKE_C_FLAGS}")
set(CMAKE_CXX_FLAGS "-Werror -Wunused-variable ${CMAKE_CXX_FLAGS}")
endif()
endif()
add_executable(hello_world hello_world.cpp)