Skip to content

Commit

Permalink
Use vcpkg
Browse files Browse the repository at this point in the history
  • Loading branch information
youyuanwu committed Nov 8, 2023
1 parent b7e25e2 commit 7228ddb
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 15 deletions.
16 changes: 3 additions & 13 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ jobs:
matrix:
BUILD_TYPE: ["Debug", "Release"]
os: [ windows-latest ]
BOOST_VERSION: [ 1.79.0, 1.83.0 ]
steps:
- uses: actions/checkout@v2

Expand All @@ -19,17 +18,10 @@ jobs:
- name: Get specific version CMake, v3.21.2
uses: lukka/[email protected]

- name: Get Boost
uses: MarkusJx/[email protected]
id: install-boost
- name: Setup vcpkg (it does not install any package yet)
uses: lukka/run-vcpkg@v11
with:
# REQUIRED: Specify the required boost version
# A list of supported versions can be found here:
# https://github.com/MarkusJx/prebuilt-boost/blob/main/versions-manifest.json
boost_version: ${{ matrix.BOOST_VERSION }}
toolset: msvc
platform_version: 2022
link: static
vcpkgGitCommitId: 486a4640db740f5994e492eb60748111dfc48de7

- name: Get OpenCppCoverage
if: ${{ matrix.BUILD_TYPE == 'Debug' }}
Expand All @@ -41,8 +33,6 @@ jobs:
powershell.exe -Command "Add-Content $env:GITHUB_PATH 'C:\Program Files\OpenCppCoverage'"
- name: run cmake
env:
BOOST_ROOT: ${{ steps.install-boost.outputs.BOOST_ROOT }}
run: >
cmake . -DCMAKE_BUILD_TYPE=${{ matrix.BUILD_TYPE }} -B build
- name: run build
Expand Down
15 changes: 13 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,12 +1,23 @@
cmake_minimum_required(VERSION 3.14)

project(winasio)

set(winasio_MAIN_PROJECT OFF)
if (CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_SOURCE_DIR)
set(winasio_MAIN_PROJECT ON)
endif()

if(winasio_MAIN_PROJECT AND NOT WINASIO_CI_FORMAT)
# configure vcpkg
# we use CmakePresets.json to point to vcpkg
if ("$ENV{VCPKG_ROOT}" STREQUAL "")
message(FATAL_ERROR "VCPKG_ROOT not found")
endif()
set(CMAKE_TOOLCHAIN_FILE "$ENV{VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake")
endif()

project(winasio VERSION 0.0.1 LANGUAGES CXX)

message(STATUS "vcpkg installed dir: ${VCPKG_INSTALLED_DIR}")

option(winasio_BuildTests "Build the unit tests when BUILD_TESTING is enabled." ${winasio_MAIN_PROJECT})
option(winasio_BuildExamples "Build examples" ${winasio_MAIN_PROJECT})

Expand Down
11 changes: 11 additions & 0 deletions vcpkg.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"$schema": "https://raw.githubusercontent.com/microsoft/vcpkg-tool/main/docs/vcpkg.schema.json",
"name": "winasio",
"version": "0.0.1",
"dependencies": [
"boost-asio",
"boost-log",
"boost-test",
"boost-beast"
]
}

0 comments on commit 7228ddb

Please sign in to comment.