Skip to content

Commit

Permalink
add workflow with triplet (#13)
Browse files Browse the repository at this point in the history
  • Loading branch information
lukka committed Nov 7, 2021
1 parent f1a1476 commit ad9884e
Show file tree
Hide file tree
Showing 2 changed files with 77 additions and 0 deletions.
66 changes: 66 additions & 0 deletions .github/workflows/hosted-ninja-vcpkg_submod-triplet.yml
@@ -0,0 +1,66 @@
# Copyright (c) 2019-2020-2021 Luca Cappa
# Released under the term specified in file LICENSE.txt
# SPDX short identifier: MIT
#
# The peculiarity of this workflow is that assumes vcpkg stored as a submodule of this repository.
# This workflow does the following:
# - Restores vcpkg artifacts from cache.
# - Sets up vcpkg if needed, then run CMake with CMakePreset.json using a configuration
# that leverages the vcpkg's toolchain file. This will automatically run vcpkg to install dependencies
# described by the vcpkg.json manifest file. It will be a no-op if those are restored from cache.
# - Finally builds the sources with Ninja.
name: hosted-ninja-vcpkg_submod-triplet-autocache
on: [push, workflow_dispatch]

jobs:
job:
name: ${{ matrix.os }}-${{ github.workflow }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
include:
- os: windows-latest
triplet: x64-windows
- os: ubuntu-latest
triplet: x64-linux
- os: macos-latest
triplet: x64-osx

env:
VCPKG_DEFAULT_TRIPLET: ${{ matrix.triplet }}

steps:
- uses: actions/checkout@v2
with:
submodules: true

- uses: lukka/get-cmake@latest
- name: dir
run: find $RUNNER_WORKSPACE
shell: bash

- name: Restore artifacts, or setup vcpkg for building artifacts
uses: lukka/run-vcpkg@v10
id: runvcpkg
with:
# This one is not needed, as it is the default value anyway.
# vcpkgDirectory: '${{ github.workspace }}/vcpkg'
vcpkgJsonGlob: '**/cmakepresets/vcpkg.json'

- name: List $RUNNER_WORKSPACE before build
run: find $RUNNER_WORKSPACE
shell: bash
- name: Prints output of run-vcpkg's action.
run: echo "root='${{ steps.runvcpkg.outputs.RUNVCPKG_VCPKG_ROOT_OUT }}', triplet='${{ steps.runvcpkg.outputs.RUNVCPKG_VCPKG_DEFAULT_TRIPLET_OUT }}' "
- name: Run CMake+vcpkg+Ninja
uses: lukka/run-cmake@v10
id: runcmake
with:
cmakeListsTxtPath: '${{ github.workspace }}/cmakepresets/CMakeLists.txt'
configurePreset: 'ninja-multi-vcpkg'
buildPreset: 'ninja-multi-vcpkg'
- name: List $RUNNER_WORKSPACE after build
run: find $RUNNER_WORKSPACE
shell: bash
11 changes: 11 additions & 0 deletions cmakepresets/CMakeLists.txt
@@ -1,11 +1,22 @@
# CMakeLists.txt

# Ensure to pick up the default triplet from the environment if any. This helps
# driving the vcpkg triplet in the same way either when starting vcpkg directly,
# or when letting CMake start vcpkg at configure/generate time.
# Note: this logic must happen before PROJECT command.
if(DEFINED ENV{VCPKG_DEFAULT_TRIPLET} AND NOT DEFINED VCPKG_TARGET_TRIPLET)
set(VCPKG_TARGET_TRIPLET "$ENV{VCPKG_DEFAULT_TRIPLET}" CACHE STRING "The vcpkg triplet")
endif()

cmake_minimum_required(VERSION 3.0)
project(test)


find_package(unofficial-sqlite3 CONFIG REQUIRED)
find_package(fmt CONFIG REQUIRED)

add_executable(main)
target_sources(main PRIVATE test.cpp)
target_link_libraries(main PRIVATE unofficial::sqlite3::sqlite3 fmt::fmt)
set_property(TARGET main PROPERTY CXX_STANDARD 20)

0 comments on commit ad9884e

Please sign in to comment.