mirror of
https://github.com/threeal/cmake-action.git
synced 2025-04-20 10:41:21 +00:00
Configure and build CMake projects on GitHub Actions
.github | ||
test | ||
.gitignore | ||
action.yml | ||
LICENSE | ||
README.md |
CMake Action
Configure, build, and test your CMake project using GitHub Actions. This action simplifies the workflow for your CMake project. It configures the build environment using the cmake
command, and optionally builds the project using the cmake --build
command and tests the project using the ctest
command.
Features
- Configures a project using the cmake command.
- Option to build a project using the
cmake --build
command. - Option to test a project using the ctest command.
- Auto-detects and installs required dependencies.
- Supports specifying multiple CMake options directly from the Action inputs.
Usage
For more information, refer to action.yml and the GitHub Actions guide.
Inputs
Name | Value Type | Description |
---|---|---|
source-dir |
Path | The source directory of the CMake project. Defaults to the current directory. |
build-dir |
Path | The source directory of the CMake project.. Defaults to the build directory inside the source directory. |
targets |
Multiple strings | A list of build targets. |
generator |
String | The build system generator for the CMake project. |
c-compiler |
String | The preferred executable for compiling C language files. |
cxx-compiler |
String | The preferred executable for compiling C++ language files. |
c-flags |
Multiple strings | Additional flags passed when compiling C language files. |
cxx-flags |
Multiple strings | Additional flags passed when compiling C++ language files. |
args |
Multiple strings | Additional arguments passed during the CMake configuration. |
run-build |
true or false |
If enabled, it builds the project using CTest. Defaults to false . |
run-test |
true or false |
If enabled, it runs testing using CTest. Defaults to false . |
test-args |
Multiple strings | Additional arguments passed during the CTest run. |
Note: Multiple strings mean that the input can be specified with more than one value. Separate each value with a space or a new line.
Note: All inputs are optional.
Examples
name: Build
on:
push:
jobs:
build-project:
runs-on: ubuntu-latest
steps:
- name: Check out the repository
uses: actions/checkout@v3.3.0
- name: Configure the project
uses: threeal/cmake-action@latest
Note: You can replace
@latest
with any version you prefer. See this.
Specify the Source and Build Directories
- name: Configure the project
uses: threeal/cmake-action@latest
with:
source-dir: submodules
build-dir: submodules/out
Configure, Build, and Test in the Same Step
- name: Configure, build, and test the project
uses: threeal/cmake-action@latest
with:
args: -DBUILD_TESTING=ON
run-build: true
run-test: true
Specify the Build Targets
- name: Configure and build this project
uses: threeal/cmake-action@latest
with:
run-build: true
targets: hello_mars hello_sun
Using Ninja as the Generator and Clang as the Compiler
- name: Configure and build this project
uses: threeal/cmake-action@latest
with:
generator: Ninja
c-compiler: clang
cxx-compiler: clang++
License
This project is licensed under the terms of the MIT License.
Copyright © 2023 Alfi Maulana