Skip to content

Commit 4f41f80

Browse files
committed
vcpkgize
1 parent ac218a0 commit 4f41f80

File tree

9 files changed

+220
-0
lines changed

9 files changed

+220
-0
lines changed

.github/workflows/ci.yml

+52
Original file line numberDiff line numberDiff line change
@@ -312,6 +312,58 @@ jobs:
312312
filename: '.\nuget\*.nupkg'
313313
api-key: ${{ secrets.NUGET_DOT_ORG_API_KEY }}
314314
if: startsWith(github.ref, 'refs/tags/')
315+
##### vcpkg #####
316+
vcpkg:
317+
strategy:
318+
fail-fast: false
319+
matrix:
320+
include:
321+
- {os: debian, codename: bookworm, image_owner: }
322+
# - {os: debian, codename: bookworm, image_owner: i386/, labels: [i386,docker]}
323+
# - {os: debian, codename: bookworm, image_owner: , labels: [arm32,docker]}
324+
# - {os: debian, codename: bookworm, image_owner: , labels: [arm64,docker]}
325+
runs-on: ${{ (matrix.labels == '' && 'ubuntu-latest') || matrix.labels }}
326+
container: ${{ matrix.image_owner }}${{ matrix.os }}:${{ matrix.codename }}
327+
name: vcpkg - linux | ${{ matrix.labels[0] }}
328+
steps:
329+
- name: add cppfw deb repo
330+
uses: myci-actions/add-deb-repo@main
331+
with:
332+
repo: deb https://gagis.hopto.org/repo/cppfw/${{ matrix.os }} ${{ matrix.codename }} main
333+
repo-name: cppfw
334+
keys-asc: https://gagis.hopto.org/repo/cppfw/pubkey.gpg
335+
install: myci cmake git curl zip unzip tar nodejs pkg-config
336+
- name: git clone
337+
uses: myci-actions/checkout@main
338+
- name: install vcpkg
339+
run: |
340+
git clone https://github.com/microsoft/vcpkg.git vcpkg-installation
341+
(cd vcpkg-installation; ./bootstrap-vcpkg.sh)
342+
- name: set VCPKG_ROOT
343+
uses: myci-actions/export-env-var@main
344+
with: {name: VCPKG_ROOT, value: "$(pwd)/vcpkg-installation"}
345+
- name: add VCPKG_ROOT to PATH
346+
uses: myci-actions/export-env-var@main
347+
with: {name: PATH, value: "$PATH:$VCPKG_ROOT"}
348+
- name: prepare vcpkg port
349+
run: |
350+
myci-vcpkg-prepare.sh --git-ref ${{ github.sha }}
351+
- name: test vcpkg port
352+
run: |
353+
cd vcpkg/test
354+
cmake .
355+
make
356+
./test
357+
- name: upload vcpkg logs to artifacts
358+
if: always() # even if previous steps fail, this one needs to be run
359+
uses: actions/upload-artifact@v4
360+
with:
361+
name: vcpkg_logs
362+
path: vcpkg-installation/buildtrees/${{ env.PACKAGE_NAME }}/
363+
- name: deploy vcpkg port
364+
run: |
365+
myci-deploy-vcpkg.sh --repo cppfw/vcpkg-repo --port-dir vcpkg/overlay/${PACKAGE_NAME}
366+
if: startsWith(github.ref, 'refs/tags/')
315367
##### conan - linux #####
316368
conan-linux:
317369
strategy:

cmake/CMakeLists.txt

+68
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
cmake_minimum_required(VERSION 3.10)
2+
3+
include(GNUInstallDirs)
4+
5+
set(name tst)
6+
7+
project(${name})
8+
9+
find_package(utki CONFIG REQUIRED)
10+
find_package(clargs CONFIG REQUIRED)
11+
find_package(opros CONFIG REQUIRED)
12+
find_package(nitki CONFIG REQUIRED)
13+
14+
file(GLOB_RECURSE srcs "../src/${name}/*.cpp")
15+
16+
add_library(
17+
${name}
18+
STATIC
19+
${srcs}
20+
)
21+
22+
target_compile_features(${name} PUBLIC cxx_std_17)
23+
set_target_properties(${name} PROPERTIES CXX_STANDARD_REQUIRED ON)
24+
set_target_properties(${name} PROPERTIES CXX_EXTENSIONS OFF)
25+
26+
target_include_directories(
27+
${name}
28+
INTERFACE
29+
$<BUILD_INTERFACE:>
30+
$<INSTALL_INTERFACE:include>
31+
)
32+
33+
target_link_libraries(
34+
${name}
35+
PUBLIC
36+
utki::utki
37+
clargs::clargs
38+
nitki::nitki
39+
)
40+
41+
# install library header files preserving directory hierarchy
42+
install(
43+
DIRECTORY
44+
"${CMAKE_CURRENT_SOURCE_DIR}/../src/${name}"
45+
DESTINATION
46+
"${CMAKE_INSTALL_INCLUDEDIR}"
47+
FILES_MATCHING PATTERN
48+
"*.hpp"
49+
)
50+
51+
install(
52+
TARGETS
53+
${name}
54+
EXPORT # generate cmake configs
55+
${name}-config
56+
)
57+
58+
# install cmake configs
59+
install(
60+
EXPORT
61+
${name}-config
62+
FILE
63+
${name}-config.cmake
64+
DESTINATION
65+
${CMAKE_INSTALL_DATAROOTDIR}/${name}
66+
NAMESPACE
67+
${name}::
68+
)

vcpkg/portfile.cmake.in

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
vcpkg_check_linkage(ONLY_STATIC_LIBRARY)
2+
3+
vcpkg_from_github(
4+
OUT_SOURCE_PATH SOURCE_PATH
5+
REPO cppfw/${PORT}
6+
REF $(git_ref)
7+
SHA512 $(archive_hash)
8+
HEAD_REF main
9+
)
10+
11+
vcpkg_cmake_configure(
12+
SOURCE_PATH "${SOURCE_PATH}/cmake"
13+
)
14+
15+
vcpkg_cmake_install()
16+
17+
vcpkg_cmake_config_fixup()
18+
19+
# Delete the include directory from the debug installation to prevent overlap.
20+
file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/include")
21+
22+
# Install the LICENSE file to the package's share directory and rename it to copyright.
23+
file(INSTALL "${SOURCE_PATH}/LICENSE" DESTINATION "${CURRENT_PACKAGES_DIR}/share/${PORT}" RENAME copyright)
24+
25+
# Copy the usage instruction file to the package's share directory.
26+
configure_file("${CMAKE_CURRENT_LIST_DIR}/usage" "${CURRENT_PACKAGES_DIR}/share/${PORT}/usage" COPYONLY)

vcpkg/test/CMakeLists.txt

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
cmake_minimum_required(VERSION 3.10)
2+
3+
set(CMAKE_TOOLCHAIN_FILE $ENV{VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake)
4+
5+
project(test)
6+
7+
find_package(utki CONFIG REQUIRED)
8+
find_package(clargs CONFIG REQUIRED)
9+
find_package(opros CONFIG REQUIRED)
10+
find_package(nitki CONFIG REQUIRED)
11+
find_package(tst CONFIG REQUIRED)
12+
13+
add_executable(test main.cpp)
14+
15+
target_link_libraries(test PRIVATE tst::tst)

vcpkg/test/main.cpp

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#include <tst/set.hpp>
2+
#include <tst/check.hpp>
3+
4+
namespace{
5+
const tst::set("test_set", [](tst::suite& suite){
6+
suite.add("sample_test", [](){
7+
std::string s = "Hi!";
8+
tst::check_eq(s.size(), size_t(3), SL);
9+
});
10+
});
11+
}

vcpkg/test/vcpkg-configuration.json

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
{
2+
"default-registry": {
3+
"kind": "git",
4+
"baseline": "5e5d0e1cd7785623065e77eff011afdeec1a3574",
5+
"repository": "https://github.com/microsoft/vcpkg"
6+
},
7+
"registries": [
8+
{
9+
"kind": "git",
10+
"repository": "https://github.com/cppfw/vcpkg-repo/",
11+
"baseline": "",
12+
"reference": "main",
13+
"packages": [ "utki", "clargs", "opros", "nitki" ]
14+
}
15+
],
16+
"overlay-ports": [
17+
"../overlay"
18+
]
19+
}

vcpkg/test/vcpkg.json

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"dependencies": [
3+
"tst"
4+
]
5+
}

vcpkg/usage

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
tst provides CMake targets:
2+
3+
find_package(tst CONFIG REQUIRED)
4+
target_link_libraries(main PRIVATE tst::tst)

vcpkg/vcpkg.json.in

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
{
2+
"name": "tst",
3+
"version": "$(version)",
4+
"homepage": "https://github.com/cppfw/tst",
5+
"description": "unit tests runner library in C++",
6+
"license": "MIT",
7+
"dependencies": [
8+
{
9+
"name" : "vcpkg-cmake",
10+
"host" : true
11+
},
12+
{
13+
"name" : "vcpkg-cmake-config",
14+
"host" : true
15+
},
16+
"utki",
17+
"clargs",
18+
"nitki"
19+
]
20+
}

0 commit comments

Comments
 (0)