mirror of
				https://github.com/threeal/cmake-action.git
				synced 2025-11-04 05:43:42 +00:00 
			
		
		
		
	Configure and build CMake projects on GitHub Actions
			
		
		
		
		
		
		
		
		
		
		
		
			
				Bumps [actions/checkout](https://github.com/actions/checkout) from 3.5.0 to 3.5.1. - [Release notes](https://github.com/actions/checkout/releases) - [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md) - [Commits](https://github.com/actions/checkout/compare/v3.5.0...v3.5.1) --- updated-dependencies: - dependency-name: actions/checkout dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com>  | 
			||
|---|---|---|
| .github | ||
| test | ||
| .gitignore | ||
| action.yml | ||
| LICENSE | ||
| README.md | ||
CMake Action
Configure, build, and test a CMake project on GitHub Actions.
Use this action to simplify the workflow run of your CMake project.
This action will configure a build environment for your project using the cmake command,
then it will build your project by running a cmake --build command,
and last it could test your project using the ctest command.
Features
- Configure and build a project using the cmake command.
 - Optionally test a project using the ctest command.
 - Auto-detect and install required dependencies.
 - Specify multiple CMake options directly from the Action inputs.
 
Usage
For more information, see action.yml and GitHub Actions guide.
Inputs
| Name | Value Type | Description | 
|---|---|---|
source-dir | 
Path | Source directory of the CMake project. Defaults to current directory. | 
build-dir | 
Path | Build directory of the CMake project. Defaults to build directory inside the source directory. | 
targets | 
Multiple strings | List of build targets. | 
run-test | 
true or false | 
If enabled, run testing using CTest. Defaults to false. | 
generator | 
String | Build system generator of the CMake project. | 
c-compiler | 
String | Preferred executable for compiling C language files. | 
cxx-compiler | 
String | 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. | 
test-args | 
Multiple strings | Additional arguments passed during the CTest run. | 
Note: Multiple strings mean that the input could 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 this repository
        uses: actions/checkout@v3.3.0
      - name: Configure and build this project
        uses: threeal/cmake-action@latest
Note: You can replace
@latestwith any version you like. See this.
Specify the Source and the Build Directories
- name: Configure and build this project
  uses: threeal/cmake-action@latest
  with:
    source-dir: submodules
    build-dir: submodules/out
Specify the Build Targets
- name: Configure and build this project
  uses: threeal/cmake-action@latest
  with:
    targets: hello_mars hello_sun
Run Unit Tests After Build
- name: Configure, build, and test this project
  uses: threeal/cmake-action@latest
  with:
    args: -DBUILD_TESTING=ON
    run-test: true
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