diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index e51b54a..442a728 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,11 +53,14 @@ 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 /WX-' || '-Wno-unused-variable' }} + cxx-flags: ${{ matrix.compiler == 'msvc' && '/w /WX-' || '-Wno-unused-variable' }} + args: -D CHECK_SURPASS_WARNING=ON - name: Run the build results - run: build/test_c && build/test_cpp + run: | + ${{ matrix.compiler == 'msvc' && 'build\Debug\test_c.exe' || 'build/test_c' }} + ${{ matrix.compiler == 'msvc' && 'build\Debug\test_cpp.exe' || 'build/test_cpp' }} specified-compiler-usage: runs-on: ${{ matrix.os }}-latest diff --git a/action.yml b/action.yml index 97eff0d..af61157 100644 --- a/action.yml +++ b/action.yml @@ -41,25 +41,25 @@ runs: id: process_inputs shell: bash run: | - ARGS="${{ inputs.source-dir }} -B ${{ inputs.build-dir }}" - BUILD_ARGS="--build ${{ inputs.build-dir }}" + ARGS="'${{ inputs.source-dir }}' -B '${{ inputs.build-dir }}'" + BUILD_ARGS="--build '${{ inputs.build-dir }}'" if [ -n '${{ inputs.targets }}' ]; then BUILD_ARGS="$BUILD_ARGS --target ${{ inputs.targets }}" fi if [ -n '${{ inputs.generator }}' ]; then - ARGS="$ARGS -G ${{ inputs.generator }}" + ARGS="$ARGS -G '${{ inputs.generator }}'" fi if [ -n '${{ inputs.c-compiler }}' ]; then - ARGS="$ARGS -D CMAKE_C_COMPILER=${{ inputs.c-compiler }}" + ARGS="$ARGS -D CMAKE_C_COMPILER='${{ inputs.c-compiler }}'" fi if [ -n '${{ inputs.cxx-compiler }}' ]; then - ARGS="$ARGS -D CMAKE_CXX_COMPILER=${{ inputs.cxx-compiler }}" + ARGS="$ARGS -D CMAKE_CXX_COMPILER='${{ inputs.cxx-compiler }}'" fi if [ -n '${{ inputs.c-flags }}' ]; then - ARGS="$ARGS -D CMAKE_C_FLAGS=${{ inputs.c-flags }}" + ARGS="$ARGS -D CMAKE_C_FLAGS='${{ inputs.c-flags }}'" fi if [ -n '${{ inputs.cxx-flags }}' ]; then - ARGS="$ARGS -D CMAKE_CXX_FLAGS=${{ inputs.cxx-flags }}" + ARGS="$ARGS -D CMAKE_CXX_FLAGS='${{ inputs.cxx-flags }}'" fi if [ -n '${{ inputs.args }}' ]; then ARGS="$ARGS ${{ inputs.args }}" @@ -78,9 +78,9 @@ runs: esac - name: Configure the CMake project - shell: bash + shell: ${{ runner.os == 'Windows' && 'pwsh' || 'bash' }} run: cmake ${{ steps.process_inputs.outputs.cmake_args }} - name: Build targets - shell: bash + shell: ${{ runner.os == 'Windows' && 'pwsh' || 'bash' }} run: cmake ${{ steps.process_inputs.outputs.cmake_build_args }} 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)