Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: vcpkg integration #17

Merged
merged 1 commit into from
Oct 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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"
]
}
2 changes: 1 addition & 1 deletion cmake/pkg-config.pc.in
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ libdir=@CMAKE_INSTALL_PREFIX@/@CMAKE_INSTALL_LIBDIR@
Name: @PROJECT_NAME@
Description: @PROJECT_DESCRIPTION@
Version: @PROJECT_VERSION@
Cflags: -I${includedir}
Cflags: -I${includedir} -std=c++17
Libs: -L${libdir} -l@PROJECT_NAME@
Requires@REQUIRES_SUFFIX@: opentelemetry_logs
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"
}
]
}
7 changes: 7 additions & 0 deletions vcpkg.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"$schema": "https://raw.githubusercontent.com/microsoft/vcpkg-tool/main/docs/vcpkg.schema.json",
"dependencies": [
"gtest",
"opentelemetry-cpp"
]
}