Skip to content

Commit

Permalink
add vcpkg
Browse files Browse the repository at this point in the history
  • Loading branch information
romanpauk committed Jul 30, 2024
1 parent 867849d commit 280526a
Show file tree
Hide file tree
Showing 8 changed files with 55 additions and 11 deletions.
16 changes: 8 additions & 8 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: Build
concurrency:
group: ${{ github.ref }}
cancel-in-progress: true
on:
on:
schedule:
- cron: "0 0 * * *" # Daily
push:
Expand Down Expand Up @@ -52,7 +52,7 @@ jobs:
#{ CC: clang-17, CXX: clang++-17, STD: 23 },
{ CC: clang-18, CXX: clang++-18, STD: 17 },
{ CC: clang-18, CXX: clang++-18, STD: 20 },
{ CC: clang-18, CXX: clang++-18, STD: 23 }
{ CC: clang-18, CXX: clang++-18, STD: 23 }
]
runs-on: ${{ matrix.os }}
steps:
Expand All @@ -69,7 +69,7 @@ jobs:
run: |
which ${{ matrix.compiler.CC }} || sudo apt install ${{ matrix.compiler.CC }} || true
which ${{ matrix.compiler.CXX }} || sudo apt install ${{ matrix.compiler.CXX }} || true
cmake -S . -B build -DCMAKE_BUILD_TYPE=${{ matrix.config }} -DCMAKE_CXX_STANDARD=${{ matrix.compiler.STD }}
cmake -S . -B build -DDINGO_DEVELOPMENT_MODE=ON -DCMAKE_BUILD_TYPE=${{ matrix.config }} -DCMAKE_CXX_STANDARD=${{ matrix.compiler.STD }}
- name: Check Formatting
env:
PIP_BREAK_SYSTEM_PACKAGES: 1
Expand All @@ -90,9 +90,9 @@ jobs:
cd build && ./dingo_benchmark
- name: FetchContent
run: |
cmake -S test/fetchcontent -B fetchcontent-build -DCMAKE_BUILD_TYPE=${{ matrix.config }} -DCMAKE_CXX_STANDARD=${{ matrix.compiler.STD }}
cmake -S packaging/fetchcontent -B fetchcontent-build -DCMAKE_BUILD_TYPE=${{ matrix.config }} -DCMAKE_CXX_STANDARD=${{ matrix.compiler.STD }}
cmake --build fetchcontent-build -j 2
build-windows:
strategy:
fail-fast: false
Expand All @@ -111,7 +111,7 @@ jobs:
uses: actions/checkout@v4
- name: Configure
run: |
cmake -S . -B build -DCMAKE_BUILD_TYPE=${{ matrix.config }} -DCMAKE_CXX_STANDARD=${{ matrix.std }}
cmake -S . -B build -DDINGO_DEVELOPMENT_MODE=ON -DCMAKE_BUILD_TYPE=${{ matrix.config }} -DCMAKE_CXX_STANDARD=${{ matrix.std }}
- name: Check Formatting
run: |
python3 -m pip install mdformat
Expand All @@ -128,6 +128,6 @@ jobs:
build/${{ matrix.config }}/dingo_benchmark
- name: FetchContent
run: |
cmake -S test/fetchcontent -B fetchcontent-build -DCMAKE_BUILD_TYPE=${{ matrix.config }} -DCMAKE_CXX_STANDARD=${{ matrix.std }}
cmake -S packaging/fetchcontent -B fetchcontent-build -DCMAKE_BUILD_TYPE=${{ matrix.config }} -DCMAKE_CXX_STANDARD=${{ matrix.std }}
cmake --build fetchcontent-build -j 2
10 changes: 9 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
cmake_minimum_required(VERSION 3.19)
project(dingo)

option(DINGO_DEVELOPMENT_MODE "include additional targets for development" OFF)

add_library(dingo INTERFACE)
target_include_directories(dingo INTERFACE include)

Expand Down Expand Up @@ -45,7 +47,13 @@ target_sources(dingo INTERFACE
include/dingo/type_traits.h
)

if(CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_SOURCE_DIR)
install(
DIRECTORY ${CMAKE_SOURCE_DIR}/include/dingo
DESTINATION include
FILES_MATCHING PATTERN "*.h"
)

if(DINGO_DEVELOPMENT_MODE)
enable_testing()
include(FetchContent)
include(cmake/clang-format.cmake)
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -91,10 +91,10 @@ D e = container.invoke([&](A& a, B* b) { return D{a, b}; });
To use the library from CMake-based projects, FetchContent can be used. Target
dingo is added as an INTERFACE library without any other dependencies.
<!-- { include("test/fetchcontent/CMakeLists.txt", scope="####") -->
<!-- { include("packaging/fetchcontent/CMakeLists.txt", scope="####") -->
Example code included from
[test/fetchcontent/CMakeLists.txt](test/fetchcontent/CMakeLists.txt):
[packaging/fetchcontent/CMakeLists.txt](packaging/fetchcontent/CMakeLists.txt):
```CMake
include(FetchContent)
Expand Down
File renamed without changes.
File renamed without changes.
14 changes: 14 additions & 0 deletions packaging/vcpkg/dingo/portfile.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
vcpkg_from_github(
OUT_SOURCE_PATH SOURCE_PATH
REPO romanpauk/dingo
REF a1434efa8880d5f7c8a59dc2f1f949f14c349e5c
HEAD_REF master
SHA512 ea202a92027fefe8d6ca89130c66bb4950be0ed8ee227a5fd300adb19d71c3bce84b1ef059b30e893dc38670f1e1cef3a258c25285ea46efc02992f8b50cea76
)

vcpkg_cmake_configure(SOURCE_PATH "${SOURCE_PATH}")
vcpkg_cmake_install()
vcpkg_install_copyright(FILE_LIST "${SOURCE_PATH}/LICENSE")

file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug")
file(INSTALL "${CMAKE_CURRENT_LIST_DIR}/usage" DESTINATION "${CURRENT_PACKAGES_DIR}/share/${PORT}")
5 changes: 5 additions & 0 deletions packaging/vcpkg/dingo/usage
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@

dingo provides the following interface library target:

find_package(dingo CONFIG REQUIRED)
target_link_libraries(main PRIVATE dingo::dingo)
17 changes: 17 additions & 0 deletions packaging/vcpkg/dingo/vcpkg.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"name": "dingo",
"version": "0.0.1",
"homepage": "https://github.com/romanpauk/dingo",
"description": "Dependency Injection Container for C++, with DI, next-gen and an 'o' in a name. Header only.",
"license": "MIT",
"dependencies": [
{
"name" : "vcpkg-cmake",
"host" : true
},
{
"name" : "vcpkg-cmake-config",
"host" : true
}
]
}

0 comments on commit 280526a

Please sign in to comment.