Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
77 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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) | ||
|