[GCC|Clang] added addition compile flags. #376
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: CMake | |
# on: [push, pull_request] | |
on: | |
push: | |
branches: | |
- develop | |
paths: | |
- '**.c' | |
- '**.cmake' | |
- '**.cpp' | |
- '**.h' | |
- 'CMakeLists.txt' | |
pull_request: | |
branches: | |
- develop | |
paths: | |
- '**.c' | |
- '**.cmake' | |
- '**.cpp' | |
- '**.h' | |
- 'CMakeLists.txt' | |
jobs: | |
build: | |
name: >- | |
${{ github.ref_name }} | |
${{ matrix.os }} | |
${{ matrix.compiler }} | |
${{ matrix.optimized && 'release' || 'debug' }} | |
${{ matrix.target_platform }} | |
strategy: | |
fail-fast: false | |
matrix: | |
compiler: [clang, gcc, msvc, mingw] | |
os: [ubuntu-latest, macos-latest, windows-latest] | |
optimized: [true, false] | |
target_platform: [x64, Win32] | |
exclude: | |
- os: ubuntu-latest | |
compiler: clang | |
- os: ubuntu-latest | |
compiler: msvc | |
- os: ubuntu-latest | |
compiler: mingw | |
- os: ubuntu-latest | |
target_platform: Win32 | |
- os: macos-latest | |
compiler: gcc | |
- os: macos-latest | |
compiler: msvc | |
- os: macos-latest | |
compiler: mingw | |
- os: macos-latest | |
target_platform: Win32 | |
- os: windows-latest | |
compiler: clang | |
- os: windows-latest | |
compiler: gcc | |
- compiler: mingw | |
target_platform: Win32 | |
env: | |
CMAKE_BUILD_DIR: >- | |
${{ format( | |
startsWith(matrix.os, 'windows') && '{0}\build' || '{0}/build', | |
github.workspace) }} | |
CMAKE_GENERATOR: ${{ 'mingw' == matrix.compiler && '-G "MinGW Makefiles"' || '' }} | |
CMAKE_BUILD_TYPE: >- | |
${{ format( | |
'msvc' == matrix.compiler && '' || '-DCMAKE_BUILD_TYPE={0}', | |
(matrix.optimized && 'Release' || 'Debug')) }} | |
CMAKE_CONFIG_TYPE: ${{ matrix.optimized && 'Release' || 'Debug' }} | |
CMAKE_TARGET_PLATFORM: >- | |
${{ format( | |
'msvc' == matrix.compiler && '-A {0}' || '', | |
matrix.target_platform) }} | |
EXECUTABLE_EXTENSION: ${{ startsWith(matrix.os, 'windows') && '.exe' || '' }} | |
BINARY_PATH: >- | |
${{ format( | |
('msvc' == matrix.compiler && '{0}\build\{1}\') || | |
(startsWith(matrix.os, 'windows') && '{0}\build\' || '{0}/build/'), | |
github.workspace, | |
matrix.optimized && 'Release' || 'Debug') }} | |
LIBRARY_BINARY_DIR: >- | |
${{ format( | |
startsWith(matrix.os, 'windows') && '{0}\{1}' || '{0}/{1}', | |
github.workspace, matrix.os) }} | |
runs-on: ${{ matrix.os }} | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Fetch prebuild of third-party libraries | |
run: git fetch origin ${{ matrix.os }} | |
- name: Checkout third-party libraries | |
run: git checkout origin/${{ matrix.os }} -- . | |
- name: Create project files | |
run: >- | |
cmake | |
${{ env.CMAKE_TARGET_PLATFORM }} | |
${{ env.CMAKE_GENERATOR }} | |
${{ env.CMAKE_BUILD_TYPE }} | |
-S ${{ github.workspace }} | |
-B ${{ env.CMAKE_BUILD_DIR }} | |
-DLIBRARY_BINARY_DIR=${{ env.LIBRARY_BINARY_DIR }} | |
-DPROGRAM_VERSION="${{ github.event.repository.updated_at }}" | |
- name: Get number of CPU cores | |
uses: SimenB/github-actions-cpu-cores@v2 | |
id: cpu-cores | |
- name: Build | |
run: >- | |
cmake | |
--build ${{ env.CMAKE_BUILD_DIR }} | |
--config ${{ env.CMAKE_CONFIG_TYPE }} | |
--parallel ${{ steps.cpu-cores.outputs.count }} | |
- name: Run main application | |
run: ${{ env.BINARY_PATH }}ant4c${{ env.EXECUTABLE_EXTENSION }} | |
- name: Run tests (MinGW) | |
if: ${{ 'mingw' == matrix.compiler }} | |
run: | | |
$Env:PATH="C:\mingw64\bin;$Env:SystemRoot\system32;$Env:SystemRoot;$Env:SystemRoot\system32\Wbem;$Env:SystemRoot\system32\WindowsPowerShell\v1.0\;$Env:ProgramFiles\CMake\bin;" | |
ctest --build-config ${{ env.CMAKE_CONFIG_TYPE }} --test-dir ${{ env.CMAKE_BUILD_DIR }} --output-on-failure | |
- name: Run tests | |
if: ${{ 'mingw' != matrix.compiler }} | |
run: >- | |
ctest | |
--build-config ${{ env.CMAKE_CONFIG_TYPE }} | |
--test-dir ${{ env.CMAKE_BUILD_DIR }} | |
--output-on-failure | |
- name: Compress files with zstd | |
shell: pwsh | |
run: | | |
$paths = Get-ChildItem -File -Path ${{ env.BINARY_PATH }} | |
ForEach ($path in $paths) | |
{ | |
$outputPath = [System.String]::Format("{0}.zst", $path.FullName) | |
& "zstd" --ultra -22 $path.FullName -o $outputPath | |
} | |
- name: Upload binaries | |
uses: actions/upload-artifact@v4 | |
with: | |
name: ${{ matrix.os }}-${{ matrix.compiler }}-${{ matrix.optimized && 'release' || 'debug' }}-${{ matrix.target_platform }} | |
retention-days: 1 | |
path: ${{ env.BINARY_PATH }}/*.zst |