Skip to content

[CMake / build-in deps] Fixed Pcap++ build (Warnings-as-errors) #126

[CMake / build-in deps] Fixed Pcap++ build (Warnings-as-errors)

[CMake / build-in deps] Fixed Pcap++ build (Warnings-as-errors) #126

Workflow file for this run

name: Windows
on:
push:
pull_request:
branches: [ master ]
env:
# Customize the CMake build type here (Release, Debug, RelWithDebInfo, etc.)
INSTALL_PREFIX: _install
PROJECT_NAME: udpcap
VS_TOOLSET: v142
VS_NAME: vs2019
jobs:
build-windows:
strategy:
matrix:
library_type: [static, shared]
build_arch: [x64, win32]
fail-fast: false
# The CMake configure and build commands are platform agnostic and should work equally well on Windows or Mac.
# You can convert this to a matrix build if you need cross-platform coverage.
# See: https://docs.github.com/en/free-pro-team@latest/actions/learn-github-actions/managing-complex-workflows#using-a-build-matrix
runs-on: windows-2019
steps:
- name: Set Variables
run: |
# Always set build_shared_libs to OFF, as we want static dependencies.
# The udpcap_library_type variable will be used to determine if we are
# building a static or shared udpcap library.
echo "build_shared_libs=OFF" >> "$Env:GITHUB_ENV"
if ( '${{ matrix.library_type }}' -eq 'static' )
{
echo "udpcap_library_type=STATIC" >> "$Env:GITHUB_ENV"
echo "package_postfix=static" >> "$Env:GITHUB_ENV"
}
else
{
echo "udpcap_library_type=SHARED" >> "$Env:GITHUB_ENV"
echo "package_postfix=shared" >> "$Env:GITHUB_ENV"
}
- name: Checkout
uses: actions/checkout@v4
with:
submodules: 'true'
fetch-depth: 0
############################################
# Test-compile the project
############################################
- name: Configure CMake
# Configure CMake in a 'build' subdirectory. `CMAKE_BUILD_TYPE` is only required if you are using a single-configuration generator such as make.
# See https://cmake.org/cmake/help/latest/variable/CMAKE_BUILD_TYPE.html?highlight=cmake_build_type
run: |
cmake -B ${{github.workspace}}/_build `
-G "Visual Studio 16 2019" `
-A ${{ matrix.build_arch }} `
-T ${{ env.VS_TOOLSET }} `
-DCMAKE_INSTALL_PREFIX=${{env.INSTALL_PREFIX}} `
-DUDPCAP_LIBRARY_TYPE=${{ env.udpcap_library_type }} `
-DBUILD_SHARED_LIBS=${{ env.build_shared_libs }}
- name: Build (Release)
run: |
cmake --build ${{github.workspace}}/_build --config Release --parallel
# We only need to install everyhing (i.e. Pcap++ libs) for the static build.
# For the shared build, we only need to install the udpcap library and headers.
if ( '${{ matrix.library_type }}' -eq 'static' )
{
cmake --install ${{github.workspace}}/_build --config Release
}
else
{
cmake --install ${{github.workspace}}/_build --config Release --component udpcap_dev
cmake --install ${{github.workspace}}/_build --config Release --component udpcap_runtime
}
- name: Build (Debug)
run: |
cmake --build ${{github.workspace}}/_build --config Debug --parallel
# We only need to install everyhing (i.e. Pcap++ libs) for the static build.
# For the shared build, we only need to install the udpcap library and headers.
if ( '${{ matrix.library_type }}' -eq 'static' )
{
cmake --install ${{github.workspace}}/_build --config Debug
}
else
{
cmake --install ${{github.workspace}}/_build --config Debug --component udpcap_dev
cmake --install ${{github.workspace}}/_build --config Debug --component udpcap_runtime
}
- name: Read Project Version from CMakeCache
run: |
$cmake_project_version_line = cat ${{github.workspace}}/_build/CMakeCache.txt | Select-String -Pattern ^CMAKE_PROJECT_VERSION:
$cmake_project_version = $cmake_project_version_line.Line.split("=")[1]
echo "CMAKE_PROJECT_VERSION=$cmake_project_version" >> "$Env:GITHUB_ENV"
- name: Upload binaries
uses: actions/upload-artifact@v4
with:
name: ${{ env.PROJECT_NAME }}-${{ env.CMAKE_PROJECT_VERSION }}-windows-${{ matrix.build_arch }}-${{ env.VS_NAME }}-${{ matrix.library_type }}
path: ${{github.workspace}}/${{env.INSTALL_PREFIX}}
############################################
# Test if our binary can be linked against
############################################
- name: CMake integration test
run: |
cmake -B ${{github.workspace}}/samples/integration_test/_build `
-A ${{ matrix.build_arch }} `
-DCMAKE_PREFIX_PATH=${{github.workspace}}/${{env.INSTALL_PREFIX}}
working-directory: ${{ github.workspace }}/samples/integration_test
- name: Compile integration test (Release)
run: cmake --build ${{github.workspace}}/samples/integration_test/_build --config Release
working-directory: ${{ github.workspace }}/samples/integration_test
- name: Run integration test (Release)
run: |
if ( '${{ matrix.library_type }}' -eq 'shared' )
{
$Env:Path = '${{github.workspace}}/${{env.INSTALL_PREFIX}}/bin;' + $Env:Path
}
.\integration_test.exe
working-directory: ${{ github.workspace }}/samples/integration_test/_build/Release
- name: Compile integration test (Debug)
run: cmake --build ${{github.workspace}}/samples/integration_test/_build --config Debug
working-directory: ${{ github.workspace }}/samples/integration_test
- name: Run integration test (Debug)
run: |
if ( '${{ matrix.library_type }}' -eq 'shared' )
{
$Env:Path = '${{github.workspace}}/${{env.INSTALL_PREFIX}}/bin;' + $Env:Path
}
.\integration_test.exe
working-directory: ${{ github.workspace }}/samples/integration_test/_build/Debug