mirror of
				https://github.com/threeal/cmake-action.git
				synced 2025-11-03 21:33:42 +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
 | 
					        run: test ! -d build
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  additional-flags-usage:
 | 
					  additional-flags-usage:
 | 
				
			||||||
    runs-on: ubuntu-latest
 | 
					    runs-on: ${{ matrix.compiler == 'msvc' && 'windows' || 'ubuntu' }}-latest
 | 
				
			||||||
 | 
					    strategy:
 | 
				
			||||||
 | 
					      matrix:
 | 
				
			||||||
 | 
					        compiler: [gcc, msvc]
 | 
				
			||||||
    steps:
 | 
					    steps:
 | 
				
			||||||
      - name: Check out this repository
 | 
					      - name: Check out this repository
 | 
				
			||||||
        uses: actions/checkout@v3.3.0
 | 
					        uses: actions/checkout@v3.3.0
 | 
				
			||||||
@ -50,11 +53,14 @@ jobs:
 | 
				
			|||||||
        with:
 | 
					        with:
 | 
				
			||||||
          source-dir: test
 | 
					          source-dir: test
 | 
				
			||||||
          targets: test_c test_cpp
 | 
					          targets: test_c test_cpp
 | 
				
			||||||
          c-flags: -Wno-unused-variable
 | 
					          c-flags: ${{ matrix.compiler == 'msvc' && '/w /WX-' || '-Wno-unused-variable' }}
 | 
				
			||||||
          cxx-flags: -Wno-unused-variable
 | 
					          cxx-flags: ${{ matrix.compiler == 'msvc' && '/w /WX-' || '-Wno-unused-variable' }}
 | 
				
			||||||
 | 
					          args: -D CHECK_SURPASS_WARNING=ON
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      - name: Run the build results
 | 
					      - 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:
 | 
					  specified-compiler-usage:
 | 
				
			||||||
    runs-on: ${{ matrix.os }}-latest
 | 
					    runs-on: ${{ matrix.os }}-latest
 | 
				
			||||||
 | 
				
			|||||||
							
								
								
									
										18
									
								
								action.yml
									
									
									
									
									
								
							
							
						
						
									
										18
									
								
								action.yml
									
									
									
									
									
								
							@ -41,25 +41,25 @@ runs:
 | 
				
			|||||||
      id: process_inputs
 | 
					      id: process_inputs
 | 
				
			||||||
      shell: bash
 | 
					      shell: bash
 | 
				
			||||||
      run: |
 | 
					      run: |
 | 
				
			||||||
        ARGS="${{ inputs.source-dir }} -B ${{ inputs.build-dir }}"
 | 
					        ARGS="'${{ inputs.source-dir }}' -B '${{ inputs.build-dir }}'"
 | 
				
			||||||
        BUILD_ARGS="--build ${{ inputs.build-dir }}"
 | 
					        BUILD_ARGS="--build '${{ inputs.build-dir }}'"
 | 
				
			||||||
        if [ -n '${{ inputs.targets }}' ]; then
 | 
					        if [ -n '${{ inputs.targets }}' ]; then
 | 
				
			||||||
          BUILD_ARGS="$BUILD_ARGS --target ${{ inputs.targets }}"
 | 
					          BUILD_ARGS="$BUILD_ARGS --target ${{ inputs.targets }}"
 | 
				
			||||||
        fi
 | 
					        fi
 | 
				
			||||||
        if [ -n '${{ inputs.generator }}' ]; then
 | 
					        if [ -n '${{ inputs.generator }}' ]; then
 | 
				
			||||||
          ARGS="$ARGS -G ${{ inputs.generator }}"
 | 
					          ARGS="$ARGS -G '${{ inputs.generator }}'"
 | 
				
			||||||
        fi
 | 
					        fi
 | 
				
			||||||
        if [ -n '${{ inputs.c-compiler }}' ]; then
 | 
					        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
 | 
					        fi
 | 
				
			||||||
        if [ -n '${{ inputs.cxx-compiler }}' ]; then
 | 
					        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
 | 
					        fi
 | 
				
			||||||
        if [ -n '${{ inputs.c-flags }}' ]; then
 | 
					        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
 | 
					        fi
 | 
				
			||||||
        if [ -n '${{ inputs.cxx-flags }}' ]; then
 | 
					        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
 | 
					        fi
 | 
				
			||||||
        if [ -n '${{ inputs.args }}' ]; then
 | 
					        if [ -n '${{ inputs.args }}' ]; then
 | 
				
			||||||
          ARGS="$ARGS ${{ inputs.args }}"
 | 
					          ARGS="$ARGS ${{ inputs.args }}"
 | 
				
			||||||
@ -78,9 +78,9 @@ runs:
 | 
				
			|||||||
        esac
 | 
					        esac
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    - name: Configure the CMake project
 | 
					    - name: Configure the CMake project
 | 
				
			||||||
      shell: bash
 | 
					      shell: ${{ runner.os == 'Windows' && 'pwsh' || 'bash' }}
 | 
				
			||||||
      run: cmake ${{ steps.process_inputs.outputs.cmake_args }}
 | 
					      run: cmake ${{ steps.process_inputs.outputs.cmake_args }}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    - name: Build targets
 | 
					    - name: Build targets
 | 
				
			||||||
      shell: bash
 | 
					      shell: ${{ runner.os == 'Windows' && 'pwsh' || 'bash' }}
 | 
				
			||||||
      run: cmake ${{ steps.process_inputs.outputs.cmake_build_args }}
 | 
					      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)
 | 
					option(CHECK_SURPASS_WARNING "check if target could surpass a compiler warning" OFF)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
if(CHECK_SURPASS_WARNING)
 | 
					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_C_FLAGS "-Werror -Wunused-variable ${CMAKE_C_FLAGS}")
 | 
				
			||||||
    set(CMAKE_CXX_FLAGS "-Werror -Wunused-variable ${CMAKE_CXX_FLAGS}")
 | 
					    set(CMAKE_CXX_FLAGS "-Werror -Wunused-variable ${CMAKE_CXX_FLAGS}")
 | 
				
			||||||
 | 
					  endif()
 | 
				
			||||||
endif()
 | 
					endif()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
add_executable(hello_world hello_world.cpp)
 | 
					add_executable(hello_world hello_world.cpp)
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
		Reference in New Issue
	
	Block a user