Skip to content

Commit 521c379

Browse files
authored
Added vcpkg installation docs and CI smoke test (#12)
1 parent 8e13bd7 commit 521c379

5 files changed

Lines changed: 136 additions & 2 deletions

File tree

.github/workflows/install.yml

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,18 +58,25 @@ jobs:
5858
# (the resolved includedir must actually contain our headers, not point at
5959
# a configure-time prefix that no longer matches the install location).
6060
# Skipped on Windows — pkg-config isn't part of the default toolchain.
61+
#
62+
# Expected version is derived from CMakeLists.txt rather than hardcoded
63+
# so that a `project(... VERSION x.y.z ...)` bump doesn't silently leave
64+
# this assertion testing the old number.
6165
- name: Verify pkg-config metadata
6266
if: runner.os != 'Windows'
6367
env:
6468
PKG_CONFIG_PATH: ${{ runner.temp }}/prefix/lib/pkgconfig
6569
run: |
70+
expected_version=$(sed -nE 's/^project\(GeoUtilsCpp VERSION ([0-9]+\.[0-9]+\.[0-9]+).*/\1/p' CMakeLists.txt)
71+
test -n "$expected_version" || { echo "ERROR: could not parse project version from CMakeLists.txt" >&2; exit 1; }
6672
version=$(pkg-config --modversion geo-utils-cpp)
6773
cflags=$(pkg-config --cflags geo-utils-cpp)
6874
include_dir=$(pkg-config --variable=includedir geo-utils-cpp)
75+
echo "expected: $expected_version"
6976
echo "version: $version"
7077
echo "cflags: $cflags"
7178
echo "includedir: $include_dir"
72-
test "$version" = "1.0.1"
79+
test "$version" = "$expected_version"
7380
case "$cflags" in
7481
*//*) echo "ERROR: doubled-slash in include path: $cflags" >&2; exit 1 ;;
7582
esac

.github/workflows/vcpkg.yml

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
# vcpkg integration smoke test.
2+
#
3+
# Installs geo-utils-cpp from the official microsoft/vcpkg registry, then
4+
# configures and builds the minimal consumer project (tests/consumer/) using
5+
# the vcpkg CMake toolchain file. Runs on Linux/macOS/Windows in parallel.
6+
#
7+
# What this catches:
8+
# - Breakage in the published vcpkg port
9+
# - Drift in vcpkg infrastructure or GitHub runner images
10+
# - Our exported CMake config / target name not surviving an install via vcpkg
11+
#
12+
# What this does NOT catch:
13+
# - Regressions introduced in this repo on a PR — vcpkg ships the *released*
14+
# version (currently 1.0.1), not HEAD. The PR/push runs verify the
15+
# published port still works; the weekly schedule catches drift over time.
16+
#
17+
# Triggered automatically on push/PR to master/main; runs weekly to catch
18+
# upstream drift; can also be run manually from the Actions tab.
19+
20+
name: vcpkg
21+
22+
on:
23+
push:
24+
branches: [master, main]
25+
pull_request:
26+
branches: [master, main]
27+
workflow_dispatch:
28+
schedule:
29+
# Mondays 06:00 UTC. Catches drift in the vcpkg registry / runner images.
30+
- cron: '0 6 * * 1'
31+
32+
permissions:
33+
contents: read
34+
35+
concurrency:
36+
group: ${{ github.workflow }}-${{ github.ref }}
37+
cancel-in-progress: true
38+
39+
jobs:
40+
vcpkg-consumer:
41+
name: vcpkg + consumer (${{ matrix.os }})
42+
strategy:
43+
fail-fast: false
44+
matrix:
45+
os: [ubuntu-latest, macos-latest, windows-latest]
46+
47+
runs-on: ${{ matrix.os }}
48+
49+
defaults:
50+
run:
51+
# Bash is available on all GH-hosted runners (Git Bash on Windows) and
52+
# gives us consistent $VCPKG_INSTALLATION_ROOT expansion across platforms.
53+
shell: bash
54+
55+
steps:
56+
- uses: actions/checkout@v4
57+
58+
# GH-hosted runners ship vcpkg pre-installed at $VCPKG_INSTALLATION_ROOT.
59+
# The bundled checkout can lag the registry by days/weeks, so sync to
60+
# origin/master to make sure the geo-utils-cpp port is present and
61+
# current. fetch+reset (rather than `pull --ff-only`) is robust against
62+
# the runner image leaving HEAD detached or off master — the runner is
63+
# disposable, so a hard reset is safe.
64+
- name: Sync vcpkg registry
65+
run: |
66+
git -C "$VCPKG_INSTALLATION_ROOT" fetch --depth=1 origin master
67+
git -C "$VCPKG_INSTALLATION_ROOT" reset --hard FETCH_HEAD
68+
69+
- name: Install geo-utils-cpp via vcpkg
70+
run: "$VCPKG_INSTALLATION_ROOT/vcpkg" install geo-utils-cpp
71+
72+
- name: Configure consumer with vcpkg toolchain
73+
run: |
74+
cmake -S tests/consumer -B build-consumer \
75+
-DCMAKE_TOOLCHAIN_FILE="$VCPKG_INSTALLATION_ROOT/scripts/buildsystems/vcpkg.cmake"
76+
77+
- name: Build consumer
78+
run: cmake --build build-consumer --config Release
79+
80+
- name: Test consumer
81+
run: ctest --test-dir build-consumer -C Release --output-on-failure

README.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@
44
<a href="https://github.com/gistrec/geo-utils-cpp/actions/workflows/ci.yml">
55
<img src="https://github.com/gistrec/geo-utils-cpp/actions/workflows/ci.yml/badge.svg" alt="CI">
66
</a>
7+
<a href="https://github.com/gistrec/geo-utils-cpp/actions/workflows/vcpkg.yml">
8+
<img src="https://github.com/gistrec/geo-utils-cpp/actions/workflows/vcpkg.yml/badge.svg" alt="vcpkg">
9+
</a>
710
<a href="https://app.codacy.com/gh/gistrec/geo-utils-cpp/dashboard">
811
<img src="https://img.shields.io/codacy/grade/bcff544711544d5fb7da95b68abf566d" alt="Code quality">
912
</a>
@@ -73,6 +76,19 @@ FetchContent_MakeAvailable(GeoUtilsCpp)
7376
target_link_libraries(your_target PRIVATE geo::utils)
7477
```
7578

79+
### vcpkg
80+
81+
```sh
82+
vcpkg install geo-utils-cpp
83+
```
84+
85+
Then in your `CMakeLists.txt`:
86+
87+
```cmake
88+
find_package(GeoUtilsCpp 1.0.1 REQUIRED)
89+
target_link_libraries(your_target PRIVATE geo::utils)
90+
```
91+
7692
### find_package
7793

7894
```cmake

docs/getting-started.md

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,33 @@ FetchContent_MakeAvailable(GeoUtilsCpp)
2222
target_link_libraries(your_target PRIVATE geo::utils)
2323
```
2424

25+
### vcpkg
26+
27+
The library is available in the official [vcpkg registry](https://github.com/microsoft/vcpkg).
28+
29+
Classic mode:
30+
31+
```sh
32+
vcpkg install geo-utils-cpp
33+
```
34+
35+
Manifest mode — add to your `vcpkg.json`:
36+
37+
```json
38+
{
39+
"dependencies": [
40+
"geo-utils-cpp"
41+
]
42+
}
43+
```
44+
45+
Then consume it from CMake:
46+
47+
```cmake
48+
find_package(GeoUtilsCpp 1.0.1 REQUIRED)
49+
target_link_libraries(your_target PRIVATE geo::utils)
50+
```
51+
2552
### find_package
2653

2754
Install the library first, then:

tests/consumer/CMakeLists.txt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,10 @@ project(geo_utils_cpp_consumer LANGUAGES CXX)
55
# link against geo::utils, and run a minimal program. Intended to be configured
66
# against an install prefix from the install workflow.
77

8-
find_package(GeoUtilsCpp 1.0.1 REQUIRED)
8+
# No version pinned: this is a smoke test for findability/linkage, not a
9+
# version-compatibility check. Version assertions live in install.yml's
10+
# pkg-config step (which derives the expected version from CMakeLists.txt).
11+
find_package(GeoUtilsCpp REQUIRED)
912

1013
add_executable(app main.cpp)
1114
target_link_libraries(app PRIVATE geo::utils)

0 commit comments

Comments
 (0)