Skip to content

CMake: Ecaludp now installs an ecaludpConfigVersion.cmake file (#12) #95

CMake: Ecaludp now installs an ecaludpConfigVersion.cmake file (#12)

CMake: Ecaludp now installs an ecaludpConfigVersion.cmake file (#12) #95

Workflow file for this run

name: Windows
on:
push:
pull_request:
branches: [ main ]
env:
# Customize the CMake build type here (Release, Debug, RelWithDebInfo, etc.)
INSTALL_PREFIX: _install
PROJECT_NAME: ecaludp
VS_TOOLSET: v140
VS_NAME: vs2015
jobs:
build-windows:
strategy:
fail-fast: false
matrix:
library_type: [static, shared, object]
build_arch: [x64, win32]
npcap_enabled: [ON, OFF]
# 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: |
if ( '${{ matrix.library_type }}' -eq 'static' )
{
echo "ecaludp_library_type=STATIC" >> "$Env:GITHUB_ENV"
echo "package_postfix=static" >> "$Env:GITHUB_ENV"
}
elseif( '${{ matrix.library_type }}' -eq 'shared' )
{
echo "ecaludp_library_type=SHARED" >> "$Env:GITHUB_ENV"
echo "package_postfix=shared" >> "$Env:GITHUB_ENV"
}
elseif( '${{ matrix.library_type }}' -eq 'object' )
{
echo "ecaludp_library_type=OBJECT" >> "$Env:GITHUB_ENV"
echo "package_postfix=object" >> "$Env:GITHUB_ENV"
}
if ( '${{ matrix.npcap_enabled }}' -eq 'ON' )
{
echo "npcap_enabled_string=-npcap" >> "$Env:GITHUB_ENV"
}
else
{
echo "npcap_enabled_string=" >> "$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
shell: cmd
run: |
cmake -B ${{github.workspace}}/_build ^
-G "Visual Studio 16 2019" ^
-A ${{ matrix.build_arch }} ^
-T ${{ env.VS_TOOLSET }} ^
-DECALUDP_BUILD_SAMPLES=ON ^
-DECALUDP_BUILD_TESTS=ON ^
-DECALUDP_USE_BUILTIN_ASIO=ON ^
-DECALUDP_USE_BUILTIN_RECYCLE=ON ^
-DECALUDP_USE_BUILTIN_GTEST=ON ^
-DECALUDP_LIBRARY_TYPE=${{env.ecaludp_library_type}} ^
-DECALUDP_ENABLE_NPCAP=${{ matrix.npcap_enabled }} ^
-DCMAKE_INSTALL_PREFIX=${{env.INSTALL_PREFIX}}
- name: Build (Release)
shell: cmd
run: |
cmake --build ${{github.workspace}}/_build --config Release --parallel
- name: Install (Release)
shell: cmd
run: |
cmake --build ${{github.workspace}}/_build --config Release --target INSTALL
if: ${{ matrix.library_type != 'object' }}
- name: Build (Debug)
shell: cmd
run: |
cmake --build ${{github.workspace}}/_build --config Debug --parallel
- name: Install (Debug)
shell: cmd
run: |
cmake --build ${{github.workspace}}/_build --config Debug --target INSTALL
if: ${{ matrix.library_type != 'object' }}
- name: Run Tests
run: ctest -C Release -V
working-directory: ${{ github.workspace }}/_build
if: ${{ matrix.npcap_enabled != 'ON' }} # Npcap driver is missing, so we cannot execute tests
- 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 }}${{ env.npcap_enabled_string }}-windows-${{ matrix.build_arch }}-${{ env.VS_NAME }}-${{ matrix.library_type }}
path: ${{github.workspace}}/${{env.INSTALL_PREFIX}}
if: ${{ matrix.library_type != 'object' }}
############################################
# Test if our binary can be linked against
############################################
- name: Set variables for integration test
shell: powershell
run: |
if ( '${{ matrix.npcap_enabled }}' -eq 'ON' )
{
echo "integration_test_name=integration_test_npcap" >> "$Env:GITHUB_ENV"
if ( '${{ matrix.library_type }}' -eq 'static' )
{
echo "integration_test_include_udpcap=ON" >> "$Env:GITHUB_ENV"
}
else
{
echo "integration_test_include_udpcap=OFF" >> "$Env:GITHUB_ENV"
}
}
else
{
echo "integration_test_name=integration_test" >> "$Env:GITHUB_ENV"
echo "integration_test_include_udpcap=OFF" >> "$Env:GITHUB_ENV"
}
- name: CMake integration test
shell: powershell
run: |
cmake -B "${{github.workspace}}/samples/${{ env.integration_test_name }}/_build" `
-A ${{ matrix.build_arch }} `
-DCMAKE_PREFIX_PATH="${{github.workspace}}/${{env.INSTALL_PREFIX}}" `
-DINTEGRATION_TEST_INCLUDE_UDPCAP=$use_udpcap
working-directory: ${{ github.workspace }}/samples/${{ env.integration_test_name }}
if: ${{ matrix.library_type != 'object' }}
- name: Compile integration test (Release)
shell: cmd
run: cmake --build ${{github.workspace}}/samples/${{ env.integration_test_name }}/_build --config Release
working-directory: ${{ github.workspace }}/samples/${{ env.integration_test_name }}
if: ${{ matrix.library_type != 'object' }}
- name: Run integration test (Release)
run: |
if ( '${{ matrix.library_type }}' -eq 'shared' )
{
$Env:Path = '${{github.workspace}}/${{env.INSTALL_PREFIX}}/bin;' + $Env:Path
}
.\${{ env.integration_test_name }}.exe
working-directory: ${{ github.workspace }}/samples/${{ env.integration_test_name }}/_build/Release
if: ${{ matrix.library_type != 'object' }}
- name: Compile integration test (Debug)
shell: cmd
run: cmake --build ${{github.workspace}}/samples/${{ env.integration_test_name }}/_build --config Debug
working-directory: ${{ github.workspace }}/samples/${{ env.integration_test_name }}
if: ${{ matrix.library_type != 'object' }}
- name: Run integration test (Debug)
run: |
if ( '${{ matrix.library_type }}' -eq 'shared' )
{
$Env:Path = '${{github.workspace}}/${{env.INSTALL_PREFIX}}/bin;' + $Env:Path
}
.\${{ env.integration_test_name }}.exe
working-directory: ${{ github.workspace }}/samples/${{ env.integration_test_name }}/_build/Debug
if: ${{ matrix.library_type != 'object' }}