Skip to content

Fix vcpkg packaging: debug headers, DLL exports, YAML_USE_CXX17 typo, x86 exclusion #741

Fix vcpkg packaging: debug headers, DLL exports, YAML_USE_CXX17 typo, x86 exclusion

Fix vcpkg packaging: debug headers, DLL exports, YAML_USE_CXX17 typo, x86 exclusion #741

Workflow file for this run

name: CMake
on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]
permissions:
contents: read
env:
global-cmake-flags: -DTRIESTE_ENABLE_TESTING=1
jobs:
build-test:
strategy:
matrix:
platform: [ "ubuntu-22.04", "macos-latest", "windows-latest" ]
build-type: [ "Release", "Debug" ]
# Note: cmake-options is missing here on purpose to let it be overridden by includes
standard: [ "", "-DTRIESTE_USE_CXX17=ON" ]
compiler: [ "", "clang" ]
variant: [""]
include:
# ensures ubuntu-22.04 clang uses Ninja (modifies the matrix entry)
- platform: "ubuntu-22.04"
compiler: "clang"
cmake-options: "-DCMAKE_CXX_COMPILER=clang++-15 -DCMAKE_C_COMPILER=clang-15 -DTRIESTE_BUILD_PARSER_TESTS=1"
generator: "-G Ninja"
dependencies: "sudo apt install ninja-build clang-15"
- platform: "windows-latest"
variant: "build-parser-tests"
build-type: "Release"
cmake-options: "-DTRIESTE_BUILD_PARSER_TESTS=1"
- platform: "windows-latest"
variant: "shared-libs"
build-type: "Release"
cmake-options: "-DBUILD_SHARED_LIBS=ON"
- platform: "macos-latest"
variant: "build-parser-tests"
build-type: "Release"
cmake-options: "-DTRIESTE_BUILD_PARSER_TESTS=1"
- platform: "ubuntu-22.04"
variant: "asan"
build-type: "Release"
cmake-options: "-DCMAKE_CXX_COMPILER=clang++-15 -DCMAKE_C_COMPILER=clang-15 -DTRIESTE_SANITIZE=address -DTRIESTE_BUILD_PARSER_TESTS=1"
dependencies: "sudo apt install ninja-build clang-15"
- platform: "macos-latest"
variant: "asan"
build-type: "Release"
cmake-options: "-DTRIESTE_SANITIZE=address -DTRIESTE_BUILD_PARSER_TESTS=1"
- platform: "ubuntu-22.04"
variant: "ubsan"
build-type: "Release"
cmake-options: "-DCMAKE_CXX_COMPILER=clang++-15 -DCMAKE_C_COMPILER=clang-15 -DTRIESTE_SANITIZE=undefined -DTRIESTE_BUILD_PARSER_TESTS=1"
dependencies: "sudo apt install ninja-build clang-15"
exclude:
# Mac is already using clang.
- platform: "macos-latest"
compiler: "clang"
# Windows is only using MSVC.
- platform: "windows-latest"
compiler: "clang"
# Don't abort runners if a single one fails
fail-fast: false
runs-on: ${{matrix.platform}}
name: ${{matrix.platform}} ${{matrix.build-type}} ${{matrix.standard}} ${{matrix.compiler}} ${{matrix.variant}}
steps:
- uses: actions/checkout@v6
- name: Install build dependencies
run: ${{matrix.dependencies}}
- name: Configure CMake
run: cmake -B ${{github.workspace}}/build ${{env.global-cmake-flags}} -DCMAKE_BUILD_TYPE=${{matrix.build-type}} ${{matrix.generator}} ${{matrix.standard}} ${{matrix.cmake-options}}
- name: Build
run: cmake --build ${{github.workspace}}/build --config ${{matrix.build-type}}
- name: Test
working-directory: ${{github.workspace}}/build
run: ctest -C ${{matrix.build-type}} --output-on-failure --timeout 400 --interactive-debug-mode 0
vcpkg-integration:
strategy:
fail-fast: false
matrix:
os: [ ubuntu-22.04, macos-latest, windows-latest ]
features: [ "core" ]
include:
- os: ubuntu-22.04
features: "parsers"
runs-on: ${{ matrix.os }}
name: vcpkg - ${{ matrix.os }} ${{ matrix.features }}
steps:
- uses: actions/checkout@v6
- name: Check version consistency
shell: bash
run: |
file_ver=$(head -1 VERSION | tr -d '[:space:]')
vcpkg_ver=$(grep '"version"' ports/trieste/vcpkg.json | sed 's/.*: *"\(.*\)".*/\1/')
if [ "$file_ver" != "$vcpkg_ver" ]; then
echo "::error::VERSION ($file_ver) and ports/trieste/vcpkg.json ($vcpkg_ver) are out of sync."
exit 1
fi
echo "Version consistent: $file_ver"
- name: Bootstrap vcpkg
shell: bash
run: |
git clone https://github.com/microsoft/vcpkg.git "${{ runner.temp }}/vcpkg" --depth 1
if [ "$RUNNER_OS" = "Windows" ]; then
"${{ runner.temp }}/vcpkg/bootstrap-vcpkg.bat" -disableMetrics
else
"${{ runner.temp }}/vcpkg/bootstrap-vcpkg.sh" -disableMetrics
fi
- name: Create overlay port pointing at local source
shell: bash
run: |
overlay="${{ runner.temp }}/overlay/trieste"
mkdir -p "$overlay"
# Copy the real port files
cp ports/trieste/vcpkg.json "$overlay/"
cp ports/trieste/usage "$overlay/"
# Normalize workspace path to forward slashes for CMake (Windows compat)
ws_path=$(echo "${{ github.workspace }}" | sed 's|\\|/|g')
# Rewrite portfile to use local source instead of vcpkg_from_github
{
echo "set(SOURCE_PATH \"${ws_path}\")"
echo ''
# Keep everything from the feature block onwards (see NOTE comment in
# ports/trieste/portfile.cmake documenting this coupling)
sed -n '/^if("parsers"/,$ p' ports/trieste/portfile.cmake
} > "$overlay/portfile.cmake"
# Validate that the sed extraction actually matched
if ! grep -q 'vcpkg_cmake_configure' "$overlay/portfile.cmake"; then
echo "::error::Overlay portfile extraction failed — 'vcpkg_cmake_configure' not found."
echo "The sed pattern in this workflow is coupled to ports/trieste/portfile.cmake."
echo "See the NOTE comment in that file."
exit 1
fi
- name: Install trieste via vcpkg
shell: bash
# Run from runner.temp to avoid the workspace triggering manifest mode.
working-directory: ${{ runner.temp }}
run: |
if [ "${{ matrix.features }}" = "parsers" ]; then
"${{ runner.temp }}/vcpkg/vcpkg" install "trieste[parsers]" \
--overlay-ports="${{ runner.temp }}/overlay"
else
"${{ runner.temp }}/vcpkg/vcpkg" install trieste \
--overlay-ports="${{ runner.temp }}/overlay"
fi
- name: Build consumer project
shell: bash
run: |
extra_flags=""
if [ "${{ matrix.features }}" = "parsers" ]; then
extra_flags="-DTEST_PARSERS=ON"
fi
cmake -B "${{ runner.temp }}/consumer-build" \
-S test/vcpkg-consumer \
-DCMAKE_TOOLCHAIN_FILE="${{ runner.temp }}/vcpkg/scripts/buildsystems/vcpkg.cmake" \
$extra_flags
cmake --build "${{ runner.temp }}/consumer-build" --config Release
- name: Run tests
shell: bash
run: |
ctest --test-dir "${{ runner.temp }}/consumer-build" \
--build-config Release --output-on-failure
all-checks:
# Join of all build-test jobs
needs: [build-test, format-check, vcpkg-integration]
runs-on: ubuntu-22.04
steps:
- name: Check all jobs
run: echo "All jobs passed"
format-check:
runs-on: ubuntu-24.04
name: Format Check
steps:
- uses: actions/checkout@v6
- name: Install dependencies
run: sudo apt install ninja-build clang-format-18
- name: Configure CMake
run: cmake -B ${{github.workspace}}/build -DCMAKE_CXX_COMPILER=clang++-18 -DCMAKE_C_COMPILER=clang-18 -G Ninja
- name: Run clang-format check
working-directory: ${{github.workspace}}/build
run: |
set -eo pipefail
ninja clangformat
git diff --exit-code