Skip to content

Commit

Permalink
feat: vcpkg integration
Browse files Browse the repository at this point in the history
  • Loading branch information
sjinks committed Oct 4, 2024
1 parent 1e72877 commit e7d5b7f
Show file tree
Hide file tree
Showing 11 changed files with 108 additions and 4 deletions.
64 changes: 64 additions & 0 deletions .github/workflows/ci-vcpkg.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
name: Build and Test (vcpkg)

on:
push:
branches:
- master
pull_request:
workflow_dispatch:

permissions:
contents: read

jobs:
build:
name: Build and Test (${{ matrix.os }})
strategy:
fail-fast: false
matrix:
include:
- os: macos-latest
triplet: arm64-osx-release
- os: ubuntu-24.04
triplet: x64-linux-release
runs-on: ${{ matrix.os }}
permissions:
contents: read
env:
VCPKG_DEFAULT_TRIPLET: ${{ matrix.triplet }}
VCPKG_DEFAULT_HOST_TRIPLET: ${{ matrix.triplet }}
steps:
- name: Harden Runner
uses: step-security/harden-runner@91182cccc01eb5e619899d80e4e971d6181294a7 # v2.10.1
with:
egress-policy: audit

- name: Check out code
uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 # v4.2.0
with:
submodules: true

- name: Set up cmake and ninja
uses: lukka/get-cmake@582a9f5c6f4f332f36797e1ac757d1c8850a1513 # v3.30.4

- name: Set up vcpkg
uses: lukka/run-vcpkg@5e0cab206a5ea620130caf672fce3e4a6b5666a1 # v11.5

- name: Build
run: |
cmake -B build --toolchain vcpkg/scripts/buildsystems/vcpkg.cmake
cmake --build build
- name: Test
run: ctest --test-dir build

- name: Install
run: sudo cmake --install build

- name: Smoke test
run: |
cmake -B build --toolchain ../vcpkg/scripts/buildsystems/vcpkg.cmake
cmake --build build
./build/ci-cmake
./build/ci-pkgconfig
working-directory: ci
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "vcpkg"]
path = vcpkg
url = https://github.com/microsoft/vcpkg
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ set(EXPORT_COMPILE_COMMANDS ON)

project(
wwa_opentelemetry_exporter_syslog_logs
VERSION 1.0.0
VERSION 1.0.1
DESCRIPTION "Syslog logs exporter for OpenTelemetry"
HOMEPAGE_URL "https://github.com/sjinks/opentelemetry_exporter_syslog_logs"
LANGUAGES CXX
Expand Down
1 change: 1 addition & 0 deletions ci/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
build/
6 changes: 5 additions & 1 deletion ci/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
cmake_minimum_required(VERSION 3.25)

project(ci VERSION 1.0.0.1 LANGUAGES CXX)
project(ci LANGUAGES CXX)
set(CMAKE_VERBOSE_MAKEFILE ON)

if(DEFINED VCPKG_INSTALLED_DIR)
file(MAKE_DIRECTORY "${VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}/include" "${VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}/debug/include" )
endif()

include(FindPkgConfig)

find_package(wwa_opentelemetry_exporter_syslog_logs CONFIG REQUIRED)
Expand Down
1 change: 1 addition & 0 deletions ci/vcpkg-configuration.json
6 changes: 6 additions & 0 deletions ci/vcpkg.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"$schema": "https://raw.githubusercontent.com/microsoft/vcpkg-tool/main/docs/vcpkg.schema.json",
"dependencies": [
"opentelemetry-cpp"
]
}
6 changes: 4 additions & 2 deletions test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,7 @@ set_target_properties(
VISIBILITY_INLINES_HIDDEN ON
)

include(GoogleTest)
gtest_discover_tests(test_logger)
if(NOT CMAKE_CROSSCOMPILING)
include(GoogleTest)
gtest_discover_tests(test_logger)
endif()
1 change: 1 addition & 0 deletions vcpkg
Submodule vcpkg added at 52fc0d
14 changes: 14 additions & 0 deletions vcpkg-configuration.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"default-registry": {
"kind": "git",
"baseline": "0affe8710a4a5b26328e909fe1ad7146df39d108",
"repository": "https://github.com/microsoft/vcpkg"
},
"registries": [
{
"kind": "artifact",
"location": "https://github.com/microsoft/vcpkg-ce-catalog/archive/refs/heads/main.zip",
"name": "microsoft"
}
]
}
8 changes: 8 additions & 0 deletions vcpkg.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"$schema": "https://raw.githubusercontent.com/microsoft/vcpkg-tool/main/docs/vcpkg.schema.json",
"dependencies": [
"gtest",
"nlohmann-json",
"opentelemetry-cpp"
]
}

0 comments on commit e7d5b7f

Please sign in to comment.