From 250f59da815a35529395041f2b62adf129cb4e81 Mon Sep 17 00:00:00 2001 From: Alfi Maulana Date: Tue, 17 Jan 2023 12:46:36 +0700 Subject: [PATCH] run `additional-flags-usage` job on both GCC and MSVC --- .github/workflows/test.yml | 9 ++++++--- test/CMakeLists.txt | 9 +++++++-- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 5fa73b6..0a1ddd0 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -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 diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 434f472..1f6ccca 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -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)