All Projects → lukka → Run Vcpkg

lukka / Run Vcpkg

Licence: mit
GitHub Action to automatically cache and run vcpkg to build C++ dependencies for your C++ based applications. Available as Azure DevOps tasks also: https://marketplace.visualstudio.com/items?itemName=lucappa.cmake-ninja-vcpkg-tasks

Programming Languages

typescript
32286 projects
cpp
1120 projects
cplusplus
227 projects

Projects that are alternatives of or similar to Run Vcpkg

Docker Swarm
🐳🐳🐳 This repository is part of a blog series on Docker Swarm example using VirtualBox, OVH Openstack, Azure and Amazon Web Services AWS
Stars: ✭ 43 (-12.24%)
Mutual labels:  devops
Commently
😀💬 Easily comment and update comments on GitHub PRs
Stars: ✭ 45 (-8.16%)
Mutual labels:  devops
Shon
A simple tool to convert json or yaml into a shell-compliant data structure.
Stars: ✭ 47 (-4.08%)
Mutual labels:  devops
Orne navigation
This repository provides mobile robot navigation system with i-Cart mini for Tsukuba Challenge under Project ORNE.
Stars: ✭ 43 (-12.24%)
Mutual labels:  cmake
Ffmpeg Example
FFMPEG 0.11-4.4/LibAV 0.8-11 example application with byte exact reading
Stars: ✭ 44 (-10.2%)
Mutual labels:  cmake
Kapo
Wrap any command in a status socket
Stars: ✭ 45 (-8.16%)
Mutual labels:  devops
Skeleton
Skeleton for quick new C++ project setup
Stars: ✭ 42 (-14.29%)
Mutual labels:  cmake
Pulse
Dynamic, api-driven stats collector service for realtime stats publishing and historical aggregation with Influxdb.
Stars: ✭ 48 (-2.04%)
Mutual labels:  devops
Genepi
Automatic generation of N-API wrapper from a C++ library
Stars: ✭ 45 (-8.16%)
Mutual labels:  cmake
Nonstd Lite
Parent of *-lite repositories, a migration path to post-C++11 features for pre-C++11 environments
Stars: ✭ 46 (-6.12%)
Mutual labels:  cmake
Programming learning resource
学习计算机科学的一些pdf资源
Stars: ✭ 1,019 (+1979.59%)
Mutual labels:  cmake
Libcsptr
Smart pointers for the (GNU) C programming language
Stars: ✭ 1,023 (+1987.76%)
Mutual labels:  cmake
Cpp starter project
A template CMake project to get you started with C++ and tooling
Stars: ✭ 1,025 (+1991.84%)
Mutual labels:  cmake
Pcl For Android
Cross-compilation of PCL (point cloud library) for Android
Stars: ✭ 43 (-12.24%)
Mutual labels:  cmake
Para
Para - community plugin manager and a "swiss army knife" for Terraform/Terragrunt - just 1 tool to facilitate all your workflows.
Stars: ✭ 47 (-4.08%)
Mutual labels:  devops
Picmake
你还在学CMake的过程中毫无头绪吗?你还在为复杂程序库依赖发愁吗?你是否觉得原生CMake的编写冗余而低效?那就快来学习和使用PICMake吧!只需要一行,无论是可执行,动态库还是静态库,轻松搞定!同时高效支持多目标,复杂库的编译安装,从此告别大量冗余CMake代码,专注开发核心应用程序,编译不再愁! 例如下面是使用PICMake编译一个依赖OpenGL的可执行文件,只需要一行!
Stars: ✭ 43 (-12.24%)
Mutual labels:  cmake
Regrader
VST delay plugin where the repeats degrade in resolution
Stars: ✭ 44 (-10.2%)
Mutual labels:  cmake
Piplin
📤 An open source self-hosted continuous integration and deployment system - QQ群: 656868
Stars: ✭ 1,044 (+2030.61%)
Mutual labels:  devops
Bcm
Boost cmake modules
Stars: ✭ 48 (-2.04%)
Mutual labels:  cmake
Octopod
🐙🛠️ Open-source self-hosted solution for managing multiple deployments in a Kubernetes cluster with a user-friendly web interface.
Stars: ✭ 47 (-4.08%)
Mutual labels:  devops

Action Status

Coverage Status

Before using this action, consider writing a pure workflow!

Before using this action, please consider reading and learning how to write a workflow which is directly using the well known tools you can run on your own machine, without relying on GitHub actions that you cannot run on your development machine. You can read more in this issue about it: https://github.com/lukka/run-vcpkg/issues/66

The run-vcpkg action for caching artifacts and using vcpkg on GitHub

The run-vcpkg action restores from cache vcpkg along with the previously installed ports. On the other hand when there is a "cache miss":

  • vpckg is fetched and installed; the cache's key is composed by hashing the hosting OS name, the command line arguments and the vcpkg's commit id.
    • Restoring from cache can be skipped with doNotCache: true.
  • Then vcpkg is run to install the desired ports.
    • This step can be skipped with setupOnly: true.
  • Artifacts and vcpkg are then saved in cache.
    • Saving to cache can be skipped with doNotCache: true.
    • Saving to cache happens at the end of the workflow in case setupOnly: true, otherwise it happens at the end of the action execution.

The provided samples use GitHub hosted runners.

Good companions are the run-cmake action and the get-cmake actions.

User Manual

Contributing

Read CONTRIBUTING.md

Quickstart

Setup vcpkg and use CMake with a vcpkg.json manifest to install dependencies and build your project

It is highly recommended to use both vcpkg as a submodule and a vcpkg.json manifest file to declaratively specify the dependencies.

Both suggestions are shown in the hosted-advanced-setup-vcpkg-manifest.yml workflow, here below an excerpt:

jobs: 
  build:
    env:
      buildDir: '${{ github.workspace }}/build/'
    steps:
      #-uses: actions/[email protected]   <===== YOU DO NOT NEED THIS!
      
      # Install latest CMake.
      - uses: lukka/[email protected]

      # Restore from cache the previously built ports. If a "cache miss" occurs, then vcpkg is bootstrapped. Since a the vcpkg.json is being used later on to install the packages when run-cmake runs, no packages are installed at this time and the input 'setupOnly:true' is mandatory.
      - name: Restore artifacts, or setup vcpkg (do not install any package)
        uses: lukka/[email protected]
        with:
          # Just install vcpkg for now, do not install any ports in this step yet.
          setupOnly: true
          # Location of the vcpkg submodule in the Git repository.
          vcpkgDirectory: '${{ github.workspace }}/vcpkg'
          # Since the cache must be invalidated when content of the vcpkg.json file changes, let's
          # compute its hash and append this to the computed cache's key.
          appendedCacheKey: ${{ hashFiles( '**/vcpkg_manifest/vcpkg.json' ) }}
          vcpkgTriplet: ${{ matrix.triplet }}
          # Ensure the vcpkg artifacts are cached, they are generated in the 'CMAKE_BINARY_DIR/vcpkg_installed' directory.
          additionalCachedPaths: ${{ env.buildDir }}/vcpkg_installed

      - name: Run CMake to install the dependencies specified in the vcpkg.json manifest, generate project file and build the project
        uses: lukka/[email protected]
        with:
          cmakeListsOrSettingsJson: CMakeListsTxtAdvanced
          cmakeListsTxtPath: '${{ github.workspace }}/vcpkg_manifest/CMakeLists.txt'
          buildDirectory: ${{ env.buildDir }}
          # This input tells run-cmake to consume the vcpkg.cmake toolchain file set by run-vcpkg.
          useVcpkgToolchainFile: true
          buildWithCMake: true

Setup vcpkg only and use your own scripts

When setupOnly: true, it only setups vcpkg without installing any port. The provisioned vcpkg can then be used in a subsequent step as shown:

    # Restore from cache the previously built ports. If cache-miss, download and build vcpkg (aka "bootstrap vcpkg").
    - name: Restore from cache and install vcpkg
      # Download and build vcpkg, without installing any port. If content is cached already, it is a no-op.
      uses: lukka/[email protected]
      with:
        setupOnly: true
    # Now that vcpkg is installed, it is being used to run with the desired arguments.
    - run: |
        $VCPKG_ROOT/vcpkg install boost:linux-x64
      shell: bash

Flowchart

run-vcpkg flowchart

Action reference: all input/output parameters

action.yml

Best practices

Use vcpkg as a submodule of your repository

When using vcpkg, be aware of how it works, specifically:

  • a specific version of vcpkg must be used either locally and on build servers;
  • a specific version of vcpkg is identified by the commit id of the used vcpkg repository;
  • it not possible to choose which version of a port to install, instead it is the used version of vcpkg that establishes which version (just one) of a port is available;

To sum up, you need to pin the specific version of vcpkg you want to use to keep a consistent development experience between local and remote build environments. This is accomplished by using vcpkg as submodule of your Git repository; this way the version of vcpkg used is implied by the commit id specified by the submodule for vcpkg.

Use vcpkg's vcpkg.json file to specify the dependencies

The vcpkg.json is a manifest file that declaratively specifies the dependencies to be installed. The file is being used automatically by running CMake when:

  • starting CMake with the vcpkg.cmake toolchain file.
  • the root CMake source directory contains a vcpkg.json file.

When conditions are satisfied, the toolchain execution starts vcpkg to install the packages declared in the manifest file.

Putting this manifest-like file under source control is highly recommended as this helps to run vcpkg the same exact way locally and remotely on the build servers.* The dependencies specified in the vcpkg.json file are installed when CMake runs (i.e. at run-cmake time), hence the 'run-vcpkg' step must have the input setupOnly: true.

Samples

View the workflows based on the run-cmake and run-vcpkg actions.

CMakeLists.txt samples
Linux/macOS/Windows, hosted runner, basic Actions Status
Linux/macOS/Windows, hosted runner, advanced Actions Status
Linux/macOS/Windows, hosted runner, vcpkg as submodule Actions Status
Linux/macOS/Windows, hosted runner, setup only and vcpkg as submodule Actions Status
CMakeSettings.json samples
Linux/macOS/Windows, hosted runner, with vcpkg as submodule Actions Status

Real world project samples

Project Platform(s)
CppOpenGLWebAssemblyCMake WASM/Linux/macOS Actions Status
codehz/wine-bdlauncher Windows CI
OPM/ResInsight Windows/Linux CI
Mudlet/Mudlet Linux/macOS/Windows Build Mudlet
otland/forgottenserver Linux/macOS/Windows Build with vcpkg
Element-0/ElementZero Windows CI
zealdocs/zeal Linux/Windows Build Check
libevent/libevent Windows/macos/Linux WindowsmacOSLinux
marian-nmt/marian-dev Windows/Linux/macOS Windows Linux macOS
GrinPlusPlus Linux/Windows/macOS ci
OpenTDD Windows/macOS CI
scummvm Windows n/a

License

All the content in this repository is licensed under the MIT License.

Copyright (c) 2019-2020-2021 Luca Cappa

Donating

Other than submitting a pull request, donating is another way to contribute to this project.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].