mirror of
https://github.com/threeal/cmake-action.git
synced 2025-07-27 08:14:23 +00:00
docs(readme): improve example usages section
This commit is contained in:
parent
e64a84070b
commit
7e60273426
66
README.md
66
README.md
@ -28,6 +28,8 @@ This action wraps the [`cmake`](https://cmake.org/cmake/help/latest/manual/cmake
|
|||||||
|
|
||||||
## Example Usages
|
## Example Usages
|
||||||
|
|
||||||
|
This example demonstrates how to use this action to configure and build a CMake project in a GitHub Actions workflow:
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
name: Build
|
name: Build
|
||||||
on:
|
on:
|
||||||
@ -37,48 +39,66 @@ jobs:
|
|||||||
name: Build Project
|
name: Build Project
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout Project
|
||||||
uses: actions/checkout@v4.1.7
|
uses: actions/checkout@v4.1.7
|
||||||
|
|
||||||
- name: Configure and Build Project
|
- name: Build Project
|
||||||
uses: threeal/cmake-action@main
|
uses: threeal/cmake-action@v2.0.0
|
||||||
```
|
|
||||||
|
|
||||||
> **Note**: You can replace `main` with any version you prefer. See [this](https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsuses).
|
|
||||||
|
|
||||||
### Configure Project Without Building
|
|
||||||
|
|
||||||
```yaml
|
|
||||||
- name: Configure Project
|
|
||||||
uses: threeal/cmake-action@main
|
|
||||||
with:
|
|
||||||
run-build: false
|
|
||||||
```
|
```
|
||||||
|
|
||||||
### Specify the Source and Build Directories
|
### Specify the Source and Build Directories
|
||||||
|
|
||||||
|
By default, this action uses the current working directory as the source directory and the `build` directory inside the source directory as the build directory. To use different directories, set the `source-dir` and/or `build-dir` inputs:
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
- name: Configure and Build Project
|
- name: Build Project
|
||||||
uses: threeal/cmake-action@main
|
uses: threeal/cmake-action@v2.0.0
|
||||||
with:
|
with:
|
||||||
source-dir: submodules
|
source-dir: source
|
||||||
build-dir: submodules/out
|
build-dir: output
|
||||||
```
|
```
|
||||||
|
|
||||||
### Using Ninja as the Generator and Clang as the Compiler
|
### Specify Build System Generator and Compiler
|
||||||
|
|
||||||
|
The following example demonstrates how to use this action to configure and build the project using [Ninja](https://ninja-build.org/) as the build system generator and [Clang](https://clang.llvm.org/) as the compiler:
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
- name: Setup Ninja
|
- name: Setup Ninja
|
||||||
uses: seanmiddleditch/gha-setup-ninja@v4
|
uses: seanmiddleditch/gha-setup-ninja@v5
|
||||||
|
|
||||||
- name: Configure and Build Project
|
- name: Build Project
|
||||||
uses: threeal/cmake-action@main
|
uses: threeal/cmake-action@v2.0.0
|
||||||
with:
|
with:
|
||||||
generator: Ninja
|
generator: Ninja
|
||||||
c-compiler: clang
|
|
||||||
cxx-compiler: clang++
|
cxx-compiler: clang++
|
||||||
```
|
```
|
||||||
|
|
||||||
|
### Specify Additional Options
|
||||||
|
|
||||||
|
Use the `options` input to specify additional options for configuring a project:
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
- name: Build Project
|
||||||
|
uses: threeal/cmake-action@v2.0.0
|
||||||
|
with:
|
||||||
|
options: |
|
||||||
|
BUILD_TESTS=ON
|
||||||
|
BUILD_EXAMPLES=ON
|
||||||
|
```
|
||||||
|
|
||||||
|
The above example is equivalent to calling the `cmake` command with the `-DBUILD_TESTS=ON` and `-DBUILD_EXAMPLES=ON` arguments.
|
||||||
|
|
||||||
|
### Configure Project Without Building
|
||||||
|
|
||||||
|
By default, this action builds the project after configuration. To skip the build process, set the `run-build` option to `false`:
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
- name: Configure Project
|
||||||
|
uses: threeal/cmake-action@v2.0.0
|
||||||
|
with:
|
||||||
|
run-build: false
|
||||||
|
```
|
||||||
|
|
||||||
## License
|
## License
|
||||||
|
|
||||||
This project is licensed under the terms of the [MIT License](./LICENSE).
|
This project is licensed under the terms of the [MIT License](./LICENSE).
|
||||||
|
Loading…
Reference in New Issue
Block a user