GitHub 在 GitHub 上使用 CMake (CMakePresets.json)、Ninja 和 vcpkg 构建 C++ 应用程序的操作。
GitHub 在 GitHub 上使用 CMake (CMakePresets.json)、Ninja 和 vcpkg 构建 C++ 应用程序的操作。
Take a look at this C++ project template that applies all the following instructions, but also shows how to create a pure workflow without using special GitHub action that you cannot run locally on your development machine, but directly using the tools (CMake, Ninja, vcpkg, C++ compilers) you already use daily.
The run-cmake action runs CMake on GitHub workflows leveraging CMakePresets.json. Note that usage of CMakePresets.json is required.
Good companions are the run-vcpkg action and the get-cmake action.
Special features which provide added value over a pure workflow are:
annotations for CMake errors/warnings and for build (gcc/msvc/clang) errors/warnings are created inline in the changed source files the build run for, e.g.:
when necessary, it sets up the environment to build with the MSVC toolset.
automatic dump of log files created by CMake (e.g., CMakeOutput.log) and vcpkg. The content of those files flow into the workflow output log. The regex is customizable by the user.
The provided samples use GitHub hosted runners.
Good companions are the run-vcpkg action and the get-cmake action.
It is highly recommended to use:
…Using github.workspace may be challenging since it contains backslashes on Windows which are interpreted as escape sequences when used as base path of additional arguments. To work around this, you could use the String.raw function which prevents the escape sequences from being processed, e.g.:
with:
configurePresetAdditionalArgs: "[ String.raw`-DD3D9_INCLUDE_DIR=${{ github.workspace }}/cache/Include` ]"Description of all input parameters: action.yml
Flowchart with related input in action.yml which let customize the flow.
…If you want vcpkg env to avoid adding tool paths to PATH, provide a custom runVcpkgEnvFormatString without --tools, for example:
runVcpkgEnvFormatString: "[`env`, `--bin`, `--include`, `--python`, `--triplet`, `$[env.VCPKG_DEFAULT_TRIPLET]`, `set`]"Checkmarks indicates whether the samples "uses" or specifies the thing in the header or whether it is true.
| workflow link | vcpkg as submodule |
explicit triplet | vcpkg toolchain |
CMake's Presets |
Ninja |
run-vcpkg runs vcpkg |
CMake runs vcpkg |
|---|---|---|---|---|---|---|---|
| link | ✅ | ❌ | ✅ | ✅ | ✅ | ❌ | ✅ |
| link | ❌ | ❌ | ✅ | ✅ | ✅ | ❌ | ✅ |
| link | ❌ | ❌ | ✅ | ✅ | ✅ | ✅ | ❌ |
| link | ✅ | ✅ | ✅ | ✅ | ✅ | ❌ | ✅ |
run-cmakeThis graph shows the list of public repositories with more than 25 stars using run-cmake.
All the content in this repository is licensed under the MIT License.
Copyright © 2019-2020-2021-2022-2023-2024-2025 Luca Cappa
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.
Read CONTRIBUTING.md
暂无开放 Issues,或尚未同步最近议题。