Skip to content
You're viewing an older version of this GitHub Action. Do you want to see the latest version instead?

Action Status

Build C++ software with the multi-platform run-cmake action by running CMake on GitHub workflows. Samples provided use GitHub hosted runners and Caching.

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

User Manual

Developer Manual

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

  # Sample when vcpkg is a submodule of your repository (highly recommended!)

jobs: 
  build:
    env:
      buildDir: '${{ github.workspace }}/build'
    steps:
      # Cache/Restore the vcpkg's build artifacts using a vcpkg.json manifest.
      - name: Run vcpkg
        uses: lukka/run-vcpkg@v6
        with:
          # Just install vcpkg for now, do not install any ports in this step yet.
          setupOnly: true
          # Location of the vcpkg as submodule of the 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.json' ) }}
          vcpkgTriplet: ${{ matrix.triplet }}
          # Ensure the vcpkg artifacts are cached, they are generated in the 'CMAKE_BINARY_DIR/vcpkg_installed'.
          additionalCachedPaths: ${{ env.buildDir }}/vcpkg_installed
      - name: 'Run CMake with Ninja, install dependencies with vcpkg, build with CMake'
        uses: lukka/run-cmake@v3
        with:
          cmakeListsOrSettingsJson: CMakeListsTxtAdvanced
          cmakeListsTxtPath: '${{ github.workspace }}/cmakesettings.json/CMakeLists.txt'
          useVcpkgToolchainFile: true
          cmakeAppendedArgs: '-GNinja'
          buildDirectory: ${{ env.buildDir }}
          # Or build multiple configurations out of a CMakeSettings.json file created with Visual Studio.
          # cmakeListsOrSettingsJson: CMakeSettingsJson
          # cmakeSettingsJsonPath: '${{ github.workspace }}/cmakesettings.json/CMakeSettings.json'
          # configurationRegexFilter: '${{ matrix.configuration }}'

run-cmake flowchart

This action behaves the same way as it does the run-cmake task for Azure DevOps.

The documentation of the 'run-cmake" action is identical to the 'run-cmake' task's one for Azure DevOps.

Features available only in the GitHub version of 'run-cmake':

  • Annotations for CMake errors/warnings and for build (gcc/msvc/clang) errors/warning are created inline in the changed source files the build run for, e.g.: Annotation

action.yml

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, with cache and vcpkg as submodule Actions Status
CMakeSettings.json samples
Linux/macOS/Windows, hosted runner, with cache and vcpkg as submodule Actions Status
Project Platform(s)
CppOpenGLWebAssemblyCMake WASM/Linux/macOS Actions Status
quiniouben/vban Windows/Linux CI
OPM/ResInsight Windows/Linux CI
Mudlet/Mudlet Linux/macOS Build Mudlet
otland/forgottenserver Linux/macOS/Windows Build with vcpkg
Element-0/ElementZero Windows CI
assimp/assimp Linux/macOS/Windows C/C++ CI
sony/nmos-cpp Linux/macOS/Windows build-test
RaftLib/RaftLib Linux/macOS/Windows CI
zealdocs/zeal Linux/Windows Build Check
marian-nmt/marian-dev Windows/Linux/macOS Windows Linux macOS
GrinPlusPlus Linux/Windows/macOS ci
OpenTDD Windows/macOS CI

Developers information

Prerequisites

gulp 4 globally installed.

Setup for GitHub Registry public packages

run-vcpkg depends on public NPM packages published by lukka/run-cmake-vcpkg-action-libs in the GitHub Packages registry. Unexpectedly, a public package still requires authentication when downloading it, hence if you want to npm install those packages correctly, you need to obtain a token with read:packages scope. Then create in the root of the repository a .npmrc file with the following content:

//npm.pkg.github.com/:_authToken=YOURTOKEN @lukka:registry=https://npm.pkg.github.com/

Note: Never commit this .npmrc file!

Build and lint

Build with tsc running:

npm run build

Launch lint by:

npm run lint

Packaging

To build, lint validate and package the extension for release purpose, run:

npm run pack

Testing

To build, pack and test:

npm run test

To run test directly:

jest

Validation tests on various scenarios are run using the workflows of the Samples.

The software is provided as is, there is no warranty of any kind. All users are encouraged to improve the source code with fixes and new features.

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.