mirror of
https://github.com/threeal/cmake-action.git
synced 2025-06-08 18:21:20 +00:00
commit
8580c9d7bf
14
.github/workflows/test.yml
vendored
14
.github/workflows/test.yml
vendored
@ -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
|
||||
|
18
action.yml
18
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 }}
|
||||
|
@ -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)
|
||||
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)
|
||||
|
Loading…
Reference in New Issue
Block a user